From 5876b4b12aca5c614cf83218a1ca1fe10dde5422 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Fri, 22 Apr 2016 17:26:31 +0300 Subject: [PATCH] improve error message for WF Tuples --- src/librustc/traits/error_reporting.rs | 4 ++++ src/test/compile-fail/unsized3.rs | 4 +++- src/test/compile-fail/unsized6.rs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index d02dfcd9ea7..98812f4e00f 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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", diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index 1d93645fc84..d5f2cf65a69 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -60,7 +60,9 @@ fn f8(x1: &S, x2: &S) { fn f9(x1: Box>, x2: Box>) { 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(x1: Box>, x2: Box>) { diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index e18ccfee96c..ba9a8a4f294 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -15,12 +15,15 @@ trait T {} fn f1(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: &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(x1: Box, x2: Box, x3: Box) {