Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated E0071 to new format. #35285

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3147,9 +3147,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
};
if variant.is_none() || variant.unwrap().kind == ty::VariantKind::Tuple {
// Reject tuple structs for now, braced and unit structs are allowed.
span_err!(self.tcx.sess, span, E0071,
"`{}` does not name a struct or a struct variant",
pprust::path_to_string(path));
struct_span_err!(self.tcx.sess, path.span, E0071,
"`{}` does not name a struct or a struct variant",
pprust::path_to_string(path))
.span_label(path.span, &format!("not a struct"))
.emit();

return None;
}

Expand Down
9 changes: 7 additions & 2 deletions src/test/compile-fail/E0071.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
enum Foo { FirstValue(i32) }

fn main() {
let u = Foo::FirstValue { value: 0 }; //~ ERROR E0071
let t = u32 { value: 4 }; //~ ERROR E0071
let u = Foo::FirstValue { value: 0 };
//~^ ERROR `Foo::FirstValue` does not name a struct or a struct variant [E0071]
//~| NOTE not a struct

let t = u32 { value: 4 };
//~^ ERROR `u32` does not name a struct or a struct variant [E0071]
//~| NOTE not a struct
}
1 change: 1 addition & 0 deletions src/test/compile-fail/trait-as-struct-constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ trait TraitNotAStruct {}
fn main() {
TraitNotAStruct{ value: 0 };
//~^ ERROR: `TraitNotAStruct` does not name a struct or a struct variant [E0071]
//~| NOTE not a struct
}