Skip to content

Note predicate span on ImplDerivedObligation #106703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use rustc_middle::ty::{
TypeSuperFoldable, TypeVisitable, TypeckResults,
};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{BytePos, DesugaringKind, ExpnKind, Span, DUMMY_SP};
use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span, DUMMY_SP};
use rustc_target::spec::abi;
use std::ops::Deref;

Expand Down Expand Up @@ -2949,7 +2949,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// FIXME: we should do something else so that it works even on crate foreign
// auto traits.
is_auto_trait = matches!(is_auto, hir::IsAuto::Yes);
err.span_note(ident.span, &msg)
err.span_note(ident.span, &msg);
}
Some(Node::Item(hir::Item {
kind: hir::ItemKind::Impl(hir::Impl { of_trait, self_ty, .. }),
Expand All @@ -2960,9 +2960,29 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
spans.push(trait_ref.path.span);
}
spans.push(self_ty.span);
err.span_note(spans, &msg)
let mut spans: MultiSpan = spans.into();
if matches!(
self_ty.span.ctxt().outer_expn_data().kind,
ExpnKind::Macro(MacroKind::Derive, _)
) || matches!(
of_trait.as_ref().map(|t| t.path.span.ctxt().outer_expn_data().kind),
Some(ExpnKind::Macro(MacroKind::Derive, _))
) {
spans.push_span_label(
data.span,
"unsatisfied trait bound introduced in this `derive` macro",
);
} else if !data.span.is_dummy() && !data.span.overlaps(self_ty.span) {
spans.push_span_label(
data.span,
"unsatisfied trait bound introduced here",
);
}
err.span_note(spans, &msg);
}
_ => {
err.note(&msg);
}
_ => err.note(&msg),
};

