};
if is_structure {
let fields = ty::lookup_struct_fields(cx.tcx, vid);
- let field_pats = fields.move_iter()
+ let field_pats: Vec<FieldPat> = fields.move_iter()
.zip(pats.iter())
+ .filter(|&(_, pat)| pat.node != PatWild)
.map(|(field, pat)| FieldPat {
ident: Ident::new(field.name),
pat: pat.clone()
}).collect();
- PatStruct(def_to_path(cx.tcx, vid), field_pats, false)
+ let has_more_fields = field_pats.len() < pats.len();
+ PatStruct(def_to_path(cx.tcx, vid), field_pats, has_more_fields)
} else {
PatEnum(def_to_path(cx.tcx, vid), Some(pats))
}
}
ast::PatStruct(ref path, ref fields, etc) => {
try!(self.print_path(path, true));
- try!(word(&mut self.s, "{"));
+ try!(self.nbsp());
+ try!(self.word_space("{"));
try!(self.commasep_cmnt(
Consistent, fields.as_slice(),
|s, f| {
try!(s.cbox(indent_unit));
try!(s.print_ident(f.ident));
- try!(s.word_space(":"));
+ try!(s.word_nbsp(":"));
try!(s.print_pat(&*f.pat));
s.end()
},
if fields.len() != 0u { try!(self.word_space(",")); }
try!(word(&mut self.s, ".."));
}
+ try!(space(&mut self.s));
try!(word(&mut self.s, "}"));
}
ast::PatTup(ref elts) => {
fn struct_with_a_nested_enum_and_vector() {
match (Foo { first: true, second: None }) {
- //~^ ERROR non-exhaustive patterns: `Foo{first: false, second: Some([_, _, _, _])}` not covered
+//~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered
Foo { first: true, second: None } => (),
Foo { first: true, second: Some(_) } => (),
Foo { first: false, second: None } => (),
fn enum_struct_variant() {
match Red {
- //~^ ERROR non-exhaustive patterns: `CustomRGBA{a: true, r: _, g: _, b: _}` not covered
+ //~^ ERROR non-exhaustive patterns: `CustomRGBA { a: true, .. }` not covered
Red => (),
Green => (),
CustomRGBA { a: false, r: _, g: _, b: 0 } => (),
N2[label="expr 6"];
N3[label="expr S6{val: 6,}"];
N4[label="local _x"];
- N5[label="pat S6{val: _x}"];
- N6[label="block { let S6{val: _x} = S6{val: 6,}; }"];
+ N5[label="pat S6 { val: _x }"];
+ N6[label="block { let S6 { val: _x } = S6{val: 6,}; }"];
N0 -> N2;
N2 -> N3;
N3 -> N4;