Skip to content

Commit d10dfdb

Browse files
authored
Rollup merge of rust-lang#35985 - 0xmohit:pr/error-code-E0277, r=jonathandturner
Update E0277 to new error format Fixes rust-lang#35311. Part of rust-lang#35233. r? @jonathandturner
2 parents b0c686a + 874a20d commit d10dfdb

11 files changed

+34
-4
lines changed

src/librustc/traits/error_reporting.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
477477
return;
478478
}
479479

480-
let mut err = struct_span_err!(
481-
self.tcx.sess, span, E0277,
480+
let mut err = struct_span_err!(self.tcx.sess, span, E0277,
482481
"the trait bound `{}` is not satisfied",
483482
trait_ref.to_predicate());
483+
err.span_label(span, &format!("trait `{}` not satisfied",
484+
trait_ref.to_predicate()));
484485

485486
// Try to report a help message
486487

src/test/compile-fail/E0277.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ fn some_func<T: Foo>(foo: T) {
1717
}
1818

1919
fn main() {
20-
some_func(5i32); //~ ERROR E0277
20+
some_func(5i32);
21+
//~^ ERROR the trait bound `i32: Foo` is not satisfied
22+
//~| NOTE trait `i32: Foo` not satisfied
23+
//~| NOTE required by `some_func`
2124
}

src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ trait Add<RHS=Self> {
3131
fn ice<A>(a: A) {
3232
let r = loop {};
3333
r = r + a;
34-
//~^ ERROR E0277
34+
//~^ ERROR the trait bound `(): Add<A>` is not satisfied
35+
//~| NOTE trait `(): Add<A>` not satisfied
3536
}

src/test/compile-fail/cast-rfc0401.rs

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ fn main()
9292
let _ = v as *const [u8]; //~ ERROR cannot cast
9393
let _ = fat_v as *const Foo;
9494
//~^ ERROR the trait bound `[u8]: std::marker::Sized` is not satisfied
95+
//~| NOTE trait `[u8]: std::marker::Sized` not satisfied
9596
//~| NOTE `[u8]` does not have a constant size known at compile-time
9697
//~| NOTE required for the cast to the object type `Foo`
9798
let _ = foo as *const str; //~ ERROR casting
@@ -106,6 +107,7 @@ fn main()
106107
let a : *const str = "hello";
107108
let _ = a as *const Foo;
108109
//~^ ERROR the trait bound `str: std::marker::Sized` is not satisfied
110+
//~| NOTE trait `str: std::marker::Sized` not satisfied
109111
//~| NOTE `str` does not have a constant size known at compile-time
110112
//~| NOTE required for the cast to the object type `Foo`
111113

src/test/compile-fail/const-unsized.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@ use std::fmt::Debug;
1212

1313
const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync));
1414
//~^ ERROR `std::fmt::Debug + Sync + 'static: std::marker::Sized` is not satisfied
15+
//~| NOTE `std::fmt::Debug + Sync + 'static: std::marker::Sized` not satisfied
1516
//~| NOTE does not have a constant size known at compile-time
1617
//~| NOTE constant expressions must have a statically known size
1718

1819
const CONST_FOO: str = *"foo";
1920
//~^ ERROR `str: std::marker::Sized` is not satisfied
21+
//~| NOTE `str: std::marker::Sized` not satisfied
2022
//~| NOTE does not have a constant size known at compile-time
2123
//~| NOTE constant expressions must have a statically known size
2224

2325
static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync));
2426
//~^ ERROR `std::fmt::Debug + Sync + 'static: std::marker::Sized` is not satisfied
27+
//~| NOTE `std::fmt::Debug + Sync + 'static: std::marker::Sized` not satisfied
2528
//~| NOTE does not have a constant size known at compile-time
2629
//~| NOTE constant expressions must have a statically known size
2730

2831
static STATIC_BAR: str = *"bar";
2932
//~^ ERROR `str: std::marker::Sized` is not satisfied
33+
//~| NOTE `str: std::marker::Sized` not satisfied
3034
//~| NOTE does not have a constant size known at compile-time
3135
//~| NOTE constant expressions must have a statically known size
3236

src/test/compile-fail/impl-trait/auto-trait-leak.rs

+4
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ fn send<T: Send>(_: T) {}
2626
fn main() {
2727
send(before());
2828
//~^ ERROR the trait bound `std::rc::Rc<std::cell::Cell<i32>>: std::marker::Send` is not satisfied
29+
//~| NOTE trait `std::rc::Rc<std::cell::Cell<i32>>: std::marker::Send` not satisfied
2930
//~| NOTE `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads safely
3031
//~| NOTE required because it appears within the type `[closure
3132
//~| NOTE required because it appears within the type `impl std::ops::Fn<(i32,)>`
3233
//~| NOTE required by `send`
3334

3435
send(after());
3536
//~^ ERROR the trait bound `std::rc::Rc<std::cell::Cell<i32>>: std::marker::Send` is not satisfied
37+
//~| NOTE trait `std::rc::Rc<std::cell::Cell<i32>>: std::marker::Send` not satisfied
3638
//~| NOTE `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads safely
3739
//~| NOTE required because it appears within the type `[closure
3840
//~| NOTE required because it appears within the type `impl std::ops::Fn<(i32,)>`
@@ -52,6 +54,7 @@ fn after() -> impl Fn(i32) {
5254
fn cycle1() -> impl Clone {
5355
send(cycle2().clone());
5456
//~^ ERROR the trait bound `std::rc::Rc<std::string::String>: std::marker::Send` is not satisfied
57+
//~| NOTE trait `std::rc::Rc<std::string::String>: std::marker::Send` not satisfied
5558
//~| NOTE `std::rc::Rc<std::string::String>` cannot be sent between threads safely
5659
//~| NOTE required because it appears within the type `impl std::clone::Clone`
5760
//~| NOTE required by `send`
@@ -62,6 +65,7 @@ fn cycle1() -> impl Clone {
6265
fn cycle2() -> impl Clone {
6366
send(cycle1().clone());
6467
//~^ ERROR the trait bound `std::rc::Rc<std::cell::Cell<i32>>: std::marker::Send` is not satisfied
68+
//~| NOTE trait `std::rc::Rc<std::cell::Cell<i32>>: std::marker::Send` not satisfied
6569
//~| NOTE `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads safely
6670
//~| NOTE required because it appears within the type `impl std::clone::Clone`
6771
//~| NOTE required by `send`

src/test/compile-fail/on-unimplemented/multiple-impls.rs

+3
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ impl Index<Bar<usize>> for [i32] {
4242
fn main() {
4343
Index::index(&[] as &[i32], 2u32);
4444
//~^ ERROR E0277
45+
//~| NOTE not satisfied
4546
//~| NOTE trait message
4647
//~| NOTE required by
4748
Index::index(&[] as &[i32], Foo(2u32));
4849
//~^ ERROR E0277
50+
//~| NOTE not satisfied
4951
//~| NOTE on impl for Foo
5052
//~| NOTE required by
5153
Index::index(&[] as &[i32], Bar(2u32));
5254
//~^ ERROR E0277
55+
//~| NOTE not satisfied
5356
//~| NOTE on impl for Bar
5457
//~| NOTE required by
5558
}

src/test/compile-fail/on-unimplemented/on-impl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl Index<usize> for [i32] {
3030
#[rustc_error]
3131
fn main() {
3232
Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32); //~ ERROR E0277
33+
//~| NOTE not satisfied
3334
//~| NOTE a usize is required
3435
//~| NOTE required by
3536
}

src/test/compile-fail/on-unimplemented/on-trait.rs

+2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ pub fn main() {
3535
//~^ ERROR
3636
//~^^ NOTE a collection of type `std::option::Option<std::vec::Vec<u8>>` cannot be built from an iterator over elements of type `&u8`
3737
//~^^^ NOTE required by `collect`
38+
//~| NOTE trait `std::option::Option<std::vec::Vec<u8>>: MyFromIterator<&u8>` not satisfied
3839
let x: String = foobar(); //~ ERROR
3940
//~^ NOTE test error `std::string::String` with `u8` `_` `u32`
4041
//~^^ NOTE required by `foobar`
42+
//~| NOTE trait `std::string::String: Foo<u8, _, u32>` not satisfied
4143
}

src/test/compile-fail/on-unimplemented/slice-index.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use std::ops::Index;
1818
fn main() {
1919
let x = &[1, 2, 3] as &[i32];
2020
x[1i32]; //~ ERROR E0277
21+
//~| NOTE trait `[i32]: std::ops::Index<i32>` not satisfied
2122
//~| NOTE slice indices are of type `usize`
2223
x[..1i32]; //~ ERROR E0277
24+
//~| NOTE trait `[i32]: std::ops::Index<std::ops::RangeTo<i32>>` not satisfied
2325
//~| NOTE slice indices are of type `usize`
2426
}

src/test/compile-fail/trait-suggest-where-clause.rs

+7
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ fn check<T: Iterator, U: ?Sized>() {
1616
// suggest a where-clause, if needed
1717
mem::size_of::<U>();
1818
//~^ ERROR `U: std::marker::Sized` is not satisfied
19+
//~| NOTE trait `U: std::marker::Sized` not satisfied
1920
//~| HELP consider adding a `where U: std::marker::Sized` bound
2021
//~| NOTE required by `std::mem::size_of`
2122

2223
mem::size_of::<Misc<U>>();
2324
//~^ ERROR `U: std::marker::Sized` is not satisfied
25+
//~| NOTE trait `U: std::marker::Sized` not satisfied
2426
//~| HELP consider adding a `where U: std::marker::Sized` bound
2527
//~| NOTE required because it appears within the type `Misc<U>`
2628
//~| NOTE required by `std::mem::size_of`
@@ -29,29 +31,34 @@ fn check<T: Iterator, U: ?Sized>() {
2931

3032
<u64 as From<T>>::from;
3133
//~^ ERROR `u64: std::convert::From<T>` is not satisfied
34+
//~| NOTE trait `u64: std::convert::From<T>` not satisfied
3235
//~| HELP consider adding a `where u64: std::convert::From<T>` bound
3336
//~| NOTE required by `std::convert::From::from`
3437

3538
<u64 as From<<T as Iterator>::Item>>::from;
3639
//~^ ERROR `u64: std::convert::From<<T as std::iter::Iterator>::Item>` is not satisfied
40+
//~| NOTE trait `u64: std::convert::From<<T as std::iter::Iterator>::Item>` not satisfied
3741
//~| HELP consider adding a `where u64:
3842
//~| NOTE required by `std::convert::From::from`
3943

4044
// ... but not if there are inference variables
4145

4246
<Misc<_> as From<T>>::from;
4347
//~^ ERROR `Misc<_>: std::convert::From<T>` is not satisfied
48+
//~| NOTE trait `Misc<_>: std::convert::From<T>` not satisfied
4449
//~| NOTE required by `std::convert::From::from`
4550

4651
// ... and also not if the error is not related to the type
4752

4853
mem::size_of::<[T]>();
4954
//~^ ERROR `[T]: std::marker::Sized` is not satisfied
55+
//~| NOTE `[T]: std::marker::Sized` not satisfied
5056
//~| NOTE `[T]` does not have a constant size
5157
//~| NOTE required by `std::mem::size_of`
5258

5359
mem::size_of::<[&U]>();
5460
//~^ ERROR `[&U]: std::marker::Sized` is not satisfied
61+
//~| NOTE `[&U]: std::marker::Sized` not satisfied
5562
//~| NOTE `[&U]` does not have a constant size
5663
//~| NOTE required by `std::mem::size_of`
5764
}

0 commit comments

Comments
 (0)