Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5f6cfd2
mention `remove` in `swap_remove`
Nov 1, 2021
084b232
add const generics test
lcnr Nov 4, 2021
1642fdf
Add `-Zassert-incr-state` to assert state of incremental cache
pierwill Oct 31, 2021
ddc1d58
windows: Return the "Not Found" error when a path is empty
JohnTitor Nov 16, 2021
483cff7
Add SourceMap::indentation_before.
m-ou-se Nov 4, 2021
453e242
Improve suggestion for unit Option/Result at the end of a block.
m-ou-se Nov 4, 2021
b331b66
Improve compatible enum variant suggestions.
m-ou-se Nov 4, 2021
4877756
Update tests.
m-ou-se Nov 4, 2021
5a25751
Add new tests for compatible variant diagnostics.
m-ou-se Nov 4, 2021
09e4a75
Use span_suggestions instead of multipart_suggestions.
m-ou-se Nov 4, 2021
b66fb64
Update test output.
m-ou-se Nov 16, 2021
f5dc388
Point at source of trait bound obligations in more places
estebank Oct 5, 2021
3fe48b2
Change `trait_defs.rs` incremental hash test
estebank Oct 6, 2021
412793f
Point at bounds when comparing impl items to trait
estebank Oct 6, 2021
abf70a9
Do not mention associated items when they introduce an obligation
estebank Oct 12, 2021
a7261c3
Avoid suggesting literal formatting that turns into member access
notriddle Nov 17, 2021
a6b31eb
Align multiline messages to their label (add left margin)
estebank Oct 13, 2021
70e8240
Point at `impl` blocks when they introduce unmet obligations
estebank Oct 13, 2021
8d443ea
Suggest constraining `fn` type params when appropriate
estebank Oct 13, 2021
1cadfe6
Move tests for missing trait bounds to their own directory
estebank Oct 14, 2021
2c173af
review comments
estebank Nov 18, 2021
a8dcc87
Move tests from ui directory
estebank Nov 18, 2021
c5438c3
Rollup merge of #89580 - estebank:trait-bounds-are-tricky, r=nagisa
matthiaskrgr Nov 18, 2021
a4739f2
Rollup merge of #90386 - pierwill:assert-incr-state-85864, r=Aaron1011
matthiaskrgr Nov 18, 2021
38f2cfa
Rollup merge of #90480 - r00ster91:remove, r=kennytm
matthiaskrgr Nov 18, 2021
aa17eeb
Rollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=e…
matthiaskrgr Nov 18, 2021
63ee3b2
Rollup merge of #90578 - lcnr:add-test, r=Mark-Simulacrum
matthiaskrgr Nov 18, 2021
005be61
Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se
matthiaskrgr Nov 18, 2021
177058c
Rollup merge of #90989 - notriddle:notriddle/rustc-suggest-float-endi…
matthiaskrgr Nov 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Do not mention associated items when they introduce an obligation
  • Loading branch information
