Skip to content

Commit e273fab

Browse files
authored
Rollup merge of #90840 - BoxyUwU:lolripme, r=jackh726
relate lifetime in `TypeOutlives` bounds on drop impls Fixes #90838
2 parents b35af0d + 875024c commit e273fab

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

compiler/rustc_typeck/src/check/dropck.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
240240
ty::PredicateKind::ConstEvaluatable(a),
241241
ty::PredicateKind::ConstEvaluatable(b),
242242
) => tcx.try_unify_abstract_consts((a, b)),
243-
(ty::PredicateKind::TypeOutlives(a), ty::PredicateKind::TypeOutlives(b)) => {
244-
relator.relate(predicate.rebind(a.0), p.rebind(b.0)).is_ok()
243+
(
244+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, lt_a)),
245+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_b, lt_b)),
246+
) => {
247+
relator.relate(predicate.rebind(ty_a), p.rebind(ty_b)).is_ok()
248+
&& relator.relate(predicate.rebind(lt_a), p.rebind(lt_b)).is_ok()
245249
}
246250
_ => predicate == p,
247251
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
struct Wrapper<'a, T>(&'a T)
2+
where
3+
T: 'a;
4+
5+
impl<'a, T> Drop for Wrapper<'a, T>
6+
where
7+
T: 'static,
8+
//~^ error: `Drop` impl requires `T: 'static` but the struct it is implemented for does not
9+
{
10+
fn drop(&mut self) {}
11+
}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0367]: `Drop` impl requires `T: 'static` but the struct it is implemented for does not
2+
--> $DIR/relate_lt_in_type_outlives_bound.rs:7:8
3+
|
4+
LL | T: 'static,
5+
| ^^^^^^^
6+
|
7+
note: the implementor must specify the same requirement
8+
--> $DIR/relate_lt_in_type_outlives_bound.rs:1:1
9+
|
10+
LL | / struct Wrapper<'a, T>(&'a T)
11+
LL | | where
12+
LL | | T: 'a;
13+
| |__________^
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0367`.

0 commit comments

Comments
 (0)