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 @@ -6788,7 +6788,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
tcx,
ObligationCause::dummy(),
param_env,
ty::TraitRef::new(tcx, trait_def_id, trait_args),
parent_trait_pred.rebind(ty::TraitRef::new(tcx, trait_def_id, trait_args)),
);
self.predicate_may_hold(&obligation)
})
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/derives/imperfect-derive-higher-ranked.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// regression test for #164376

#[derive(Clone)]
struct S<'a, T>(&'a T);

fn require<T>() where for<'a> S<'a, T>: Clone {}

fn main() {
require::<&'static mut u8>();
//~^ ERROR the trait bound `&'static mut u8: Clone` is not satisfied
}
29 changes: 29 additions & 0 deletions tests/ui/derives/imperfect-derive-higher-ranked.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0277]: the trait bound `&'static mut u8: Clone` is not satisfied
--> $DIR/imperfect-derive-higher-ranked.rs:9:15
|
LL | require::<&'static mut u8>();
| ^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&'static mut u8`
|
help: the trait `Clone` is implemented for `u8`
--> $SRC_DIR/core/src/clone.rs:LL:COL
::: $SRC_DIR/core/src/clone.rs:LL:COL
|
= note: in this macro invocation
note: required for `S<'a, &'static mut u8>` to implement `for<'a> Clone`
--> $DIR/imperfect-derive-higher-ranked.rs:4:8
|
LL | #[derive(Clone)]
| ----- in this derive macro expansion
LL | struct S<'a, T>(&'a T);
| ^ - type parameter would need to implement `for<'a> Clone`
= help: consider manually implementing `for<'a> 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 `require`
--> $DIR/imperfect-derive-higher-ranked.rs:6:41
|
LL | fn require<T>() where for<'a> S<'a, T>: Clone {}
| ^^^^^ required by this bound in `require`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Loading