Skip to content

Commit 563db42

Browse files
committed
Do not mention associated items when they introduce an obligation
1 parent 446b466 commit 563db42

File tree

102 files changed

+9
-1028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+9
-1028
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,15 +1958,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19581958
region, object_ty,
19591959
));
19601960
}
1961-
ObligationCauseCode::ItemObligation(item_def_id) => {
1962-
let item_name = tcx.def_path_str(item_def_id);
1963-
let msg = format!("required by `{}`", item_name);
1964-
let sp = tcx
1965-
.hir()
1966-
.span_if_local(item_def_id)
1967-
.unwrap_or_else(|| tcx.def_span(item_def_id));
1968-
let sp = tcx.sess.source_map().guess_head_span(sp);
1969-
err.span_note(sp, &msg);
1961+
ObligationCauseCode::ItemObligation(_item_def_id) => {
1962+
// We hold the `DefId` of the item introducing the obligation, but displaying it
1963+
// doesn't add user usable information. It always point at an associated item.
19701964
}
19711965
ObligationCauseCode::BindingObligation(item_def_id, span) => {
19721966
let item_name = tcx.def_path_str(item_def_id);

compiler/rustc_typeck/src/check/compare_method.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ fn compare_predicate_entailment<'tcx>(
232232
span,
233233
impl_m_hir_id,
234234
ObligationCauseCode::CompareImplMethodObligation {
235-
item_name: impl_m.ident.name,
236235
impl_item_def_id: impl_m.def_id,
237236
trait_item_def_id: trait_m.def_id,
238237
},

src/test/ui/allocator/not-an-allocator.stderr

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ LL | #[global_allocator]
66
LL | static A: usize = 0;
77
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
88
|
9-
note: required by `std::alloc::GlobalAlloc::alloc`
10-
--> $SRC_DIR/core/src/alloc/global.rs:LL:COL
11-
|
12-
LL | unsafe fn alloc(&self, layout: Layout) -> *mut u8;
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
1510

1611
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
@@ -21,11 +16,6 @@ LL | #[global_allocator]
2116
LL | static A: usize = 0;
2217
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
2318
|
24-
note: required by `std::alloc::GlobalAlloc::dealloc`
25-
--> $SRC_DIR/core/src/alloc/global.rs:LL:COL
26-
|
27-
LL | unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout);
28-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2919
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
3020

3121
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
@@ -36,11 +26,6 @@ LL | #[global_allocator]
3626
LL | static A: usize = 0;
3727
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
3828
|
39-
note: required by `std::alloc::GlobalAlloc::realloc`
40-
--> $SRC_DIR/core/src/alloc/global.rs:LL:COL
41-
|
42-
LL | unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4429
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
4530

4631
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
@@ -51,11 +36,6 @@ LL | #[global_allocator]
5136
LL | static A: usize = 0;
5237
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
5338
|
54-
note: required by `std::alloc::GlobalAlloc::alloc_zeroed`
55-
--> $SRC_DIR/core/src/alloc/global.rs:LL:COL
56-
|
57-
LL | unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
58-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5939
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
6040

6141
error: aborting due to 4 previous errors

src/test/ui/associated-consts/associated-const-array-len.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied
33
|
44
LL | const X: [i32; <i32 as Foo>::ID] = [0, 1, 2];
55
| ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32`
6-
|
7-
note: required by `Foo::ID`
8-
--> $DIR/associated-const-array-len.rs:2:5
9-
|
10-
LL | const ID: usize;
11-
| ^^^^^^^^^^^^^^^^
126

137
error: aborting due to previous error
148

src/test/ui/associated-consts/issue-63496.stderr

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
99
|
1010
= note: cannot satisfy `_: A`
1111
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
12-
note: required by `A::C`
13-
--> $DIR/issue-63496.rs:2:5
14-
|
15-
LL | const C: usize;
16-
| ^^^^^^^^^^^^^^^
1712

1813
error[E0283]: type annotations needed
1914
--> $DIR/issue-63496.rs:4:33
@@ -26,11 +21,6 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
2621
|
2722
= note: cannot satisfy `_: A`
2823
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
29-
note: required by `A::C`
30-
--> $DIR/issue-63496.rs:2:5
31-
|
32-
LL | const C: usize;
33-
| ^^^^^^^^^^^^^^^
3424

3525
error: aborting due to 2 previous errors
3626

src/test/ui/associated-item/issue-48027.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ LL | fn return_n(&self) -> [u8; Bar::X];
99
|
1010
= note: cannot satisfy `_: Bar`
1111
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
12-
note: required by `Bar::X`
13-
--> $DIR/issue-48027.rs:2:5
14-
|
15-
LL | const X: usize;
16-
| ^^^^^^^^^^^^^^^
1712

1813
error[E0038]: the trait `Bar` cannot be made into an object
1914
--> $DIR/issue-48027.rs:6:6

src/test/ui/associated-types/associated-types-bound-failure.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ LL | ToInt::to_int(&g.get())
66
| |
77
| required by a bound introduced by this call
88
|
9-
note: required by `ToInt::to_int`
10-
--> $DIR/associated-types-bound-failure.rs:6:5
11-
|
12-
LL | fn to_int(&self) -> isize;
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
149
help: consider further restricting the associated type
1510
|
1611
LL | where G : GetToInt, <G as GetToInt>::R: ToInt

src/test/ui/associated-types/associated-types-unconstrained.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ LL | let x: isize = Foo::bar();
55
| ^^^^^^^^ cannot infer type
66
|
77
= note: cannot satisfy `_: Foo`
8-
note: required by `Foo::bar`
9-
--> $DIR/associated-types-unconstrained.rs:5:5
10-
|
11-
LL | fn bar() -> isize;
12-
| ^^^^^^^^^^^^^^^^^^
138

149
error: aborting due to previous error
1510

src/test/ui/associated-types/issue-44153.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ note: required because of the requirements on the impl of `Visit` for `()`
99
|
1010
LL | impl<'a> Visit for () where
1111
| ^^^^^ ^^
12-
note: required by `Visit::visit`
13-
--> $DIR/issue-44153.rs:6:5
14-
|
15-
LL | fn visit() {}
16-
| ^^^^^^^^^^
1712

1813
error: aborting due to previous error
1914

src/test/ui/async-await/issue-61076.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ async fn bar() -> Result<(), ()> {
4242
foo()?; //~ ERROR the `?` operator can only be applied to values that implement `Try`
4343
//~^ NOTE the `?` operator cannot be applied to type `impl Future<Output = Result<(), ()>>`
4444
//~| HELP the trait `Try` is not implemented for `impl Future<Output = Result<(), ()>>`
45-
//~| NOTE required by `branch`
4645
//~| HELP consider `await`ing on the `Future`
4746
//~| NOTE in this expansion of desugaring of operator `?`
4847
//~| NOTE in this expansion of desugaring of operator `?`
4948
//~| NOTE in this expansion of desugaring of operator `?`
50-
//~| NOTE in this expansion of desugaring of operator `?`
5149
Ok(())
5250
}
5351

@@ -67,12 +65,10 @@ async fn baz() -> Result<(), ()> {
6765
t?; //~ ERROR the `?` operator can only be applied to values that implement `Try`
6866
//~^ NOTE the `?` operator cannot be applied to type `T`
6967
//~| HELP the trait `Try` is not implemented for `T`
70-
//~| NOTE required by `branch`
7168
//~| HELP consider `await`ing on the `Future`
7269
//~| NOTE in this expansion of desugaring of operator `?`
7370
//~| NOTE in this expansion of desugaring of operator `?`
7471
//~| NOTE in this expansion of desugaring of operator `?`
75-
//~| NOTE in this expansion of desugaring of operator `?`
7672

7773

7874
let _: i32 = tuple().0; //~ ERROR no field `0`

src/test/ui/async-await/issue-61076.stderr

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,25 @@ LL | foo()?;
55
| ^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = Result<(), ()>>`
66
|
77
= help: the trait `Try` is not implemented for `impl Future<Output = Result<(), ()>>`
8-
note: required by `branch`
9-
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
10-
|
11-
LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
12-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138
help: consider `await`ing on the `Future`
149
|
1510
LL | foo().await?;
1611
| ++++++
1712

1813
error[E0277]: the `?` operator can only be applied to values that implement `Try`
19-
--> $DIR/issue-61076.rs:67:5
14+
--> $DIR/issue-61076.rs:65:5
2015
|
2116
LL | t?;
2217
| ^^ the `?` operator cannot be applied to type `T`
2318
|
2419
= help: the trait `Try` is not implemented for `T`
25-
note: required by `branch`
26-
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
27-
|
28-
LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3020
help: consider `await`ing on the `Future`
3121
|
3222
LL | t.await?;
3323
| ++++++
3424

3525
error[E0609]: no field `0` on type `impl Future<Output = Tuple>`
36-
--> $DIR/issue-61076.rs:78:26
26+
--> $DIR/issue-61076.rs:74:26
3727
|
3828
LL | let _: i32 = tuple().0;
3929
| ^ field not available in `impl Future`, but it is available in its `Output`
@@ -44,7 +34,7 @@ LL | let _: i32 = tuple().await.0;
4434
| ++++++
4535

4636
error[E0609]: no field `a` on type `impl Future<Output = Struct>`
47-
--> $DIR/issue-61076.rs:82:28
37+
--> $DIR/issue-61076.rs:78:28
4838
|
4939
LL | let _: i32 = struct_().a;
5040
| ^ field not available in `impl Future`, but it is available in its `Output`
@@ -55,7 +45,7 @@ LL | let _: i32 = struct_().await.a;
5545
| ++++++
5646

5747
error[E0599]: no method named `method` found for opaque type `impl Future<Output = Struct>` in the current scope
58-
--> $DIR/issue-61076.rs:86:15
48+
--> $DIR/issue-61076.rs:82:15
5949
|
6050
LL | struct_().method();
6151
| ^^^^^^ method not found in `impl Future<Output = Struct>`
@@ -66,13 +56,13 @@ LL | struct_().await.method();
6656
| ++++++
6757

6858
error[E0308]: mismatched types
69-
--> $DIR/issue-61076.rs:94:9
59+
--> $DIR/issue-61076.rs:90:9
7060
|
7161
LL | Tuple(_) => {}
7262
| ^^^^^^^^ expected opaque type, found struct `Tuple`
7363
|
7464
note: while checking the return type of the `async fn`
75-
--> $DIR/issue-61076.rs:58:21
65+
--> $DIR/issue-61076.rs:56:21
7666
|
7767
LL | async fn tuple() -> Tuple {
7868
| ^^^^^ checked the `Output` of this `async fn`, expected opaque type

src/test/ui/async-await/issue-70594.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ LL | [1; ().await];
2525
| ^^^^^^^^ `()` is not a future
2626
|
2727
= help: the trait `Future` is not implemented for `()`
28-
note: required by `poll`
29-
--> $SRC_DIR/core/src/future/future.rs:LL:COL
30-
|
31-
LL | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
32-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3328

3429
error: aborting due to 4 previous errors
3530

src/test/ui/async-await/issue-84841.stderr

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ LL | test()?;
55
| ^^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = ()>`
66
|
77
= help: the trait `Try` is not implemented for `impl Future<Output = ()>`
8-
note: required by `branch`
9-
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
10-
|
11-
LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
12-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138

149
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`)
1510
--> $DIR/issue-84841.rs:9:11
@@ -25,11 +20,6 @@ LL | | }
2520
| |_- this function should return `Result` or `Option` to accept `?`
2621
|
2722
= help: the trait `FromResidual<_>` is not implemented for `()`
28-
note: required by `from_residual`
29-
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
30-
|
31-
LL | fn from_residual(residual: R) -> Self;
32-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3323

