Skip to content
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 @@ -4258,9 +4258,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
err.span_note(spans, msg);
if derived && trait_name != "Copy" {
err.help(format!(
"consider manually implementing `{trait_name}` to avoid undesired \
bounds",
"consider manually implementing `{trait_name}` to avoid undesired bounds caused by \"imperfect derives\"",
));
err.note(
"to learn more, visit <https://github.com/rust-lang/rust/issues/26925>",
);
}
point_at_assoc_type_restriction(
tcx,
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/associated-types/issue-38821.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ LL | pub enum ColumnInsertValue<Col, Expr> where
...
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ------------------------------------------------ unsatisfied trait bound
= help: consider manually implementing `Debug` to avoid undesired bounds
= help: consider manually implementing `Debug` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
help: consider further restricting the associated type
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
Expand Down Expand Up @@ -238,7 +239,8 @@ LL | pub enum ColumnInsertValue<Col, Expr> where
...
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ------------------------------------------------ unsatisfied trait bound
= help: consider manually implementing `Clone` to avoid undesired bounds
= help: consider manually implementing `Clone` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
help: consider further restricting the associated type
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| ----- in this derive macro expansion
LL | struct Bar<T>(T);
| ^^^ - unsatisfied trait bound
= help: consider manually implementing `Debug` to avoid undesired bounds
= help: consider manually implementing `Debug` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
= note: 2 redundant requirements hidden
= note: required for `&&'static Bar<(dyn Debug + 'static)>` to implement `Debug`
= note: required for the cast from `&&&'static Bar<(dyn Debug + 'static)>` to `&dyn Debug`
Expand Down Expand Up @@ -102,7 +103,8 @@ LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| -- in this derive macro expansion
LL | struct Bar<T>(T);
| ^^^ - type parameter would need to implement `Eq`
= help: consider manually implementing `Eq` to avoid undesired bounds
= help: consider manually implementing `Eq` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
= note: 1 redundant requirement hidden
= note: required for `&'static Bar<dyn Debug>` to implement `Eq`
note: required by a bound in `std::cmp::AssertParamIsEq`
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/derives/clone-copy/deriving-copyclone.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ LL | #[derive(Copy, Clone)]
| ----- in this derive macro expansion
LL | struct B<T> {
| ^ - type parameter would need to implement `Clone`
= help: consider manually implementing `Clone` to avoid undesired bounds
= help: consider manually implementing `Clone` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
note: required by a bound in `is_clone`
--> $DIR/deriving-copyclone.rs:19:16
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ LL | #[derive(Debug)]
| ----- in this derive macro expansion
LL | struct S<T>(T);
| ^ - type parameter would need to implement `Debug`
= help: consider manually implementing `Debug` to avoid undesired bounds
= help: consider manually implementing `Debug` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
help: consider annotating `X` with `#[derive(Debug)]`
|
LL + #[derive(Debug)]
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/proc-macro/issue-104884-trait-impl-sugg-err.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ LL | #[derive(PartialOrd, AddImpl)]
...
LL | struct PriorityQueue<T>(BinaryHeap<PriorityQueueEntry<T>>);
| ^^^^^^^^^^^^^ - type parameter would need to implement `PartialOrd`
= help: consider manually implementing `PartialOrd` to avoid undesired bounds
= help: consider manually implementing `PartialOrd` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
note: required by a bound in `Ord`
--> $SRC_DIR/core/src/cmp.rs:LL:COL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ LL | #[derive(Debug, Copy, Clone)]
| ----- in this derive macro expansion
LL | pub struct Vector2<T: Debug + Copy + Clone> {
| ^^^^^^^ ---- unsatisfied trait bound
= help: consider manually implementing `Debug` to avoid undesired bounds
= help: consider manually implementing `Debug` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
= note: required for the cast from `&Vector2<K>` to `&dyn Debug`
help: consider further restricting type parameter `K` with trait `Copy`
|
Expand Down Expand Up @@ -72,7 +73,8 @@ LL | #[derive(Debug, Copy, Clone)]
| ----- in this derive macro expansion
LL | pub struct Vector2<T: Debug + Copy + Clone> {
| ^^^^^^^ ---- unsatisfied trait bound
= help: consider manually implementing `Clone` to avoid undesired bounds
= help: consider manually implementing `Clone` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
help: consider further restricting type parameter `K` with trait `Copy`
|
LL | pub struct AABB<K: Debug + std::marker::Copy> {
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ LL | #[derive(Debug, Copy, Clone)]
| ----- in this derive macro expansion
LL | pub struct Vector2<T: Debug + Copy + Clone> {
| ^^^^^^^ ---- unsatisfied trait bound
= help: consider manually implementing `Debug` to avoid undesired bounds
= help: consider manually implementing `Debug` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
= note: required for the cast from `&Vector2<K>` to `&dyn Debug`
help: consider restricting type parameter `K` with trait `Copy`
|
Expand Down Expand Up @@ -136,7 +137,8 @@ LL | #[derive(Debug, Copy, Clone)]
| ----- in this derive macro expansion
LL | pub struct Vector2<T: Debug + Copy + Clone> {
| ^^^^^^^ ---- unsatisfied trait bound
= help: consider manually implementing `Clone` to avoid undesired bounds
= help: consider manually implementing `Clone` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
help: consider restricting type parameter `K` with trait `Copy`
|
LL | pub struct AABB<K: std::marker::Copy> {
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/traits/derive-implicit-bound.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ LL | #[derive(PartialEq, Eq)]
| --------- in this derive macro expansion
LL | pub struct Id<T>(PhantomData<T>);
| ^^ - type parameter would need to implement `PartialEq`
= help: consider manually implementing `PartialEq` to avoid undesired bounds
= help: consider manually implementing `PartialEq` to avoid undesired bounds caused by "imperfect derives"
= note: to learn more, visit <https://github.com/rust-lang/rust/issues/26925>
note: required by a bound in `accept_eq`
--> $DIR/derive-implicit-bound.rs:17:23
|
Expand Down
Loading