Skip to content

Weird interaction between higher-ranked lifetimes and associated type bounds #23481

Closed

Description

@apasel422

foo.rs:

pub trait Foo
where
    for<'a> &'a Self: Bar,
    for<'a> <&'a Self as Bar>::Xyz: Clone {}

pub trait Bar {
    type Xyz;
}

impl Foo for () {}

impl<'a> Bar for &'a () {
    type Xyz = usize;
}

Error from rustc 1.0.0-nightly (30e1f9a1c 2015-03-14) (built 2015-03-15)

foo.rs:12:1: 12:19 error: the trait `for<'a> core::clone::Clone` is not implemented for the type `<&'a () as Bar>::Xyz` [E0277]
foo.rs:12 impl Foo for () {}
          ^~~~~~~~~~~~~~~~~~

Activity

  1. changed the title [-]Weird interaction between higher-kinded lifetimes and associated type bounds[/-] [+]Weird interaction between higher-ranked lifetimes and associated type bounds[/+] on Nov 23, 2015
  2. brson commented on May 4, 2017

    @brson
    Contributor

    Current error

    
    
    rustc 1.17.0 (56124baa9 2017-04-24)
    error[E0277]: the trait bound `for<'a> <&'a () as Bar>::Xyz: std::clone::Clone` is not satisfied
      --> <anon>:10:6
       |
    10 | impl Foo for () {}
       |      ^^^ the trait `for<'a> std::clone::Clone` is not implemented for `<&'a () as Bar>::Xyz`
       |
       = help: the following implementations were found:
                 <&'a T as std::clone::Clone>
       = note: required by `Foo`
    
    error: aborting due to previous error
    
    Compilation failed.
    
  3. steveklabnik commented on Sep 24, 2018

    @steveklabnik
    Contributor

    Triage: no change

  4. estebank commented on Nov 5, 2019

    @estebank
    Contributor

    Trieage: no change.

  5. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    T-langRelevant to the language team
    on Nov 5, 2019
  6. estebank commented on Jun 8, 2022

    @estebank
    Contributor

    This code now compiles since 1.56. On 1.55, the error was:

    error[E0277]: the trait bound `for<'a> <&'a () as Bar>::Xyz: Clone` is not satisfied
      --> <source>:10:6
       |
    1  | pub trait Foo
       |           --- required by a bound in this
    ...
    4  |     for<'a> <&'a Self as Bar>::Xyz: Clone {}
       |                                     ----- required by this bound in `Foo`
    ...
    10 | impl Foo for () {}
       |      ^^^ the trait `for<'a> Clone` is not implemented for `<&'a () as Bar>::Xyz`
       |
       = help: the following implementations were found:
                 <&T as Clone>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsA-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)A-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.P-lowLow 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