Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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`

0 commit comments

Comments
 (0)