Skip to content

we eagerly normalize Type-outlives bounds #63

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
compiler-errors opened this issue Sep 21, 2023 · 2 comments
Open

we eagerly normalize Type-outlives bounds #63

compiler-errors opened this issue Sep 21, 2023 · 2 comments

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Sep 21, 2023

With rust-lang/rust#119101 and rust-lang/rust#120513 TypeOutlives obligations and assumptions are now eagerly normalized at the start of regionck and borrowck.

previous issue

Type-outlives bounds can be proven several ways -- via item bounds, via param-env clauses, and by recursively applying to the type's components. When applying param-env clauses that may satisfy a type-outlives bounds, we use the Match relation, which only considers types structurally.

That causes this code to go from passing to failing in the new trait solver:

trait Mirror {
    type Assoc;
}
impl<T> Mirror for T {
    type Assoc = T;
}

fn is_static<T: 'static>() {}

fn test<T>() where <T as Mirror>::Assoc: 'static {
    is_static::<T>();
}
@compiler-errors
Copy link
Member Author

The current trait solver avoids this by normalizing the param-env, so the bound in test above becomes where T: 'static.

@compiler-errors
Copy link
Member Author

This is not fixed by rust-lang/rust#119101, MIR borrowck doesn't normalize type-outlives yet. That will happen soon.

@lcnr lcnr changed the title Type-outlives bounds only apply structurally we eagerly normalize Type-outlives bounds Feb 9, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant