Skip to content

Can't express "T : Foo<X1> implies T : Foo<X2>" #11318

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

Closed
vadimcn opened this issue Jan 5, 2014 · 2 comments
Closed

Can't express "T : Foo<X1> implies T : Foo<X2>" #11318

vadimcn opened this issue Jan 5, 2014 · 2 comments
Labels
A-trait-system Area: Trait system

Comments

@vadimcn
Copy link
Contributor

vadimcn commented Jan 5, 2014

[Previously reported on rust-dev]

I'm trying to say "Any type that implements Foo<X1> also implements Foo<X2>":

trait Foo<T> {}
struct X1;
struct X2;

impl<T: Foo<X1>> Foo<X2> for T {}

fn main() {}

but this does not compile:

test.rs:5:1: 5:34 error: expected Foo<X2>, but found Foo<X1> (expected struct X2 but found struct X1)
test.rs:5 impl<T: Foo<X1>> Foo<X2> for T {}

This is supposedly related to Rust not distinguishing between different instantiations of generic traits, though you'd never guess that from the error message...

@vadimcn
Copy link
Contributor Author

vadimcn commented Jan 5, 2014

cc #5527

@huonw huonw added the A-traits label Jun 16, 2014
@steveklabnik
Copy link
Member

This now compiles successfully.

flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 11, 2023
[`filter_map_bool_then`]: Don't ICE on late bound regions

Fixes rust-lang#11309

Also lints `&NonCopy` now, since any `&` is `Copy`. That was accidental, but it seems that this is a consequence (or improvement!) of this fix.

r? `@Jarcho`

changelog: [`filter_map_bool_then`]: Don't ICE on late bound regions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

3 participants