diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 4f8c11d828544..47ffa9359d82f 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1124,11 +1124,12 @@ impl<'self> fmt::Default for Sidebar<'self> {
write!(w, "{name}
",
ty = short,
+ tysel = short,
class = class,
curty = shortty(cur),
name = item.as_slice());
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index d33ae06911228..ef3879f56aec9 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -22,7 +22,6 @@ use std::vec;
#[deriving(Eq)]
enum ArgumentType {
- Unknown,
Known(@str),
Unsigned,
String,
@@ -153,14 +152,13 @@ impl Context {
parse::ArgumentIs(i) => Left(i),
parse::ArgumentNamed(s) => Right(s.to_managed()),
};
- let ty = if arg.format.ty == "" {
- Unknown
- } else { Known(arg.format.ty.to_managed()) };
- self.verify_arg_type(pos, ty);
// and finally the method being applied
match arg.method {
- None => {}
+ None => {
+ let ty = Known(arg.format.ty.to_managed());
+ self.verify_arg_type(pos, ty);
+ }
Some(ref method) => { self.verify_method(pos, *method); }
}
}
@@ -253,7 +251,7 @@ impl Context {
return;
}
self.verify_same(self.args[arg].span, ty, self.arg_types[arg]);
- if ty != Unknown || self.arg_types[arg].is_none() {
+ if self.arg_types[arg].is_none() {
self.arg_types[arg] = Some(ty);
}
}
@@ -269,7 +267,7 @@ impl Context {
};
self.verify_same(span, ty,
self.name_types.find(&name).map(|&x| *x));
- if ty != Unknown || !self.name_types.contains_key(&name) {
+ if !self.name_types.contains_key(&name) {
self.name_types.insert(name, ty);
}
// Assign this named argument a slot in the arguments array if
@@ -292,9 +290,8 @@ impl Context {
/// that: `Some(None) == Some(Some(x))`
fn verify_same(&self, sp: Span, ty: ArgumentType,
before: Option) {
- if ty == Unknown { return }
let cur = match before {
- Some(Unknown) | None => return,
+ None => return,
Some(t) => t,
};
if ty == cur { return }
@@ -649,9 +646,9 @@ impl Context {
};
let fmt_trait = match ty {
- Unknown => "Default",
Known(tyname) => {
match tyname.as_slice() {
+ "" => "Default",
"?" => "Poly",
"b" => "Bool",
"c" => "Char",
diff --git a/src/test/compile-fail/ifmt-bad-arg.rs b/src/test/compile-fail/ifmt-bad-arg.rs
index f9552725af345..aace3815e840a 100644
--- a/src/test/compile-fail/ifmt-bad-arg.rs
+++ b/src/test/compile-fail/ifmt-bad-arg.rs
@@ -65,8 +65,8 @@ fn main() {
// format strings because otherwise the "internal pointer of which argument
// is next" would be invalidated if different cases had different numbers of
// arguments.
- format!("{0, select, other{{}}}", "a"); //~ ERROR: cannot use implicit
- format!("{0, plural, other{{}}}", 1); //~ ERROR: cannot use implicit
+ format!("{1, select, other{{}}}", 1, "a"); //~ ERROR: cannot use implicit
+ format!("{1, plural, other{{}}}", 1, 1); //~ ERROR: cannot use implicit
format!("{0, plural, other{{1:.*d}}}", 1, 2); //~ ERROR: cannot use implicit
format!("foo } bar"); //~ ERROR: unmatched `}` found
diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs
index 6ca21c6c5a198..2f5d4380f2e18 100644
--- a/src/test/run-pass/ifmt.rs
+++ b/src/test/run-pass/ifmt.rs
@@ -85,7 +85,6 @@ pub fn main() {
t!(format!("{1} {0}", 0, 1), "1 0");
t!(format!("{foo} {bar}", foo=0, bar=1), "0 1");
t!(format!("{foo} {1} {bar} {0}", 0, 1, foo=2, bar=3), "2 1 3 0");
- t!(format!("{} {0:s}", "a"), "a a");
t!(format!("{} {0}", "a"), "a a");
t!(format!("{foo_bar}", foo_bar=1), "1");
@@ -98,8 +97,8 @@ pub fn main() {
t!(format!("{0, select, a{a#} b{b#} c{c#} other{d#}}", "b"), "bb");
t!(format!("{0, select, a{a#} b{b#} c{c#} other{d#}}", "c"), "cc");
t!(format!("{0, select, a{a#} b{b#} c{c#} other{d#}}", "d"), "dd");
- t!(format!("{1, select, a{#{0:s}} other{#{1}}}", "b", "a"), "ab");
- t!(format!("{1, select, a{#{0}} other{#{1}}}", "c", "b"), "bb");
+ t!(format!("{1, select, a{#{0:s}} other{#}}", "b", "a"), "ab");
+ t!(format!("{1, select, a{#{0}} other{#}}", "c", "b"), "b");
// Formatting strings and their arguments
t!(format!("{:s}", "a"), "a");