Skip to content

Commit 1d2308f

Browse files
Rollup merge of #36125 - gavinb:error_msgs_p1, r=jonathandturner
Update Error format for E0164, E0165, E0184 Part of #35233 r? @jonathandturner
2 parents 9a3cfe9 + 2967dcc commit 1d2308f

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

src/librustc_const_eval/check_match.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ fn check_arms(cx: &MatchCheckCtxt,
324324
let &(ref first_arm_pats, _) = &arms[0];
325325
let first_pat = &first_arm_pats[0];
326326
let span = first_pat.span;
327-
span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern");
327+
struct_span_err!(cx.tcx.sess, span, E0165,
328+
"irrefutable while-let pattern")
329+
.span_label(span, &format!("irrefutable pattern"))
330+
.emit();
328331
},
329332

330333
hir::MatchSource::ForLoopDesugar => {

src/librustc_typeck/check/_match.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
574574
tcx.sess.add_lint(lint::builtin::MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT,
575575
pat.id, pat.span, msg);
576576
} else {
577-
span_err!(tcx.sess, pat.span, E0164, "{}", msg);
577+
struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg)
578+
.span_label(pat.span, &format!("not a tuple variant or struct")).emit();
578579
on_error();
579580
}
580581
};

src/librustc_typeck/coherence/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,11 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
348348
.emit();
349349
}
350350
Err(CopyImplementationError::HasDestructor) => {
351-
span_err!(tcx.sess, span, E0184,
351+
struct_span_err!(tcx.sess, span, E0184,
352352
"the trait `Copy` may not be implemented for this type; \
353-
the type has a destructor");
353+
the type has a destructor")
354+
.span_label(span, &format!("Copy not allowed on types with destructors"))
355+
.emit();
354356
}
355357
}
356358
});

src/test/compile-fail/E0164.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum Foo { B { i: u32 } }
1313
fn bar(foo: Foo) -> u32 {
1414
match foo {
1515
Foo::B(i) => i, //~ ERROR E0164
16+
//~| NOTE not a tuple variant or struct
1617
}
1718
}
1819

src/test/compile-fail/E0165.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct Irrefutable(i32);
1313
fn main() {
1414
let irr = Irrefutable(0);
1515
while let Irrefutable(x) = irr { //~ ERROR E0165
16+
//~| irrefutable pattern
1617
// ...
1718
}
1819
}

src/test/compile-fail/E0184.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// except according to those terms.
1010

1111
#[derive(Copy)] //~ ERROR E0184
12+
//~| NOTE Copy not allowed on types with destructors
13+
//~| NOTE in this expansion of #[derive(Copy)]
1214
struct Foo;
1315

1416
impl Drop for Foo {

0 commit comments

Comments
 (0)