forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#92918 - compiler-errors:gat-expr-lifetime-e…
…lision, r=jackh726 Allow eliding GATs in expression position Thoughts on whether this is worthwhile? Fixes rust-lang#92836 r? `@jackh726`
- Loading branch information
Showing
4 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/ui/generic-associated-types/elided-in-expr-position.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#![feature(generic_associated_types)] | ||
#![allow(unused)] | ||
|
||
pub trait Trait { | ||
type Assoc<'a> where Self: 'a; | ||
|
||
fn f(&self) -> Self::Assoc<'_>; | ||
|
||
// Disallow elision in return position, for now | ||
fn g(&self) -> Self::Assoc; | ||
//~^ ERROR missing generics for associated type `Trait::Assoc` | ||
} | ||
|
||
pub struct Struct { | ||
item: f32 | ||
} | ||
|
||
pub struct GenericStruct<'a> { | ||
ref_item: &'a f32 | ||
} | ||
|
||
impl Trait for Struct { | ||
type Assoc<'a> = GenericStruct<'a>; | ||
|
||
fn f(&self) -> Self::Assoc<'_> { | ||
Self::Assoc { | ||
ref_item: &self.item | ||
} | ||
} | ||
|
||
// Disallow elision in return position, for now | ||
fn g(&self) -> Self::Assoc { | ||
//~^ ERROR missing generics for associated type `Trait::Assoc` | ||
todo!() | ||
} | ||
} | ||
|
||
fn main() {} |
35 changes: 35 additions & 0 deletions
35
src/test/ui/generic-associated-types/elided-in-expr-position.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error[E0107]: missing generics for associated type `Trait::Assoc` | ||
--> $DIR/elided-in-expr-position.rs:10:26 | ||
| | ||
LL | fn g(&self) -> Self::Assoc; | ||
| ^^^^^ expected 1 lifetime argument | ||
| | ||
note: associated type defined here, with 1 lifetime parameter: `'a` | ||
--> $DIR/elided-in-expr-position.rs:5:10 | ||
| | ||
LL | type Assoc<'a> where Self: 'a; | ||
| ^^^^^ -- | ||
help: add missing lifetime argument | ||
| | ||
LL | fn g(&self) -> Self::Assoc<'_>; | ||
| ~~~~~~~~~ | ||
|
||
error[E0107]: missing generics for associated type `Trait::Assoc` | ||
--> $DIR/elided-in-expr-position.rs:32:26 | ||
| | ||
LL | fn g(&self) -> Self::Assoc { | ||
| ^^^^^ expected 1 lifetime argument | ||
| | ||
note: associated type defined here, with 1 lifetime parameter: `'a` | ||
--> $DIR/elided-in-expr-position.rs:5:10 | ||
| | ||
LL | type Assoc<'a> where Self: 'a; | ||
| ^^^^^ -- | ||
help: add missing lifetime argument | ||
| | ||
LL | fn g(&self) -> Self::Assoc<'_> { | ||
| ~~~~~~~~~ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0107`. |