improve error message for WF Tuples

This commit is contained in:
Ariel Ben-Yehuda 2016-04-22 17:26:31 +03:00
parent 05f1a057b6
commit 5876b4b12a
3 changed files with 10 additions and 1 deletions

View File

@ -768,6 +768,10 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
err.fileline_note(
cause_span,
"tuple elements must have `Sized` type");
err.fileline_warn(
cause_span,
"this is a new restriction added in rustc 1.10");
}
ObligationCauseCode::ProjectionWf(data) => {
err.note(&format!("required so that the projection `{}` is well-formed",

View File

@ -60,7 +60,9 @@ fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
f5(&(*x1, 34));
//~^ ERROR `X: std::marker::Sized` is not satisfied
//~^^ ERROR `X: std::marker::Sized` is not satisfied
//~| WARNING this is a new restriction added in rustc 1.10
//~^^^ ERROR `X: std::marker::Sized` is not satisfied
//~| WARNING this is a new restriction added in rustc 1.10
}
fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {

View File

@ -15,12 +15,15 @@ trait T {}
fn f1<X: ?Sized>(x: &X) {
let _: X; // <-- this is OK, no bindings created, no initializer.
let _: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfied
//~| WARNING this is a new restriction added in rustc 1.10
let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
let y: (isize, (X, usize)); //~ERROR `X: std::marker::Sized` is not satisfied
//~| WARNING this is a new restriction added in rustc 1.10
}
fn f2<X: ?Sized + T>(x: &X) {
let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
let y: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfied
//~| WARNING this is a new restriction added in rustc 1.10
}
fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {