Skip to content

Commit 5876b4b

Browse files
committed
improve error message for WF Tuples
1 parent 05f1a05 commit 5876b4b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/librustc/traits/error_reporting.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,10 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
768768
err.fileline_note(
769769
cause_span,
770770
"tuple elements must have `Sized` type");
771+
772+
err.fileline_warn(
773+
cause_span,
774+
"this is a new restriction added in rustc 1.10");
771775
}
772776
ObligationCauseCode::ProjectionWf(data) => {
773777
err.note(&format!("required so that the projection `{}` is well-formed",

src/test/compile-fail/unsized3.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
6060
fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
6161
f5(&(*x1, 34));
6262
//~^ ERROR `X: std::marker::Sized` is not satisfied
63-
//~^^ ERROR `X: std::marker::Sized` is not satisfied
63+
//~| WARNING this is a new restriction added in rustc 1.10
64+
//~^^^ ERROR `X: std::marker::Sized` is not satisfied
65+
//~| WARNING this is a new restriction added in rustc 1.10
6466
}
6567

6668
fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {

src/test/compile-fail/unsized6.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ trait T {}
1515
fn f1<X: ?Sized>(x: &X) {
1616
let _: X; // <-- this is OK, no bindings created, no initializer.
1717
let _: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfied
18+
//~| WARNING this is a new restriction added in rustc 1.10
1819
let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
1920
let y: (isize, (X, usize)); //~ERROR `X: std::marker::Sized` is not satisfied
21+
//~| WARNING this is a new restriction added in rustc 1.10
2022
}
2123
fn f2<X: ?Sized + T>(x: &X) {
2224
let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
2325
let y: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfied
26+
//~| WARNING this is a new restriction added in rustc 1.10
2427
}
2528

2629
fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {

0 commit comments

Comments
 (0)