Skip to content

fix the suggestion of format for asm_sub_register #101253

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

lyming2007
Copy link

modified:   compiler/rustc_typeck/src/check/intrinsicck.rs
modified:   src/test/ui/asm/bad-template.aarch64_mirunsafeck.stderr
modified:   src/test/ui/asm/bad-template.aarch64_thirunsafeck.stderr
modified:   src/test/ui/asm/bad-template.x86_64_mirunsafeck.stderr
modified:   src/test/ui/asm/bad-template.x86_64_thirunsafeck.stderr
modified:   src/test/ui/asm/type-check-1.rs
modified:   src/test/ui/asm/type-check-1.stderr
modified:   src/test/ui/asm/x86_64/type-check-3.stderr

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 31, 2022
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 31, 2022
@rust-log-analyzer

This comment has been minimized.

@davidtwco
Copy link
Member

r? @Amanieu

@rust-highfive rust-highfive assigned Amanieu and unassigned davidtwco Sep 1, 2022
));
err.help(&format!(
"or use the `{default_modifier}` modifier to keep the default formatting of `{default_result}`",
"or use the `0:{default_modifier}` modifier to keep the default formatting of `{default_result}`",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"or use the `0:{default_modifier}` modifier to keep the default formatting of `{default_result}`",
"or use `0:{default_modifier}` to keep the default formatting of `{default_result}`",

@rust-log-analyzer

This comment has been minimized.

@lyming2007
Copy link
Author

@Amanieu Could you help me take a look at CI?
It always complains no such file:

The job x86_64-gnu-llvm-13 failed! Check out the build log: [(web)](https://github.com/rust-lang/rust/runs/8209338744?check_suite_focus=true) [(plain)](https://github.com/rust-lang/rust/commit/aa662c2ee0ab30df02114622ee3f5e9508814c9e/checks/8209338744/logs)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] src/test/ui/asm/[type-check-1.rs](http://type-check-1.rs/) stdout ----
diff of stderr:

96    |
97    = note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
- warning: formatting may not be suitable for sub-register argument
-   --> $DIR/type-check-1.rs:67:27
-    |
-    |
- LL |         asm!( "movd xmm0, {0}", in(reg) val, out("xmm0") _,);
-    |                           ^^^           --- for this argument
-    |
-    = note: `#[warn(asm_sub_register)]` on by default
-    = help: use `0:e` modifier to have the register formatted as `eax`
-    = help: or use `0:r` modifier to keep the default formatting of `rax`

But I have checked in the type-check-1.stderr:

 99 warning: formatting may not be suitable for sub-register argument
100   --> $DIR/type-check-1.rs:67:27
101    |
102 LL |         asm!( "movd xmm0, {0}", in(reg) val, out("xmm0") _,);
103    |                           ^^^           --- for this argument
104    |
105    = note: `#[warn(asm_sub_register)]` on by default
106    = help: use `0:e` modifier to have the register formatted as `eax`
107    = help: or use `0:r` modifier to keep the default formatting of `rax`

@rust-log-analyzer

This comment has been minimized.

@Amanieu
Copy link
Member

Amanieu commented Sep 7, 2022

Try putting it in type-check-3.rs instead of type-check-1.rs.

@Amanieu
Copy link
Member

Amanieu commented Sep 7, 2022

Actually we already have checks for this lint in type-check-3.rs, you don't need to add a new case.

@Amanieu
Copy link
Member

Amanieu commented Sep 7, 2022

The stderr file for aarch64 also needs to be updated, otherwise CI will fail.

./x.py test src/test/ui --test-args asm/aarch64/type-check-3.rs --target aarch64-unknown-linux-gnu --bless

@lyming2007
Copy link
Author

The stderr file for aarch64 also needs to be updated, otherwise CI will fail.

./x.py test src/test/ui --test-args asm/aarch64/type-check-3.rs --target aarch64-unknown-linux-gnu --bless

Already did. Now CI passed. Thank you for your suggestions.

@Amanieu
Copy link
Member

Amanieu commented Sep 7, 2022

No, the file still has the old error messages: https://github.com/lyming2007/rust/blob/issue-101163/src/test/ui/asm/aarch64/type-check-3.stderr#L62

You need to run this command (note the --target aarch64-unknown-linux-gnu):

./x.py test src/test/ui --test-args asm/aarch64/type-check-3.rs --target aarch64-unknown-linux-gnu --bless

@lyming2007
Copy link
Author

No, the file still has the old error messages: https://github.com/lyming2007/rust/blob/issue-101163/src/test/ui/asm/aarch64/type-check-3.stderr#L62

You need to run this command (note the --target aarch64-unknown-linux-gnu):

./x.py test src/test/ui --test-args asm/aarch64/type-check-3.rs --target aarch64-unknown-linux-gnu --bless

done

Copy link
Member

@Amanieu Amanieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest some minor changes to make the message more readable.

@@ -333,10 +333,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
let mut err = lint.build(msg);
err.span_label(expr.span, "for this argument");
err.help(&format!(
"use the `{suggested_modifier}` modifier to have the register formatted as `{suggested_result}`",
"use `{idx}:{suggested_modifier}` modifier to have the register formatted as `{suggested_result}`",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"use `{idx}:{suggested_modifier}` modifier to have the register formatted as `{suggested_result}`",
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}`",

));
err.help(&format!(
"or use the `{default_modifier}` modifier to keep the default formatting of `{default_result}`",
"or use `{idx}:{default_modifier}` modifier to keep the default formatting of `{default_result}`",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"or use `{idx}:{default_modifier}` modifier to keep the default formatting of `{default_result}`",
"or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}`",

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.
Fix was pushed

	modified:   compiler/rustc_typeck/src/check/intrinsicck.rs
	modified:   src/test/ui/asm/bad-template.aarch64_mirunsafeck.stderr
	modified:   src/test/ui/asm/bad-template.aarch64_thirunsafeck.stderr
	modified:   src/test/ui/asm/bad-template.x86_64_mirunsafeck.stderr
	modified:   src/test/ui/asm/bad-template.x86_64_thirunsafeck.stderr
	modified:   src/test/ui/asm/type-check-1.rs
	modified:   src/test/ui/asm/type-check-1.stderr
	modified:   src/test/ui/asm/x86_64/type-check-3.stderr
@Amanieu
Copy link
Member

Amanieu commented Sep 8, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 8, 2022

📌 Commit 28c62d2 has been approved by Amanieu

It is now in the queue for this repository.

@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 8, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 9, 2022
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#99207 (Enable eager checks for memory sanitizer)
 - rust-lang#101253 (fix the suggestion of format for asm_sub_register)
 - rust-lang#101450 (Add `const_extern_fn` to 1.62 release notes.)
 - rust-lang#101556 (Tweak future opaque ty pretty printing)
 - rust-lang#101563 (Link UEFI target documentation from target list)
 - rust-lang#101593 (Cleanup themes (tooltip))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0354eee into rust-lang:master Sep 9, 2022
@rustbot rustbot added this to the 1.65.0 milestone Sep 9, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants