Skip to content

Lifetime bounds in Copy impls are ignored #29149

Closed

Description

@arielb1

UPDATE: Mentoring instructions below.


Affected Versions

rustc 1.3.0 - 1.5.0

STR

#[derive(Clone)] struct Foo<'a>(&'a u32);
impl Copy for Foo<'static> {}

fn main() {
    let s = 2;
    let a = Foo(&s);
    drop(a);
    drop(a);
}

Expected Result

Foo<'a> is not Copy, so this should cause a borrowck error.

Actual Result

The code compiles :-).

cc @nikomatsakis

Activity

  1. added
    T-langRelevant to the language team
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 21, 2015
  2. nikomatsakis commented on Oct 21, 2015

    @nikomatsakis
    Contributor

    Nominating.

  3. self-assigned this
    on Oct 22, 2015
  4. nikomatsakis commented on Oct 22, 2015

    @nikomatsakis
    Contributor

    triage: P-high

  5. nikomatsakis commented on Nov 5, 2015

    @nikomatsakis
    Contributor

    Correct behavior here is not entirely obvious, given that we erase lifetimes at trans. Possibly we should be treating this affine, or possibly the impl should be an error? Have to mull this over.

    cc @rust-lang/lang

  6. nikomatsakis commented on Nov 5, 2015

    @nikomatsakis
    Contributor

    Nominating for discussion at the lang meeting.

  7. 54 remaining items

  8. nikomatsakis commented on Jan 30, 2018

    @nikomatsakis
    Contributor

    Fixed (with NLL) in #47877

  9. added a commit that references this issue on Jan 30, 2018
    b9f7564
  10. added 3 commits that reference this issue on Feb 3, 2018
  11. added a commit that references this issue on Jul 2, 2018
  12. added 2 commits that reference this issue on Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-trait-systemArea: Trait systemC-bugCategory: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions