Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

avoid incoming breakage of for<'a> &'a T: 'a bounds #2

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

aliemjay
Copy link
Contributor

rust-lang/rust#98109 fixes a soundness hole in rust. Unfortunately, this fix exposes an other known bug in reasoning about bounds of the form for<'a> &'a T: 'a. This bug can be illustrated in the following example which is rejected since v1.0!

fn require_bound<T>()
where
    for<'a> &'a T: 'a,
    // T: 'static // <- rustc incorrectly thinks it must prove this bound for the above bound to hold.
{
}

fn test<T>() {
    require_bound::<T>();
    //^ ERROR  type parameter T doesn't live long enough
}

One way to work around such bug is to simply remove the bound since it is always satisfied for any type T.

We tried to fix this in a timely manner, but it's not a particularly easy problem. Indeed it is part of a long-term initiative under the name of "implied bounds" to better support these bounds. Sorry for any inconvenience!

@Dessix Dessix merged commit 2d35c74 into microsoft:main Oct 10, 2022
@Dessix
Copy link
Member

Dessix commented Oct 10, 2022

Confirmed locally and merged; Thank you for your contribution.

@Dessix
Copy link
Member

Dessix commented Oct 10, 2022

I'll note that #3 covered a bound missed by this PR on line 241. I'll be partially merging that as well. Following that, I will be publishing an update to a more-recent Rust version, which will set this in stone.

@aliemjay aliemjay deleted the patch-1 branch October 11, 2022 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants