-
Notifications
You must be signed in to change notification settings - Fork 13.4k
resolve: Some cleanup, asserts and tests for lifetime ribs #102884
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![feature(inline_const)] | ||
|
||
struct S<'a>(&'a u8); | ||
fn foo() {} | ||
|
||
// Paren generic args in AnonConst | ||
fn a() -> [u8; foo::()] { | ||
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait | ||
//~| ERROR mismatched types | ||
panic!() | ||
} | ||
|
||
// Paren generic args in ConstGeneric | ||
fn b<const C: u8()>() {} | ||
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait | ||
|
||
// Paren generic args in AnonymousReportError | ||
fn c<T = u8()>() {} | ||
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait | ||
//~| ERROR defaults for type parameters are only allowed in | ||
//~| WARN this was previously accepted | ||
|
||
// Elided lifetime in path in ConstGeneric | ||
fn d<const C: S>() {} | ||
//~^ ERROR missing lifetime specifier | ||
//~| ERROR `S<'static>` is forbidden as the type of a const generic parameter | ||
|
||
fn main() {} |
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,61 @@ | ||
error[E0106]: missing lifetime specifier | ||
--> $DIR/unusual-rib-combinations.rs:24:15 | ||
| | ||
LL | fn d<const C: S>() {} | ||
| ^ expected named lifetime parameter | ||
| | ||
help: consider introducing a named lifetime parameter | ||
| | ||
LL | fn d<'a, const C: S<'a>>() {} | ||
| +++ ++++ | ||
|
||
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait | ||
--> $DIR/unusual-rib-combinations.rs:7:16 | ||
| | ||
LL | fn a() -> [u8; foo::()] { | ||
| ^^^^^^^ only `Fn` traits may use parentheses | ||
|
||
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait | ||
--> $DIR/unusual-rib-combinations.rs:14:15 | ||
| | ||
LL | fn b<const C: u8()>() {} | ||
| ^^^^ only `Fn` traits may use parentheses | ||
|
||
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait | ||
--> $DIR/unusual-rib-combinations.rs:18:10 | ||
| | ||
LL | fn c<T = u8()>() {} | ||
| ^^^^ only `Fn` traits may use parentheses | ||
|
||
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions | ||
--> $DIR/unusual-rib-combinations.rs:18:6 | ||
| | ||
LL | fn c<T = u8()>() {} | ||
| ^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> | ||
= note: `#[deny(invalid_type_param_default)]` on by default | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/unusual-rib-combinations.rs:7:16 | ||
| | ||
LL | fn a() -> [u8; foo::()] { | ||
| ^^^^^^^ expected `usize`, found fn item | ||
| | ||
= note: expected type `usize` | ||
found fn item `fn() {foo}` | ||
|
||
error: `S<'static>` is forbidden as the type of a const generic parameter | ||
--> $DIR/unusual-rib-combinations.rs:24:15 | ||
| | ||
LL | fn d<const C: S>() {} | ||
| ^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
= help: more complex types are supported with `#![feature(adt_const_params)]` | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
Some errors have detailed explanations: E0106, E0214, E0308. | ||
For more information about an error, try `rustc --explain E0106`. |
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.