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

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

Closed
apasel422 opened this issue Mar 18, 2015 · 4 comments
Closed
Labels
A-associated-items Area: Associated items (types, constants & functions) A-diagnostics Area: Messages for errors, warnings, and lints A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@apasel422
Copy link
Contributor

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 () {}
          ^~~~~~~~~~~~~~~~~~
@steveklabnik steveklabnik added the A-associated-items Area: Associated items (types, constants & functions) label Mar 18, 2015
@huonw huonw changed the title Weird interaction between higher-kinded lifetimes and associated type bounds Weird interaction between higher-ranked lifetimes and associated type bounds Nov 23, 2015
@brson
Copy link
Contributor

brson commented May 4, 2017

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.

@brson brson added A-lifetimes Area: Lifetimes / regions P-low Low priority labels May 4, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: no change

@estebank
Copy link
Contributor

estebank commented Nov 5, 2019

Trieage: no change.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints F-associated_type_bounds `#![feature(associated_type_bounds)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Nov 5, 2019
@matthewjasper matthewjasper added the A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) label Jul 11, 2020
@jackh726 jackh726 removed the F-associated_type_bounds `#![feature(associated_type_bounds)]` label Feb 2, 2021
@estebank
Copy link
Contributor

estebank commented Jun 8, 2022

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>

@estebank estebank closed this as completed Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-diagnostics Area: Messages for errors, warnings, and lints A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants