-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Generic Associated Types in Trait Paths - Ast part #79266
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
11 changes: 11 additions & 0 deletions
11
src/test/ui/generic-associated-types/parse/trait-path-expected-token.rs
This file contains hidden or 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,11 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {} | ||
//~^ ERROR: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/generic-associated-types/parse/trait-path-expected-token.stderr
This file contains hidden or 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,17 @@ | ||
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` | ||
--> $DIR/trait-path-expected-token.rs:8:33 | ||
| | ||
LL | fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {} | ||
| ^ expected one of 7 possible tokens | ||
|
||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/trait-path-expected-token.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
23 changes: 23 additions & 0 deletions
23
src/test/ui/generic-associated-types/parse/trait-path-expressions.rs
This file contains hidden or 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,23 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
mod error1 { | ||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {} | ||
//~^ ERROR: expected expression, found `)` | ||
} | ||
|
||
mod error2 { | ||
|
||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {} | ||
//~^ ERROR: only types can be used in associated type constraints | ||
} | ||
|
||
fn main() {} |
25 changes: 25 additions & 0 deletions
25
src/test/ui/generic-associated-types/parse/trait-path-expressions.stderr
This file contains hidden or 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,25 @@ | ||
error: expected expression, found `)` | ||
--> $DIR/trait-path-expressions.rs:9:39 | ||
| | ||
LL | fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {} | ||
| - ^ expected expression | ||
| | | ||
| while parsing a const generic argument starting here | ||
|
||
error: only types can be used in associated type constraints | ||
--> $DIR/trait-path-expressions.rs:19:30 | ||
| | ||
LL | fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {} | ||
| ^^^^^ | ||
|
||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/trait-path-expressions.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
21 changes: 21 additions & 0 deletions
21
src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs
This file contains hidden or 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,21 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
const _: () = { | ||
fn f1<'a>(arg : Box<dyn X< : 32 >>) {} | ||
//~^ ERROR: expected one of `>`, const, lifetime, or type, found `:` | ||
//~| ERROR: expected parameter name, found `>` | ||
//~| ERROR: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` | ||
//~| ERROR: constant provided when a type was expected | ||
}; | ||
|
||
const _: () = { | ||
fn f1<'a>(arg : Box<dyn X< = 32 >>) {} | ||
//~^ ERROR: expected one of `>`, const, lifetime, or type, found `=` | ||
}; | ||
|
||
fn main() {} |
50 changes: 50 additions & 0 deletions
50
src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr
This file contains hidden or 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,50 @@ | ||
error: expected one of `>`, const, lifetime, or type, found `:` | ||
--> $DIR/trait-path-missing-gen_arg.rs:9:30 | ||
| | ||
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} | ||
| ^ expected one of `>`, const, lifetime, or type | ||
| | ||
help: expressions must be enclosed in braces to be used as const generic arguments | ||
| | ||
LL | fn f1<'a>(arg : Box<{ dyn X< : 32 } >>) {} | ||
| ^ ^ | ||
|
||
error: expected parameter name, found `>` | ||
--> $DIR/trait-path-missing-gen_arg.rs:9:36 | ||
| | ||
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} | ||
| ^ expected parameter name | ||
|
||
error: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` | ||
--> $DIR/trait-path-missing-gen_arg.rs:9:36 | ||
| | ||
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} | ||
| ^ | ||
| | | ||
| expected one of `!`, `)`, `+`, `,`, or `::` | ||
| help: missing `,` | ||
|
||
error: expected one of `>`, const, lifetime, or type, found `=` | ||
--> $DIR/trait-path-missing-gen_arg.rs:17:30 | ||
| | ||
LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {} | ||
| ^ expected one of `>`, const, lifetime, or type | ||
|
||
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/trait-path-missing-gen_arg.rs:1:12 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information | ||
|
||
error[E0747]: constant provided when a type was expected | ||
--> $DIR/trait-path-missing-gen_arg.rs:9:23 | ||
| | ||
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} | ||
| ^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0747`. |
35 changes: 35 additions & 0 deletions
35
src/test/ui/generic-associated-types/parse/trait-path-segments.rs
This file contains hidden or 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 @@ | ||
#![feature(generic_associated_types)] | ||
//~^ WARNING: the feature `generic_associated_types` is incomplete | ||
|
||
const _: () = { | ||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {} | ||
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints | ||
}; | ||
|
||
const _: () = { | ||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
trait Z {} | ||
|
||
impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {} | ||
//~^ ERROR: qualified paths cannot be used in associated type constraints | ||
}; | ||
|
||
const _: () = { | ||
trait X { | ||
type Y<'a>; | ||
} | ||
|
||
trait Z {} | ||
|
||
impl<T : X<X::Y<'a> = &'a u32>> Z for T {} | ||
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints | ||
}; | ||
|
||
fn main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.