diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.stderr | 49 |
2 files changed, 66 insertions, 0 deletions
diff --git a/src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.rs b/src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.rs new file mode 100644 index 00000000000..53dad85900a --- /dev/null +++ b/src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.rs @@ -0,0 +1,17 @@ +fn main() {} + +const FOO: [u8; 3] = { //~ ERROR this code is interpreted as a block expression + 1, 2, 3 +}; + +const BAR: [&str; 3] = {"one", "two", "three"}; +//~^ ERROR this code is interpreted as a block expression + +fn foo() { + {1, 2, 3}; + //~^ ERROR this code is interpreted as a block expression +} + +fn bar() { + 1, 2, 3 //~ ERROR expected one of +} diff --git a/src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.stderr b/src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.stderr new file mode 100644 index 00000000000..9ab491f5c23 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-87830-try-brackets-for-arrays.stderr @@ -0,0 +1,49 @@ +error: this code is interpreted as a block expression, not an array + --> $DIR/issue-87830-try-brackets-for-arrays.rs:3:22 + | +LL | const FOO: [u8; 3] = { + | ______________________^ +LL | | 1, 2, 3 +LL | | }; + | |_^ + | + = note: to define an array, one would use square brackets instead of curly braces +help: try using [] instead of {} + | +LL ~ const FOO: [u8; 3] = [ +LL | 1, 2, 3 +LL ~ ]; + | + +error: this code is interpreted as a block expression, not an array + --> $DIR/issue-87830-try-brackets-for-arrays.rs:7:24 + | +LL | const BAR: [&str; 3] = {"one", "two", "three"}; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: to define an array, one would use square brackets instead of curly braces +help: try using [] instead of {} + | +LL | const BAR: [&str; 3] = ["one", "two", "three"]; + | ~ ~ + +error: this code is interpreted as a block expression, not an array + --> $DIR/issue-87830-try-brackets-for-arrays.rs:11:5 + | +LL | {1, 2, 3}; + | ^^^^^^^^^ + | + = note: to define an array, one would use square brackets instead of curly braces +help: try using [] instead of {} + | +LL | [1, 2, 3]; + | ~ ~ + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` + --> $DIR/issue-87830-try-brackets-for-arrays.rs:16:6 + | +LL | 1, 2, 3 + | ^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: aborting due to 4 previous errors + |
