From 9b36030a65351892a3aa3ddc20ea53d4a6c589c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 15 Jan 2018 14:26:36 -0800 Subject: [PATCH] On E0283, point at method with the requirements On required type annotation diagnostic error, point at method with the requirements if the span is available. --- src/librustc/traits/error_reporting.rs | 8 ++- .../anonymous-higher-ranked-lifetime.stderr | 66 +++++++++++++++---- .../issue-39802-show-5-trait-impls.stderr | 18 ++++- .../ui/did_you_mean/recursion_limit.stderr | 6 +- src/test/ui/fmt/send-sync.stderr | 12 +++- src/test/ui/generator/not-send-sync.stderr | 12 +++- src/test/ui/impl-trait/auto-trait-leak.stderr | 12 +++- src/test/ui/issue-24424.stderr | 6 +- src/test/ui/mismatched_types/E0631.stderr | 24 +++++-- .../mismatched_types/closure-arg-count.stderr | 6 +- .../closure-arg-type-mismatch.stderr | 12 +++- .../mismatched_types/closure-mismatch.stderr | 12 +++- .../ui/mismatched_types/fn-variance-1.stderr | 12 +++- .../unboxed-closures-vtable-mismatch.rs | 4 +- .../unboxed-closures-vtable-mismatch.stderr | 13 ++-- .../ui/on-unimplemented/multiple-impls.stderr | 18 ++++- src/test/ui/on-unimplemented/on-impl.stderr | 6 +- src/test/ui/on-unimplemented/on-trait.stderr | 12 +++- src/test/ui/span/issue-29595.stderr | 6 +- .../suggestions/try-operator-on-main.stderr | 6 +- src/test/ui/type-annotation-needed.rs | 17 +++++ src/test/ui/type-annotation-needed.stderr | 14 ++++ src/test/ui/type-check/issue-40294.stderr | 6 +- 23 files changed, 260 insertions(+), 48 deletions(-) create mode 100644 src/test/ui/type-annotation-needed.rs create mode 100644 src/test/ui/type-annotation-needed.stderr diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 54da23821f5d8..1aca687af2bf3 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1241,7 +1241,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } ObligationCauseCode::ItemObligation(item_def_id) => { let item_name = tcx.item_path_str(item_def_id); - err.note(&format!("required by `{}`", item_name)); + let msg = format!("required by `{}`", item_name); + if let Some(sp) = tcx.hir.span_if_local(item_def_id) { + let sp = tcx.sess.codemap().def_span(sp); + err.span_note(sp, &msg); + } else { + err.note(&msg); + } } ObligationCauseCode::ObjectCastObligation(object_ty) => { err.note(&format!("required for the cast to the object type `{}`", diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index e364a4d8b1441..4bd3b684b7ba3 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -6,7 +6,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _` | - = note: required by `f1` +note: required by `f1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:26:1 + | +26 | fn f1(_: F) where F: Fn(&(), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:13:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _` | - = note: required by `f2` +note: required by `f2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:27:1 + | +27 | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -26,7 +34,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&(), &'r ()) -> _` | - = note: required by `f3` +note: required by `f3` + --> $DIR/anonymous-higher-ranked-lifetime.rs:28:1 + | +28 | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:15:5 @@ -36,7 +48,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _` | - = note: required by `f4` +note: required by `f4` + --> $DIR/anonymous-higher-ranked-lifetime.rs:29:1 + | +29 | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -46,7 +62,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), &'r ()) -> _` | - = note: required by `f5` +note: required by `f5` + --> $DIR/anonymous-higher-ranked-lifetime.rs:30:1 + | +30 | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:17:5 @@ -56,7 +76,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>) -> _` | - = note: required by `g1` +note: required by `g1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:33:1 + | +33 | fn g1(_: F) where F: Fn(&(), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -66,7 +90,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _` | - = note: required by `g2` +note: required by `g2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 + | +34 | fn g2(_: F) where F: Fn(&(), fn(&())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:19:5 @@ -76,7 +104,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), std::boxed::Box std::ops::Fn(&'r ()) + 'static>) -> _` | - = note: required by `g3` +note: required by `g3` + --> $DIR/anonymous-higher-ranked-lifetime.rs:35:1 + | +35 | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -86,7 +118,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` | - = note: required by `g4` +note: required by `g4` + --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 + | +36 | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:21:5 @@ -96,7 +132,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box std::ops::Fn(&'t0 ()) + 'static>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _` | - = note: required by `h1` +note: required by `h1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:39:1 + | +39 | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -106,7 +146,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _` | - = note: required by `h2` +note: required by `h2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 + | +40 | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 11 previous errors diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index d5c4add34b526..7ca3e8728fd9c 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -10,7 +10,11 @@ error[E0277]: the trait bound `i8: Foo` is not satisfied > > > - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:35:5 @@ -23,7 +27,11 @@ error[E0277]: the trait bound `u8: Foo` is not satisfied > > > - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:36:5 @@ -37,7 +45,11 @@ error[E0277]: the trait bound `bool: Foo` is not satisfied > > and 2 others - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index 7fac604ba49d7..2bc7e9e46e7c5 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -15,7 +15,11 @@ error[E0275]: overflow evaluating the requirement `K: std::marker::Send` = note: required because it appears within the type `C` = note: required because it appears within the type `B` = note: required because it appears within the type `A` - = note: required by `is_send` +note: required by `is_send` + --> $DIR/recursion_limit.rs:41:1 + | +41 | fn is_send() { } + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/fmt/send-sync.stderr b/src/test/ui/fmt/send-sync.stderr index 9e0e563c35f65..4ec5c9ebd2712 100644 --- a/src/test/ui/fmt/send-sync.stderr +++ b/src/test/ui/fmt/send-sync.stderr @@ -12,7 +12,11 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because of the requirements on the impl of `std::marker::Send` for `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` - = note: required by `send` +note: required by `send` + --> $DIR/send-sync.rs:11:1 + | +11 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` is not satisfied in `std::fmt::Arguments<'_>` --> $DIR/send-sync.rs:19:5 @@ -28,7 +32,11 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` - = note: required by `sync` +note: required by `sync` + --> $DIR/send-sync.rs:12:1 + | +12 | fn sync(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr index a1f110accc100..d30255335a660 100644 --- a/src/test/ui/generator/not-send-sync.stderr +++ b/src/test/ui/generator/not-send-sync.stderr @@ -7,7 +7,11 @@ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not s = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::cell::Cell` = note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:26:17: 30:6 a:&std::cell::Cell _]` - = note: required by `main::assert_send` +note: required by `main::assert_send` + --> $DIR/not-send-sync.rs:17:5 + | +17 | fn assert_send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not satisfied in `[generator@$DIR/not-send-sync.rs:19:17: 23:6 (std::cell::Cell, ())]` --> $DIR/not-send-sync.rs:19:5 @@ -18,7 +22,11 @@ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not s = help: within `[generator@$DIR/not-send-sync.rs:19:17: 23:6 (std::cell::Cell, ())]`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell` = note: required because it appears within the type `(std::cell::Cell, ())` = note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:19:17: 23:6 (std::cell::Cell, ())]` - = note: required by `main::assert_sync` +note: required by `main::assert_sync` + --> $DIR/not-send-sync.rs:16:5 + | +16 | fn assert_sync(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index ffd6a3fe4ffb1..838a3002e3aa7 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -7,7 +7,11 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:21:5: 21:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` - = note: required by `send` +note: required by `send` + --> $DIR/auto-trait-leak.rs:24:1 + | +24 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied in `impl std::ops::Fn<(i32,)>` --> $DIR/auto-trait-leak.rs:30:5 @@ -18,7 +22,11 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:38:5: 38:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` - = note: required by `send` +note: required by `send` + --> $DIR/auto-trait-leak.rs:24:1 + | +24 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0391]: unsupported cyclic reference between types/traits detected --> $DIR/auto-trait-leak.rs:44:1 diff --git a/src/test/ui/issue-24424.stderr b/src/test/ui/issue-24424.stderr index acdf348791b20..55af26dd91ea3 100644 --- a/src/test/ui/issue-24424.stderr +++ b/src/test/ui/issue-24424.stderr @@ -4,7 +4,11 @@ error[E0283]: type annotations required: cannot resolve `T0: Trait0<'l0>` 14 | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: required by `Trait0` +note: required by `Trait0` + --> $DIR/issue-24424.rs:12:1 + | +12 | trait Trait0<'l0> {} + | ^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 442900e0a836a..53f2f54325d57 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -6,7 +6,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | - = note: required by `foo` +note: required by `foo` + --> $DIR/E0631.rs:13:1 + | +13 | fn foo(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:18:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | - = note: required by `bar` +note: required by `bar` + --> $DIR/E0631.rs:14:1 + | +14 | fn bar>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:19:5 @@ -27,7 +35,11 @@ error[E0631]: type mismatch in function arguments 19 | foo(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | - = note: required by `foo` +note: required by `foo` + --> $DIR/E0631.rs:13:1 + | +13 | fn foo(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:20:5 @@ -38,7 +50,11 @@ error[E0631]: type mismatch in function arguments 20 | bar(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | - = note: required by `bar` +note: required by `bar` + --> $DIR/E0631.rs:14:1 + | +14 | fn bar>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index 216f39bac5418..ba25d67d76ef2 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -30,7 +30,11 @@ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments | | | expected closure that takes 1 argument | - = note: required by `f` +note: required by `f` + --> $DIR/closure-arg-count.rs:13:1 + | +13 | fn f>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments --> $DIR/closure-arg-count.rs:24:53 diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index 77d3a33276737..dfd02fe23b686 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -31,7 +31,11 @@ error[E0631]: type mismatch in function arguments | expected signature of `for<'r> fn(*mut &'r u32) -> _` | found signature of `fn(*mut &'a u32) -> _` | - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-arg-type-mismatch.rs:18:1 + | +18 | fn baz(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `for<'r> >::Output == ()` --> $DIR/closure-arg-type-mismatch.rs:20:5 @@ -39,7 +43,11 @@ error[E0271]: type mismatch resolving `for<'r> $DIR/closure-arg-type-mismatch.rs:18:1 + | +18 | fn baz(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index 99767ba1afaef..01de7e0749500 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -5,7 +5,11 @@ error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.r | ^^^ expected bound lifetime parameter, found concrete lifetime | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-mismatch.rs:15:1 + | +15 | fn baz(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/closure-mismatch.rs:18:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | expected signature of `for<'r> fn(&'r ()) -> _` | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-mismatch.rs:15:1 + | +15 | fn baz(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 2a27ffd106247..64c260c30ed49 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -7,7 +7,11 @@ error[E0631]: type mismatch in function arguments 21 | apply(&3, takes_mut); | ^^^^^ expected signature of `fn(&{integer}) -> _` | - = note: required by `apply` +note: required by `apply` + --> $DIR/fn-variance-1.rs:15:1 + | +15 | fn apply(t: T, f: F) where F: FnOnce(T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/fn-variance-1.rs:25:5 @@ -18,7 +22,11 @@ error[E0631]: type mismatch in function arguments 25 | apply(&mut 3, takes_imm); | ^^^^^ expected signature of `fn(&mut {integer}) -> _` | - = note: required by `apply` +note: required by `apply` + --> $DIR/fn-variance-1.rs:15:1 + | +15 | fn apply(t: T, f: F) where F: FnOnce(T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs index 10f4b3229f0da..f2237e495a00c 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs @@ -15,13 +15,15 @@ use std::ops::FnMut; fn to_fn_mut>(f: F) -> F { f } fn call_itisize>(y: isize, mut f: F) -> isize { +//~^ NOTE required by `call_it` f(2, y) } pub fn main() { let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); + //~^ NOTE found signature of `fn(usize, isize) -> _` let z = call_it(3, f); //~^ ERROR type mismatch - //~| required by `call_it` + //~| NOTE expected signature of `fn(isize, isize) -> _` println!("{}", z); } diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 8539c8818c025..9c9bbd19c7552 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,12 +1,17 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:23:13 + --> $DIR/unboxed-closures-vtable-mismatch.rs:25:13 | -22 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); +23 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); | ----------------------------- found signature of `fn(usize, isize) -> _` -23 | let z = call_it(3, f); +24 | //~^ NOTE found signature of `fn(usize, isize) -> _` +25 | let z = call_it(3, f); | ^^^^^^^ expected signature of `fn(isize, isize) -> _` | - = note: required by `call_it` +note: required by `call_it` + --> $DIR/unboxed-closures-vtable-mismatch.rs:17:1 + | +17 | fn call_itisize>(y: isize, mut f: F) -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index 1f71be446efb5..cfac3981be284 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:43:5 @@ -22,7 +26,11 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:46:5 @@ -39,7 +47,11 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:49:5 diff --git a/src/test/ui/on-unimplemented/on-impl.stderr b/src/test/ui/on-unimplemented/on-impl.stderr index c8c06bf44fd6f..ed2da68f08167 100644 --- a/src/test/ui/on-unimplemented/on-impl.stderr +++ b/src/test/ui/on-unimplemented/on-impl.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice | = help: the trait `Index` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/on-impl.rs:19:5 + | +19 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/on-impl.rs:32:5 diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index cde56022faea2..028200a5558c8 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `std::option::Option>: MyFromIte | ^^^^^^^ a collection of type `std::option::Option>` cannot be built from an iterator over elements of type `&u8` | = help: the trait `MyFromIterator<&u8>` is not implemented for `std::option::Option>` - = note: required by `collect` +note: required by `collect` + --> $DIR/on-trait.rs:31:1 + | +31 | fn collect, B: MyFromIterator>(it: I) -> B { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not satisfied --> $DIR/on-trait.rs:40:21 @@ -14,7 +18,11 @@ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not | ^^^^^^ test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo` | = help: the trait `Bar::Foo` is not implemented for `std::string::String` - = note: required by `foobar` +note: required by `foobar` + --> $DIR/on-trait.rs:21:1 + | +21 | fn foobar>() -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-29595.stderr b/src/test/ui/span/issue-29595.stderr index 81ba0057d7173..9046b90f0e9c3 100644 --- a/src/test/ui/span/issue-29595.stderr +++ b/src/test/ui/span/issue-29595.stderr @@ -4,7 +4,11 @@ error[E0277]: the trait bound `u8: Tr` is not satisfied 17 | let a: u8 = Tr::C; //~ ERROR the trait bound `u8: Tr` is not satisfied | ^^^^^ the trait `Tr` is not implemented for `u8` | - = note: required by `Tr::C` +note: required by `Tr::C` + --> $DIR/issue-29595.rs:13:5 + | +13 | const C: Self; + | ^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr index beb627bda6bd1..3b32b4a9eb7ba 100644 --- a/src/test/ui/suggestions/try-operator-on-main.stderr +++ b/src/test/ui/suggestions/try-operator-on-main.stderr @@ -28,7 +28,11 @@ error[E0277]: the trait bound `(): std::ops::Try` is not satisfied 25 | try_trait_generic::<()>(); //~ ERROR the trait bound | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()` | - = note: required by `try_trait_generic` +note: required by `try_trait_generic` + --> $DIR/try-operator-on-main.rs:30:1 + | +30 | fn try_trait_generic() -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` --> $DIR/try-operator-on-main.rs:32:5 diff --git a/src/test/ui/type-annotation-needed.rs b/src/test/ui/type-annotation-needed.rs new file mode 100644 index 0000000000000..3ed6e5daf0061 --- /dev/null +++ b/src/test/ui/type-annotation-needed.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo>(x: i32) {} +//~^ NOTE required by + +fn main() { + foo(42); + //~^ ERROR type annotations required +} diff --git a/src/test/ui/type-annotation-needed.stderr b/src/test/ui/type-annotation-needed.stderr new file mode 100644 index 0000000000000..7d49afbaff8af --- /dev/null +++ b/src/test/ui/type-annotation-needed.stderr @@ -0,0 +1,14 @@ +error[E0283]: type annotations required: cannot resolve `_: std::convert::Into` + --> $DIR/type-annotation-needed.rs:15:5 + | +15 | foo(42); + | ^^^ + | +note: required by `foo` + --> $DIR/type-annotation-needed.rs:11:1 + | +11 | fn foo>(x: i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/type-check/issue-40294.stderr b/src/test/ui/type-check/issue-40294.stderr index 2ca97aa3ef067..cf270afdeb173 100644 --- a/src/test/ui/type-check/issue-40294.stderr +++ b/src/test/ui/type-check/issue-40294.stderr @@ -10,7 +10,11 @@ error[E0283]: type annotations required: cannot resolve `&'a T: Foo` 21 | | } | |_^ | - = note: required by `Foo` +note: required by `Foo` + --> $DIR/issue-40294.rs:11:1 + | +11 | trait Foo: Sized { + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error