Rollup merge of #90840 - BoxyUwU:lolripme, r=jackh726
relate lifetime in `TypeOutlives` bounds on drop impls Fixes #90838
This commit is contained in:
commit
e273fab434
@ -240,8 +240,12 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||
ty::PredicateKind::ConstEvaluatable(a),
|
||||
ty::PredicateKind::ConstEvaluatable(b),
|
||||
) => tcx.try_unify_abstract_consts((a, b)),
|
||||
(ty::PredicateKind::TypeOutlives(a), ty::PredicateKind::TypeOutlives(b)) => {
|
||||
relator.relate(predicate.rebind(a.0), p.rebind(b.0)).is_ok()
|
||||
(
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, lt_a)),
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_b, lt_b)),
|
||||
) => {
|
||||
relator.relate(predicate.rebind(ty_a), p.rebind(ty_b)).is_ok()
|
||||
&& relator.relate(predicate.rebind(lt_a), p.rebind(lt_b)).is_ok()
|
||||
}
|
||||
_ => predicate == p,
|
||||
}
|
||||
|
13
src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs
Normal file
13
src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs
Normal file
@ -0,0 +1,13 @@
|
||||
struct Wrapper<'a, T>(&'a T)
|
||||
where
|
||||
T: 'a;
|
||||
|
||||
impl<'a, T> Drop for Wrapper<'a, T>
|
||||
where
|
||||
T: 'static,
|
||||
//~^ error: `Drop` impl requires `T: 'static` but the struct it is implemented for does not
|
||||
{
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
17
src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr
Normal file
17
src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr
Normal file
@ -0,0 +1,17 @@
|
||||
error[E0367]: `Drop` impl requires `T: 'static` but the struct it is implemented for does not
|
||||
--> $DIR/relate_lt_in_type_outlives_bound.rs:7:8
|
||||
|
|
||||
LL | T: 'static,
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: the implementor must specify the same requirement
|
||||
--> $DIR/relate_lt_in_type_outlives_bound.rs:1:1
|
||||
|
|
||||
LL | / struct Wrapper<'a, T>(&'a T)
|
||||
LL | | where
|
||||
LL | | T: 'a;
|
||||
| |__________^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0367`.
|
Loading…
Reference in New Issue
Block a user