Skip to content

Commit

Permalink
Don't check for alias bounds in liveness when aliases have escaping b…
Browse files Browse the repository at this point in the history
…ound vars
  • Loading branch information
compiler-errors committed Oct 31, 2023
1 parent 50be229 commit 44b6807
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 9 additions & 1 deletion compiler/rustc_infer/src/infer/outlives/for_liveness.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
};

use std::ops::ControlFlow;

Expand Down Expand Up @@ -49,6 +51,12 @@ where
return ControlFlow::Continue(());
}

// FIXME: Don't consider alias bounds on types that have escaping bound
// vars. See #117455.
if ty.has_escaping_bound_vars() {
return ty.super_visit_with(self);
}

match ty.kind() {
// We can prove that an alias is live two ways:
// 1. All the components are live.
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/type-alias-impl-trait/alias-bounds-when-bounds-escape.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// check-pass

trait Foo {
type Assoc<'a, 'b>: 'static;
}

struct MentionsLifetimeAndType<'a, T>(&'a (), T);

fn foo<'a, 'b, T: Foo>(_: <T as Foo>::Assoc<'a, 'b>) {}

fn test<'b, T: Foo>() {
let y: MentionsLifetimeAndType<'_, for<'a> fn(<T as Foo>::Assoc<'a, 'b>)> =
MentionsLifetimeAndType(&(), foo);
}

fn main() {}

0 comments on commit 44b6807

Please sign in to comment.