Skip to content
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

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

Merged
merged 1 commit into from
Sep 11, 2021

Conversation

Amanieu
Copy link
Member

@Amanieu Amanieu commented Aug 21, 2021

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

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2021
@inquisitivecrystal inquisitivecrystal 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, which will review and decide on the PR/issue. labels Aug 24, 2021
@Amanieu
Copy link
Member Author

Amanieu commented Sep 9, 2021

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned matthewjasper Sep 9, 2021
@nagisa
Copy link
Member

nagisa commented Sep 10, 2021

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
Copy link
Contributor

bors commented Sep 10, 2021

📌 Commit 4d6bfde has been approved by nagisa

@bors
Copy link
Contributor

bors commented Sep 10, 2021

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

@bors bors 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
Copy link
Member

nagisa commented Sep 10, 2021

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");
                return Err(err);
            }
            let expr = p.parse_expr()?;

into a parse_asm_input_operand method or somesuch.

@estebank
Copy link
Contributor

@nagisa weird

} else if self.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).
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:master Sep 11, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants