Skip to content

Commit 44b6807

Browse files
Don't check for alias bounds in liveness when aliases have escaping bound vars
1 parent 50be229 commit 44b6807

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

compiler/rustc_infer/src/infer/outlives/for_liveness.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
1+
use rustc_middle::ty::{
2+
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
3+
};
24

35
use std::ops::ControlFlow;
46

@@ -49,6 +51,12 @@ where
4951
return ControlFlow::Continue(());
5052
}
5153

54+
// FIXME: Don't consider alias bounds on types that have escaping bound
55+
// vars. See #117455.
56+
if ty.has_escaping_bound_vars() {
57+
return ty.super_visit_with(self);
58+
}
59+
5260
match ty.kind() {
5361
// We can prove that an alias is live two ways:
5462
// 1. All the components are live.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// check-pass
2+
3+
trait Foo {
4+
type Assoc<'a, 'b>: 'static;
5+
}
6+
7+
struct MentionsLifetimeAndType<'a, T>(&'a (), T);
8+
9+
fn foo<'a, 'b, T: Foo>(_: <T as Foo>::Assoc<'a, 'b>) {}
10+
11+
fn test<'b, T: Foo>() {
12+
let y: MentionsLifetimeAndType<'_, for<'a> fn(<T as Foo>::Assoc<'a, 'b>)> =
13+
MentionsLifetimeAndType(&(), foo);
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)