estebank committed Nov 17, 2021
commit abf70a921936b944f8883bcafbb0b88523c3a489
Original file line number Diff line number Diff line change
Expand Up @@ -1957,15 +1957,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
region, object_ty,
));
}
ObligationCauseCode::ItemObligation(item_def_id) => {
let item_name = tcx.def_path_str(item_def_id);
let msg = format!("required by `{}`", item_name);
let sp = tcx
.hir()
.span_if_local(item_def_id)
.unwrap_or_else(|| tcx.def_span(item_def_id));
let sp = tcx.sess.source_map().guess_head_span(sp);
err.span_note(sp, &msg);
ObligationCauseCode::ItemObligation(_item_def_id) => {
// We hold the `DefId` of the item introducing the obligation, but displaying it
// doesn't add user usable information. It always point at an associated item.
}
ObligationCauseCode::BindingObligation(item_def_id, span) => {
let item_name = tcx.def_path_str(item_def_id);
Expand Down
20 changes: 0 additions & 20 deletions src/test/ui/allocator/not-an-allocator.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ LL | #[global_allocator]
LL | static A: usize = 0;
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
note: required by `std::alloc::GlobalAlloc::alloc`
--> $SRC_DIR/core/src/alloc/global.rs:LL:COL
|
LL | unsafe fn alloc(&self, layout: Layout) -> *mut u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)

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

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

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

error: aborting due to 4 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied
|
LL | const X: [i32; <i32 as Foo>::ID] = [0, 1, 2];
| ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32`
|
note: required by `Foo::ID`
--> $DIR/associated-const-array-len.rs:2:5
|
LL | const ID: usize;
| ^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
10 changes: 0 additions & 10 deletions src/test/ui/associated-consts/issue-63496.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
|
= note: cannot satisfy `_: A`
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
note: required by `A::C`
--> $DIR/issue-63496.rs:2:5
|
LL | const C: usize;
| ^^^^^^^^^^^^^^^

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

error: aborting due to 2 previous errors

Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/associated-item/issue-48027.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ LL | fn return_n(&self) -> [u8; Bar::X];
|
= note: cannot satisfy `_: Bar`
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
note: required by `Bar::X`
--> $DIR/issue-48027.rs:2:5
|
LL | const X: usize;
| ^^^^^^^^^^^^^^^

error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-48027.rs:6:6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ LL | ToInt::to_int(&g.get())
| |
| required by a bound introduced by this call
|
note: required by `ToInt::to_int`
--> $DIR/associated-types-bound-failure.rs:6:5
|
LL | fn to_int(&self) -> isize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider further restricting the associated type
|
LL | where G : GetToInt, <G as GetToInt>::R: ToInt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ LL | let x: isize = Foo::bar();
| ^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Foo`
note: required by `Foo::bar`
--> $DIR/associated-types-unconstrained.rs:5:5
|
LL | fn bar() -> isize;
| ^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/associated-types/issue-44153.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ note: required because of the requirements on the impl of `Visit` for `()`
|
LL | impl<'a> Visit for () where
| ^^^^^ ^^
note: required by `Visit::visit`
--> $DIR/issue-44153.rs:6:5
|
LL | fn visit() {}
| ^^^^^^^^^^

error: aborting due to previous error

Expand Down
4 changes: 0 additions & 4 deletions src/test/ui/async-await/issue-61076.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ async fn bar() -> Result<(), ()> {
foo()?; //~ ERROR the `?` operator can only be applied to values that implement `Try`
//~^ NOTE the `?` operator cannot be applied to type `impl Future`
//~| HELP the trait `Try` is not implemented for `impl Future`
//~| NOTE required by `branch`
//~| HELP consider `await`ing on the `Future`
//~| NOTE in this expansion of desugaring of operator `?`
//~| NOTE in this expansion of desugaring of operator `?`
//~| NOTE in this expansion of desugaring of operator `?`
//~| NOTE in this expansion of desugaring of operator `?`
Ok(())
}

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


let _: i32 = tuple().0; //~ ERROR no field `0`
Expand Down
22 changes: 6 additions & 16 deletions src/test/ui/async-await/issue-61076.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,25 @@ LL | foo()?;
| ^^^^^^ the `?` operator cannot be applied to type `impl Future`
|
= help: the trait `Try` is not implemented for `impl Future`
note: required by `branch`
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
|
LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider `await`ing on the `Future`
|
LL | foo().await?;
| ++++++

error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> $DIR/issue-61076.rs:67:5
--> $DIR/issue-61076.rs:65:5
|
LL | t?;
| ^^ the `?` operator cannot be applied to type `T`
|
= help: the trait `Try` is not implemented for `T`
note: required by `branch`
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
|
LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider `await`ing on the `Future`
|
LL | t.await?;
| ++++++

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

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

error[E0599]: no method named `method` found for opaque type `impl Future` in the current scope
--> $DIR/issue-61076.rs:86:15
--> $DIR/issue-61076.rs:82:15
|
LL | struct_().method();
| ^^^^^^ method not found in `impl Future`
Expand All @@ -66,13 +56,13 @@ LL | struct_().await.method();
| ++++++

error[E0308]: mismatched types
--> $DIR/issue-61076.rs:94:9
--> $DIR/issue-61076.rs:90:9
|
LL | Tuple(_) => {}
| ^^^^^^^^ expected opaque type, found struct `Tuple`
|
note: while checking the return type of the `async fn`
--> $DIR/issue-61076.rs:58:21
--> $DIR/issue-61076.rs:56:21
|
LL | async fn tuple() -> Tuple {
| ^^^^^ checked the `Output` of this `async fn`, expected opaque type
Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/async-await/issue-70594.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ LL | [1; ().await];
| ^^^^^^^^ `()` is not a future
|
= help: the trait `Future` is not implemented for `()`
note: required by `poll`
--> $SRC_DIR/core/src/future/future.rs:LL:COL
|
LL | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors

Expand Down
10 changes: 0 additions & 10 deletions src/test/ui/async-await/issue-84841.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ LL | test()?;
| ^^^^^^^ the `?` operator cannot be applied to type `impl Future`
|
= help: the trait `Try` is not implemented for `impl Future`
note: required by `branch`
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
|
LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

error: aborting due to 2 previous errors

Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/async-await/issues/issue-62009-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ LL | (|_| 2333).await;
| ^^^^^^^^^^^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
= help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
note: required by `poll`
--> $SRC_DIR/core/src/future/future.rs:LL:COL
|
LL | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors

Expand Down
15 changes: 0 additions & 15 deletions src/test/ui/async-await/try-on-option-in-async.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ LL | | }
| |_____- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
note: required by `from_residual`
--> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
|
LL | fn from_residual(residual: R) -> Self;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

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

error: aborting due to 3 previous errors

Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/const-generics/defaults/wfness.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
= help: the following implementations were found:
<() as Trait<3_u8>>
note: required by `WhereClause`
--> $DIR/wfness.rs:8:1
|
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied
--> $DIR/wfness.rs:16:13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ error[E0277]: the trait bound `[Adt; _]: Foo` is not satisfied
|
LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; _]`
|
note: required by `Foo::bar`
--> $DIR/dont-evaluate-array-len-on-err-1.rs:19:5
|
LL | fn bar() {}
| ^^^^^^^^

error: aborting due to previous error

Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/const-generics/exhaustive-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ LL | <() as Foo<N>>::test()
<() as Foo<101_u8>>
<() as Foo<102_u8>>
and 252 others
note: required by `Foo::test`
--> $DIR/exhaustive-value.rs:2:5
|
LL | fn test() {}
| ^^^^^^^^^

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ LL | #[derive(Clone)]
LL | x: Error
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
|
note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL
|
LL | fn clone(&self) -> Self;
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/derives/derives-span-Clone-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ LL | #[derive(Clone)]
LL | Error
| ^^^^^ the trait `Clone` is not implemented for `Error`
|
note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL
|
LL | fn clone(&self) -> Self;
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
Expand Down
Loading