Skip to content

Commit e606055

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35526 - munyari:e0033, r=jonathandturner
Update E0033 to the new error format Part of rust-lang#35233 Addresses rust-lang#35498 "r? @jonathandturner
2 parents 57a1f68 + a37e90a commit e606055

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/librustc_typeck/check/_match.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
347347
if let ty::TyTrait(..) = mt.ty.sty {
348348
// This is "x = SomeTrait" being reduced from
349349
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
350-
span_err!(self.tcx.sess, span, E0033,
351-
"type `{}` cannot be dereferenced",
352-
self.ty_to_string(expected));
350+
let type_str = self.ty_to_string(expected);
351+
struct_span_err!(self.tcx.sess, span, E0033,
352+
"type `{}` cannot be dereferenced", type_str)
353+
.span_label(span, &format!("type `{}` cannot be dereferenced", type_str))
354+
.emit();
353355
return false
354356
}
355357
}

src/test/compile-fail/E0033.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ trait SomeTrait {
1313
}
1414

1515
fn main() {
16-
let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425
17-
//~^ ERROR E0038
18-
let &invalid = trait_obj; //~ ERROR E0033
16+
let trait_obj: &SomeTrait = SomeTrait;
17+
//~^ ERROR E0425
18+
//~| ERROR E0038
19+
//~| method `foo` has no receiver
20+
//~| NOTE the trait `SomeTrait` cannot be made into an object
21+
22+
let &invalid = trait_obj;
23+
//~^ ERROR E0033
24+
//~| NOTE type `&SomeTrait` cannot be dereferenced
1925
}

0 commit comments

Comments
 (0)