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

Unconstrained lifetimes permitted in assoc. type as long as they are in a projection #29861

Closed
nikomatsakis opened this issue Nov 16, 2015 · 4 comments
Assignees
Labels
A-traits Area: Trait system I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

This makes things unsound. Here is an example from @eddyb:

pub trait MakeRef<'a> {
    type Ref;
}
impl<'a, T: 'a> MakeRef<'a> for T {
    type Ref = &'a T;
}

pub trait MakeRef2 {
    type Ref2;
}
impl<'a, T> MakeRef2 for T {
    type Ref2 = <T as MakeRef<'a>>::Ref;
}

fn foo() -> <String as MakeRef2>::Ref2 { &String::from("foo") }

fn main() {
    println!("{}", foo());
}

This should be prohibited by https://github.com/rust-lang/rfcs/blob/master/text/0447-no-unused-impl-parameters.md, but it seems there is some bug.

@nikomatsakis nikomatsakis added A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness labels Nov 16, 2015
@nikomatsakis
Copy link
Contributor Author

triage: P-high

@eddyb
Copy link
Member

eddyb commented Nov 16, 2015

cc @james-darkfox (who tripped on this and #29859 in his lense crate)

@arielb1
Copy link
Contributor

arielb1 commented Nov 18, 2015

This is just stupid. I made ctp::parameters_for_type return the set of parameters that are constrained by a type, but we are also interested in the basis of parameters that determine a type, and I missed that that logic also uses the method. I will issue a patch.

@arielb1
Copy link
Contributor

arielb1 commented Nov 18, 2015

I really should try to stop having my bugfixes having bugs.

arielb1 added a commit to arielb1/rust that referenced this issue Nov 19, 2015
As this is a soundness fix, it is a [breaking-change].

Fixes rust-lang#29861.
bors added a commit that referenced this issue Nov 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants