-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsGATs-triagedIssues using the `generic_associated_types` feature that have been triagedIssues using the `generic_associated_types` feature that have been triagedS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.
Description
Compiling this code:
#![feature(generic_associated_types)]
trait MyTrait {
type Assoc<'a, 'b> where 'b: 'a;
fn do_sth(arg: Self::Assoc<'_, '_>);
}
struct Foo;
impl MyTrait for Foo {
type Assoc<'a, 'b> where 'b: 'a = u32;
fn do_sth(_: u32) {}
// fn do_sth(_: Self::Assoc<'static, 'static>) {}
// fn do_sth(_: Self::Assoc<'_, '_>) {}
}
I'd expect all of these three versions to compile. The associated type has two lifetimes as well as a lifetime bound 'b: 'a
, but u32
doesn't use the lifetime. However, I'm getting a compiler error:
error[E0478]: lifetime bound not satisfied
--> src/lib.rs:13:5
|
13 | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the anonymous lifetime #2 defined on the method body at 13:5
--> src/lib.rs:13:5
|
13 | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
note: but lifetime parameter must outlive the anonymous lifetime #1 defined on the method body at 13:5
--> src/lib.rs:13:5
|
13 | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0478`.
error: could not compile `playground` due to previous error
Without the where 'b: 'a
, all three compile fine.
Metadata
Metadata
Assignees
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsGATs-triagedIssues using the `generic_associated_types` feature that have been triagedIssues using the `generic_associated_types` feature that have been triagedS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.