Skip to content

Lifetime bounds on structs do not entirely constrain impl fns #28609

Closed
@talchas

Description

@talchas
struct Foo<'a, 'b: 'a>(&'a &'b i32);
impl<'a, 'b> Foo<'a, 'b> {
    fn foo(&self) {}
}

compiles. As far as I can tell, the bound on 'b is checked in the definitions of the functions, but isn't checked in the use of them. As a concrete example of this Kimundi/scoped-threadpool-rs#8 ( https://play.rust-lang.org/?gist=870da1405ea15e80f778&version=nightly ) will allow the incorrect use of ScopeRef in the test, while copying the bounds from the struct definition to the impl definition correctly rejects it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions