-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Passing an ExprKind::Assign
to a function should specify that rust does not have named arguments
#115192
Comments
@Centri3 How do we target the [PS: Issue was resolved via zulip] |
@rustbot claim |
@Rajveer100 rustup toolchain link dev ./build/aarch64-apple-darwin/stage1/
RUST_BACKTRACE=1 rustc +dev {{FILE}} If you use |
@chenyukang |
Backtrace for the issue: BACKTRACE
|
Be aware that this can't be handled in the parser because this is syntactically supported. |
@estebank Could you let me know the Also, as an improvement, we could also consider Let me know what you think. PS: Just noticed, the |
@Rajveer100 this will actually be slightly difficult to handle (due to the case I mentioned in my previous comment). What you'd have to do is modify the parser to detect this (effectively, track that you've started to parse a function or method call, that you're directly parsing an expression that's meant to be an argument), keep that data around in a side-channel, some |
error[E0425]: cannot find value `x` in this scope
--> debug.rs:12:7
|
1 | fn a(x: u32, y: u32) {}
| -------------------- similarly named function `a` defined here
...
12 | a(x = x_2, y = y_2);
| ^ help: a function with a similar name exists: `a`
-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:428:39 Backtrace
|
You mean to say we need to add an additional field in the Probably this place: #[derive(Clone)]
pub struct Parser<'a> {
pub sess: &'a ParseSess,
/// The current token.
pub token: Token,
/// The spacing for the current token.
pub token_spacing: Spacing,
/// The previous token.
pub prev_token: Token,
pub capture_cfg: bool,
restrictions: Restrictions,
expected_tokens: Vec<TokenType>,
token_cursor: TokenCursor,
... |
Yeah, you could add it to |
Could you describe how we would store the data using I see this, do we need an additional field here as well and what type would it have, probably pub(crate) struct ParseSess {
parse_sess: RawParseSess,
ignore_path_set: Lrc<IgnorePathSet>,
can_reset_errors: Lrc<AtomicBool>,
} |
@estebank let open_paren = self.token.span; Is this essentially the tokenizer's Which token would be checked here for the function parameter, so I can store it, also once that's done, where is the resolve and diagnostic done do I can retrieve my side-channel data and throw a single error? |
No, I think this can be done entirely in |
Yeah, I have found the locations for this, for the parent part, do we do something like this: if let Some(Expr { _: ExprKind::MethodCall(_, ..), .. }) = self.parent <--?? { Also, the |
Code
Current output
Desired output
Rationale and extra context
For somebody new to rust, it may not be immediately clear why this doesn't work, or why it's
()
. We'd ideally guide them in the right direction if lhs' name is the same as that parameter.I think we only need to do this for the two above cases (where lhs doesn't exist or it does, but the type is wrong)
If the correct type happens to be
()
, this could probably be a clippy lint.Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: