Skip to content

Improve error message when _ is used for in/inout asm operands - #88209

Merged
bors merged 1 commit into
rust-lang:masterfrom
Amanieu:asm_in_underscore
Sep 11, 2021
Merged

Improve error message when _ is used for in/inout asm operands#88209
bors merged 1 commit into
rust-lang:masterfrom
Amanieu:asm_in_underscore

Conversation

@Amanieu

Copy link
Copy Markdown
Member

As suggested by @Commeownist in #72016 (comment).

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2021
@inquisitivecrystalinquisitivecrystal added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-inline-assembly Area: Inline assembly (`asm!(…)`) T-lang Relevant to the language team labels Aug 24, 2021
@Amanieu

Copy link
Copy Markdown
MemberAuthor

r? @nagisa

@nagisa

Copy link
Copy Markdown
Member

This seems like a more general problem plaguing _ uses in an expression position. Like

error[E0658]: destructuring assignments are unstable
--> src/main.rs:3:5
|
3 | _;
| ^
|
= note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
error: in expressions, `_` can only be used on the left-hand side of an assignment
--> src/main.rs:3:5
|
3 | _;
| ^ `_` not allowed here

cc @estebank might be of interest to you.


Overall this seems like a good place to provide asm! specific diagnostic. I would perhaps have chosen to word this as "_ is not a valid input operand" or somesuch, but this seems good regardless.

@bors r+

@bors

bors commented Sep 10, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 4d6bfde has been approved by nagisa

@bors

bors commented Sep 10, 2021

Copy link
Copy Markdown
Collaborator

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2021
@nagisa

nagisa commented Sep 10, 2021

Copy link
Copy Markdown
Member

Ah well, another thing that would be nice is some deduplication. I would perhaps extract

if p.eat_keyword(kw::Underscore){let err = ecx.struct_span_err(p.token.span,"_ cannot be used for input operands");returnErr(err);}let expr = p.parse_expr()?;

into a parse_asm_input_operand method or somesuch.

@estebank

Copy link
Copy Markdown
Contributor

@nagisa weird

}elseifself.eat_keyword(kw::Underscore){
self.sess.gated_spans.gate(sym::destructuring_assignment,self.prev_token.span);
Ok(self.mk_expr(self.prev_token.span,ExprKind::Underscore, attrs))

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 11, 2021
Improve error message when _ is used for in/inout asm operands
As suggested by `@Commeownist` in rust-lang#72016 (comment).
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 11, 2021
Improve error message when _ is used for in/inout asm operands
As suggested by ``@Commeownist`` in rust-lang#72016 (comment).
This was referenced Sep 11, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 11, 2021
…ingjubilee
Rollup of 10 pull requests
Successful merges:
- rust-lang#87904 (Reword description of automatic impls of `Unsize`.)
- rust-lang#88147 (Fix non-capturing closure return type coercion)
- rust-lang#88209 (Improve error message when _ is used for in/inout asm operands)
- rust-lang#88668 (Change more x64 size checks to not apply to x32.)
- rust-lang#88733 (Fix ICE for functions with more than 65535 arguments)
- rust-lang#88757 (Suggest wapping expr in parentheses on invalid unary negation)
- rust-lang#88779 (Use more accurate spans for "unused delimiter" lint)
- rust-lang#88830 (Add help for E0463)
- rust-lang#88849 (don't clone types that are Copy (clippy::clone_on_copy))
- rust-lang#88850 (don't convert types into identical types)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 3af42a8 into rust-lang:masterSep 11, 2021
@rustbotrustbot added this to the 1.57.0 milestone Sep 11, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-inline-assemblyArea: Inline assembly (`asm!(…)`)S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@Amanieu@rust-highfive@nagisa@bors@estebank@matthewjasper@inquisitivecrystal@rustbot