if let Some(file) = file {
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/associated-types/hr-associated-type-bound-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ note: required for `u32` to implement `for<'b> X<'b>`
|
LL | impl X<'_> for u32
| ^^^^^ ^^^
LL | where
LL | for<'b> <Self as X<'b>>::U: Clone,
| ----- unsatisfied trait bound introduced here
= note: 128 redundant requirements hidden
= note: required for `u32` to implement `for<'b> X<'b>`

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ note: required for `(T,)` to implement `Grault`
|
LL | impl<T: Grault> Grault for (T,)
| ^^^^^^ ^^^^
...
LL | Self::A: Baz,
| --- unsatisfied trait bound introduced here
= note: 1 redundant requirement hidden
= note: required for `(T,)` to implement `Grault`

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/associated-types/impl-wf-cycle-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ note: required for `(T,)` to implement `Grault`
|
LL | impl<T: Grault> Grault for (T,)
| ^^^^^^ ^^^^
...
LL | Self::A: Copy,
| ---- unsatisfied trait bound introduced here

error: aborting due to previous error

Expand Down
2 changes: 2 additions & 0 deletions tests/ui/associated-types/issue-44153.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ note: required for `()` to implement `Visit`
|
LL | impl<'a> Visit for () where
| ^^^^^ ^^
LL | (): Array<Element=&'a ()>,
| -------------- unsatisfied trait bound introduced here

error: aborting due to previous error

Expand Down
4 changes: 3 additions & 1 deletion tests/ui/associated-types/issue-65774-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ note: required for `&mut T` to implement `MyDisplay`
--> $DIR/issue-65774-1.rs:5:24
|
LL | impl<'a, T: MyDisplay> MyDisplay for &'a mut T { }
| ^^^^^^^^^ ^^^^^^^^^
| --------- ^^^^^^^^^ ^^^^^^^^^
| |
| unsatisfied trait bound introduced here
= note: required for the cast from `&mut T` to the object type `dyn MyDisplay`

error: aborting due to 2 previous errors
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/associated-types/substs-ppaux.normal.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ note: required for `str` to implement `Foo<'_, '_, u8>`
--> $DIR/substs-ppaux.rs:11:17
|
LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
| ^^^^^^^^^^^^^^ ^
| - ^^^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here

error: aborting due to 5 previous errors

Expand Down
4 changes: 3 additions & 1 deletion tests/ui/associated-types/substs-ppaux.verbose.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ note: required for `str` to implement `Foo<'_#0r, '_#1r, u8>`
--> $DIR/substs-ppaux.rs:11:17
|
LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
| ^^^^^^^^^^^^^^ ^
| - ^^^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here

error: aborting due to 5 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ note: required for `&'static u32` to implement `Defaulted`
--> $DIR/typeck-default-trait-impl-precedence.rs:10:19
|
LL | impl<'a,T:Signed> Defaulted for &'a T { }
| ^^^^^^^^^ ^^^^^
| ------ ^^^^^^^^^ ^^^^^
| |
| unsatisfied trait bound introduced here
note: required by a bound in `is_defaulted`
--> $DIR/typeck-default-trait-impl-precedence.rs:12:19
|
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/block-result/issue-22645.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ note: required for `Bob` to implement `Add<{integer}>`
--> $DIR/issue-22645.rs:8:19
|
LL | impl<RHS: Scalar> Add <RHS> for Bob {
| ^^^^^^^^^ ^^^
| ------ ^^^^^^^^^ ^^^
| |
| unsatisfied trait bound introduced here

error[E0308]: mismatched types
--> $DIR/issue-22645.rs:15:3
Expand Down
10 changes: 6 additions & 4 deletions tests/ui/const-generics/generic_const_exprs/issue-85848.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ note: required for `&C` to implement `Contains<(), true>`
--> $DIR/issue-85848.rs:21:12
|
LL | impl<T, U> Contains<T, { contains::<T, U>() }> for U where T: _Contains<U> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ ------------ unsatisfied trait bound introduced here
note: required for `&C` to implement `Delegates<()>`
--> $DIR/issue-85848.rs:12:12
|
LL | impl<T, U> Delegates<U> for T where T: Contains<U, true> {}
| ^^^^^^^^^^^^ ^
| ^^^^^^^^^^^^ ^ ----------------- unsatisfied trait bound introduced here
note: required by a bound in `writes_to_specific_path`
--> $DIR/issue-85848.rs:30:31
|
Expand All @@ -36,12 +36,14 @@ note: required for `&C` to implement `Contains<(), true>`
--> $DIR/issue-85848.rs:21:12
|
LL | impl<T, U> Contains<T, { contains::<T, U>() }> for U where T: _Contains<U> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^
| ^^^^^^^^^^^^----------------------^ ^
| |
| unsatisfied trait bound introduced here
note: required for `&C` to implement `Delegates<()>`
--> $DIR/issue-85848.rs:12:12
|
LL | impl<T, U> Delegates<U> for T where T: Contains<U, true> {}
| ^^^^^^^^^^^^ ^
| ^^^^^^^^^^^^ ^ ----------------- unsatisfied trait bound introduced here
note: required by a bound in `writes_to_specific_path`
--> $DIR/issue-85848.rs:30:31
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const-blocks/trait-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ note: required for `Foo<String>` to implement `Copy`
--> $DIR/trait-error.rs:1:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
= help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/derives/deriving-copyclone.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required for `B<C>` to implement `Copy`
--> $DIR/deriving-copyclone.rs:9:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
note: required by a bound in `is_copy`
--> $DIR/deriving-copyclone.rs:18:15
|
Expand All @@ -34,7 +34,7 @@ note: required for `B<C>` to implement `Clone`
--> $DIR/deriving-copyclone.rs:9:16
|
LL | #[derive(Copy, Clone)]
| ^^^^^
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
note: required by a bound in `is_clone`
--> $DIR/deriving-copyclone.rs:19:16
|
Expand All @@ -58,7 +58,7 @@ note: required for `B<D>` to implement `Copy`
--> $DIR/deriving-copyclone.rs:9:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
note: required by a bound in `is_copy`
--> $DIR/deriving-copyclone.rs:18:15
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0275.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<
--> $DIR/E0275.rs:6:9
|
LL | impl<T> Foo for T where Bar<T>: Foo {}
| ^^^ ^
| ^^^ ^ --- unsatisfied trait bound introduced here
= note: the full type name has been written to '$TEST_BUILD_DIR/error-codes/E0275/E0275.long-type-hash.txt'
= note: 127 redundant requirements hidden
= note: required for `Bar<T>` to implement `Foo`
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/generic-associated-types/impl_bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ note: required for `Fooy<T>` to implement `Copy`
--> $DIR/impl_bounds.rs:10:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
note: the requirement `Fooy<T>: Copy` appears on the `impl`'s associated type `C` but not on the corresponding trait's associated type
--> $DIR/impl_bounds.rs:6:10
|
Expand All @@ -56,7 +56,7 @@ note: required for `Fooy<T>` to implement `Copy`
--> $DIR/impl_bounds.rs:10:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
| ^^^^ unsatisfied trait bound introduced in this `derive` macro
note: the requirement `Fooy<T>: Copy` appears on the `impl`'s method `d` but not on the corresponding trait's method
--> $DIR/impl_bounds.rs:7:8
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/generic-associated-types/issue-101020.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ note: required for `&'a mut ()` to implement `for<'a> FuncInput<'a, &'a mut ()>`
--> $DIR/issue-101020.rs:27:20
|
LL | impl<'a, T, F: 'a> FuncInput<'a, F> for T where F: Foo<T> {}
| ^^^^^^^^^^^^^^^^ ^
| ^^^^^^^^^^^^^^^^ ^ ------ unsatisfied trait bound introduced here
note: required by a bound in `LendingIterator::consume`
--> $DIR/issue-101020.rs:9:33
|
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ note: required for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]>` to i
|
LL | impl<'a, A, T> T0<'a, A> for L<T>
| ^^^^^^^^^ ^^^^
LL | where
LL | T: FnMut(A) -> Unit3,
| ----- unsatisfied trait bound introduced here
note: required by a bound in `T1::m`
--> $DIR/issue-62203-hrtb-ice.rs:27:12
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>
--> $DIR/issue-89118.rs:5:23
|
LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
| --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required by a bound in `StackContext`
--> $DIR/issue-89118.rs:9:14
|
Expand All @@ -28,7 +30,9 @@ note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>
--> $DIR/issue-89118.rs:5:23
|
LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
| --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required by a bound in `EthernetWorker`
--> $DIR/issue-89118.rs:28:14
|
Expand All @@ -48,7 +52,9 @@ note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>
--> $DIR/issue-89118.rs:5:23
|
LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
| --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required by a bound in `StackContext`
--> $DIR/issue-89118.rs:9:14
|
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/impl-trait/nested-return-type2-tait2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ note: required for `[closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:7]` to i
--> $DIR/nested-return-type2-tait2.rs:14:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
| ^^^^^ ^
| --- ^^^^^ ^
| |
| unsatisfied trait bound introduced here

error: aborting due to previous error

Expand Down
4 changes: 3 additions & 1 deletion tests/ui/impl-trait/nested-return-type2-tait3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ note: required for `[closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:7]` to i
--> $DIR/nested-return-type2-tait3.rs:14:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
| ^^^^^ ^
| --- ^^^^^ ^
| |
| unsatisfied trait bound introduced here

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ note: required for `()` to implement `Test`
--> $DIR/projection-mismatch-in-impl-where-clause.rs:11:9
|
LL | impl<T> Test for T where T: Super<Assoc = ()> {}
| ^^^^ ^
| ^^^^ ^ ---------- unsatisfied trait bound introduced here

error: aborting due to previous error

Expand Down
1 change: 1 addition & 0 deletions tests/ui/inference/issue-80816.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub trait Access<T> {
}
impl<T, A: Access<T>, P: Deref<Target = A>> Access<T> for P {
//~^ NOTE: required for `Arc<ArcSwapAny<Arc<usize>>>` to implement `Access<_>`
//~| NOTE unsatisfied trait bound introduced here
type Guard = A::Guard;
}
impl<T> Access<T> for ArcSwapAny<T> {
Expand Down
8 changes: 5 additions & 3 deletions tests/ui/inference/issue-80816.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0283]: type annotations needed
--> $DIR/issue-80816.rs:49:38
--> $DIR/issue-80816.rs:50:38
|
LL | let guard: Guard<Arc<usize>> = s.load();
| ^^^^
|
note: multiple `impl`s satisfying `ArcSwapAny<Arc<usize>>: Access<_>` found
--> $DIR/issue-80816.rs:35:1
--> $DIR/issue-80816.rs:36:1
|
LL | impl<T> Access<T> for ArcSwapAny<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -16,7 +16,9 @@ note: required for `Arc<ArcSwapAny<Arc<usize>>>` to implement `Access<_>`
--> $DIR/issue-80816.rs:31:45
|
LL | impl<T, A: Access<T>, P: Deref<Target = A>> Access<T> for P {
| ^^^^^^^^^ ^
| --------- ^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
help: try using a fully qualified path to specify the expected types
|
LL | let guard: Guard<Arc<usize>> = <Arc<ArcSwapAny<Arc<usize>>> as Access<T>>::load(&s);
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/issues/issue-20413.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ note: required for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoDa
--> $DIR/issue-20413.rs:9:9
|
LL | impl<T> Foo for T where NoData<T>: Foo {
| ^^^ ^
| ^^^ ^ --- unsatisfied trait bound introduced here
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt'
= note: 127 redundant requirements hidden
= note: required for `NoData<T>` to implement `Foo`
Expand All @@ -34,13 +34,13 @@ note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNo
--> $DIR/issue-20413.rs:28:9
|
LL | impl<T> Bar for T where EvenLessData<T>: Baz {
| ^^^ ^
| ^^^ ^ --- unsatisfied trait bound introduced here
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt'
note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>` to implement `Baz`
--> $DIR/issue-20413.rs:35:9
|
LL | impl<T> Baz for T where AlmostNoData<T>: Bar {
| ^^^ ^
| ^^^ ^ --- unsatisfied trait bound introduced here
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt'
= note: 126 redundant requirements hidden
= note: required for `EvenLessData<T>` to implement `Baz`
Expand All @@ -56,13 +56,13 @@ note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLess
--> $DIR/issue-20413.rs:35:9
|
LL | impl<T> Baz for T where AlmostNoData<T>: Bar {
| ^^^ ^
| ^^^ ^ --- unsatisfied trait bound introduced here
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt'
note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>` to implement `Bar`
--> $DIR/issue-20413.rs:28:9
|
LL | impl<T> Bar for T where EvenLessData<T>: Baz {
| ^^^ ^
| ^^^ ^ --- unsatisfied trait bound introduced here
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt'
= note: 126 redundant requirements hidden
= note: required for `AlmostNoData<T>` to implement `Bar`
Expand Down
Loading