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

E0248, E0267 & E0268 New Format #35475

Closed
wants to merge 13 commits into from
8 changes: 6 additions & 2 deletions src/librustc_passes/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ impl<'a> CheckLoopVisitor<'a> {
match self.cx {
Loop => {}
Closure => {
span_err!(self.sess, span, E0267, "`{}` inside of a closure", name);
struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name)
.span_label(span, &format!("cannot break inside of a closure"))
.emit();
}
Normal => {
span_err!(self.sess, span, E0268, "`{}` outside of loop", name);
struct_span_err!(self.sess, span, E0268, "`{}` outside of loop", name)
.span_label(span, &format!("cannot break outside of a loop"))
.emit();
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,9 +1582,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
return self.tcx().types.err;
}
_ => {
span_err!(tcx.sess, span, E0248,
"found value `{}` used as a type",
tcx.item_path_str(def.def_id()));
struct_span_err!(tcx.sess, span, E0248,
"found value `{}` used as a type",
tcx.item_path_str(def.def_id()))
.span_label(span, &format!("value used as a type"))
.emit();
return self.tcx().types.err;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0248.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ enum Foo {
}

fn do_something(x: Foo::Bar) { } //~ ERROR E0248

//~| NOTE value used as a type
fn main() {
}
1 change: 1 addition & 0 deletions src/test/compile-fail/E0267.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

fn main() {
let w = || { break; }; //~ ERROR E0267
//~| NOTE cannot break inside of a closure
}
1 change: 1 addition & 0 deletions src/test/compile-fail/E0268.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

fn main() {
break; //~ ERROR E0268
//~| NOTE cannot break outside of a loop
}