-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow parenthesis around inferred array lengths #139641
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
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
53 changes: 53 additions & 0 deletions
53
tests/ui/const-generics/generic_arg_infer/parend_infer.nogate.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,53 @@ | ||
error[E0658]: const arguments cannot yet be inferred with `_` | ||
--> $DIR/parend_infer.rs:24:16 | ||
| | ||
LL | let c: Foo<_> = Foo::<1>; | ||
| ^ | ||
| | ||
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information | ||
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: const arguments cannot yet be inferred with `_` | ||
--> $DIR/parend_infer.rs:26:16 | ||
| | ||
LL | let c: Foo<(_)> = Foo::<1>; | ||
| ^^^ | ||
| | ||
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information | ||
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: const arguments cannot yet be inferred with `_` | ||
--> $DIR/parend_infer.rs:28:16 | ||
| | ||
LL | let c: Foo<(((_)))> = Foo::<1>; | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information | ||
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: using `_` for array lengths is unstable | ||
--> $DIR/parend_infer.rs:17:17 | ||
| | ||
LL | let b: [u8; (_)] = [1; (((((_)))))]; | ||
| ^^^ | ||
| | ||
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information | ||
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: using `_` for array lengths is unstable | ||
--> $DIR/parend_infer.rs:17:28 | ||
| | ||
LL | let b: [u8; (_)] = [1; (((((_)))))]; | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information | ||
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
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 |
---|---|---|
@@ -1,12 +1,30 @@ | ||
//@ check-pass | ||
//@[gate] check-pass | ||
//@ revisions: gate nogate | ||
#![cfg_attr(gate, feature(generic_arg_infer))] | ||
|
||
struct Foo<const N: usize>; | ||
|
||
fn main() { | ||
// AST Types preserve parens for pretty printing reasons. This means | ||
// that this is parsed as a `TyKind::Paren(TyKind::Infer)`. Generic | ||
// arg lowering therefore needs to take into account not just `TyKind::Infer` | ||
// but `TyKind::Infer` wrapped in arbitrarily many `TyKind::Paren`. | ||
let a: Vec<(_)> = vec![1_u8]; | ||
let a: Vec<(((((_)))))> = vec![1_u8]; | ||
|
||
// AST Exprs similarly preserve parens for pretty printing reasons. | ||
#[rustfmt::skip] | ||
let b: [u8; (_)] = [1; (((((_)))))]; | ||
//[nogate]~^ error: using `_` for array lengths is unstable | ||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rustfmt wipes nested parenthesis in expressions so in order to make sure people dont accidentally format away part of the test.. |
||
//[nogate]~| error: using `_` for array lengths is unstable | ||
let b: [u8; 2] = b; | ||
|
||
// This is the same case as AST types as the parser doesn't distinguish between const | ||
// and type args when they share syntax | ||
let c: Foo<_> = Foo::<1>; | ||
//[nogate]~^ error: const arguments cannot yet be inferred with `_` | ||
let c: Foo<(_)> = Foo::<1>; | ||
//[nogate]~^ error: const arguments cannot yet be inferred with `_` | ||
let c: Foo<(((_)))> = Foo::<1>; | ||
//[nogate]~^ error: const arguments cannot yet be inferred with `_` | ||
} |
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.