Closed
Description
Given the following code:
fn uwu(val: i32) {}
fn main() {
let x = 1_i32;
uwu(val: x);
}
The current output is:
error[E0425]: cannot find value `val` in this scope
--> src/main.rs:5:9
|
5 | uwu(val: x);
| ^^^ expecting a type here because of type ascription
error[E0573]: expected type, found local variable `x`
--> src/main.rs:5:14
|
5 | uwu(val: x);
| ^ expecting a type here because of type ascription
Ideally the output should look like it does when value
is a literal, like an integer, float, or string literal
error: invalid `struct` delimiters or `fn` call arguments
--> src/main.rs:5:5
|
5 | uwu(val: x);
| ^^^^^^^^^^^^^^^
|
help: if `uwu` is a struct, use braces as delimiters
|
5 | uwu { val: x };
| ~ ~
help: if `uwu` is a function, use the arguments directly
|
5 - uwu(val: x);
5 + uwu(x);
|
Diagnostics reproduce on all of current stable, beta, and nightly:
Stable 1.66.0
Beta 1.67.0-beta.2
Nightly 1.68.0 2022-12-15
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Noratrieb commentedon Dec 17, 2022
No one should attempt to fix this until my PR where I remove type ascription.
fmease commentedon Dec 23, 2022
fmease commentedon May 3, 2023
Unblocked by #109128.
@rustbot label -S-blocked
jieyouxu commentedon May 30, 2023
On beta it seems to be fixed?
Noratrieb commentedon May 31, 2023
Tests:
rust/tests/ui/parser/recover-from-bad-variant.rs
Line 8 in 617d3d6
rust/tests/ui/parser/issues/issue-111416.rs
Line 2 in 617d3d6
rust/tests/ui/parser/issues/issue-34255-1.rs
Line 7 in 617d3d6