3424
error: aborting due to 2 previous errors
3525

src/test/ui/async-await/issues/issue-62009-1.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ LL | (|_| 2333).await;
3434
| ^^^^^^^^^^^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
3535
|
3636
= help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
37-
note: required by `poll`
38-
--> $SRC_DIR/core/src/future/future.rs:LL:COL
39-
|
40-
LL | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4237

4338
error: aborting due to 4 previous errors
4439

src/test/ui/async-await/try-on-option-in-async.stderr

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ LL | | }
1111
| |_____- this function should return `Result` or `Option` to accept `?`
1212
|
1313
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
14-
note: required by `from_residual`
15-
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
16-
|
17-
LL | fn from_residual(residual: R) -> Self;
18-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1914

2015
error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
2116
--> $DIR/try-on-option-in-async.rs:17:10
@@ -30,11 +25,6 @@ LL | | };
3025
| |_____- this function should return `Result` or `Option` to accept `?`
3126
|
3227
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
33-
note: required by `from_residual`
34-
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
35-
|
36-
LL | fn from_residual(residual: R) -> Self;
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3828

3929
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`)
4030
--> $DIR/try-on-option-in-async.rs:26:6
@@ -49,11 +39,6 @@ LL | | }
4939
| |_- this function should return `Result` or `Option` to accept `?`
5040
|
5141
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
52-
note: required by `from_residual`
53-
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
54-
|
55-
LL | fn from_residual(residual: R) -> Self;
56-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5742

5843
error: aborting due to 3 previous errors
5944

src/test/ui/const-generics/defaults/wfness.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
1212
|
1313
= help: the following implementations were found:
1414
<() as Trait<3_u8>>
15-
note: required by `WhereClause`
16-
--> $DIR/wfness.rs:8:1
17-
|
18-
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2015

2116
error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied
2217
--> $DIR/wfness.rs:16:13

src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ error[E0277]: the trait bound `[Adt; _]: Foo` is not satisfied
33
|
44
LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar()
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; _]`
6-
|
7-
note: required by `Foo::bar`
8-
--> $DIR/dont-evaluate-array-len-on-err-1.rs:19:5
9-
|
10-
LL | fn bar() {}
11-
| ^^^^^^^^
126

137
error: aborting due to previous error
148

src/test/ui/const-generics/exhaustive-value.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ LL | <() as Foo<N>>::test()
1010
<() as Foo<101_u8>>
1111
<() as Foo<102_u8>>
1212
and 252 others
13-
note: required by `Foo::test`
14-
--> $DIR/exhaustive-value.rs:2:5
15-
|
16-
LL | fn test() {}
17-
| ^^^^^^^^^
1813

1914
error: aborting due to previous error
2015

src/test/ui/derives/derives-span-Clone-enum-struct-variant.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ LL | #[derive(Clone)]
77
LL | x: Error
88
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
99
|
10-
note: required by `clone`
11-
--> $SRC_DIR/core/src/clone.rs:LL:COL
12-
|
13-
LL | fn clone(&self) -> Self;
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^
1510
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
1611

1712
error: aborting due to previous error

0 commit comments

Comments
 (0)