Skip to content

Commit 0354eee

Browse files
authored
Rollup merge of #101253 - lyming2007:issue-101163, r=Amanieu
fix the suggestion of format for asm_sub_register 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
2 parents 6d20335 + 28c62d2 commit 0354eee

7 files changed

+38
-38
lines changed

compiler/rustc_typeck/src/check/intrinsicck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
333333
let mut err = lint.build(msg);
334334
err.span_label(expr.span, "for this argument");
335335
err.help(&format!(
336-
"use the `{suggested_modifier}` modifier to have the register formatted as `{suggested_result}`",
336+
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}`",
337337
));
338338
err.help(&format!(
339-
"or use the `{default_modifier}` modifier to keep the default formatting of `{default_result}`",
339+
"or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}`",
340340
));
341341
err.emit();
342342
},

src/test/ui/asm/aarch64/type-check-3.stderr

+20-20
Original file line numberDiff line numberDiff line change
@@ -5,89 +5,89 @@ LL | asm!("{}", in(reg) 0u8);
55
| ^^ --- for this argument
66
|
77
= note: `#[warn(asm_sub_register)]` on by default
8-
= help: use the `w` modifier to have the register formatted as `w0`
9-
= help: or use the `x` modifier to keep the default formatting of `x0`
8+
= help: use `{0:w}` to have the register formatted as `w0`
9+
= help: or use `{0:x}` to keep the default formatting of `x0`
1010

1111
warning: formatting may not be suitable for sub-register argument
1212
--> $DIR/type-check-3.rs:50:15
1313
|
1414
LL | asm!("{}", in(reg) 0u16);
1515
| ^^ ---- for this argument
1616
|
17-
= help: use the `w` modifier to have the register formatted as `w0`
18-
= help: or use the `x` modifier to keep the default formatting of `x0`
17+
= help: use `{0:w}` to have the register formatted as `w0`
18+
= help: or use `{0:x}` to keep the default formatting of `x0`
1919

2020
warning: formatting may not be suitable for sub-register argument
2121
--> $DIR/type-check-3.rs:52:15
2222
|
2323
LL | asm!("{}", in(reg) 0i32);
2424
| ^^ ---- for this argument
2525
|
26-
= help: use the `w` modifier to have the register formatted as `w0`
27-
= help: or use the `x` modifier to keep the default formatting of `x0`
26+
= help: use `{0:w}` to have the register formatted as `w0`
27+
= help: or use `{0:x}` to keep the default formatting of `x0`
2828

2929
warning: formatting may not be suitable for sub-register argument
3030
--> $DIR/type-check-3.rs:54:15
3131
|
3232
LL | asm!("{}", in(reg) 0f32);
3333
| ^^ ---- for this argument
3434
|
35-
= help: use the `w` modifier to have the register formatted as `w0`
36-
= help: or use the `x` modifier to keep the default formatting of `x0`
35+
= help: use `{0:w}` to have the register formatted as `w0`
36+
= help: or use `{0:x}` to keep the default formatting of `x0`
3737

3838
warning: formatting may not be suitable for sub-register argument
3939
--> $DIR/type-check-3.rs:57:15
4040
|
4141
LL | asm!("{}", in(vreg) 0i16);
4242
| ^^ ---- for this argument
4343
|
44-
= help: use the `h` modifier to have the register formatted as `h0`
45-
= help: or use the `v` modifier to keep the default formatting of `v0`
44+
= help: use `{0:h}` to have the register formatted as `h0`
45+
= help: or use `{0:v}` to keep the default formatting of `v0`
4646

4747
warning: formatting may not be suitable for sub-register argument
4848
--> $DIR/type-check-3.rs:59:15
4949
|
5050
LL | asm!("{}", in(vreg) 0f32);
5151
| ^^ ---- for this argument
5252
|
53-
= help: use the `s` modifier to have the register formatted as `s0`
54-
= help: or use the `v` modifier to keep the default formatting of `v0`
53+
= help: use `{0:s}` to have the register formatted as `s0`
54+
= help: or use `{0:v}` to keep the default formatting of `v0`
5555

5656
warning: formatting may not be suitable for sub-register argument
5757
--> $DIR/type-check-3.rs:61:15
5858
|
5959
LL | asm!("{}", in(vreg) 0f64);
6060
| ^^ ---- for this argument
6161
|
62-
= help: use the `d` modifier to have the register formatted as `d0`
63-
= help: or use the `v` modifier to keep the default formatting of `v0`
62+
= help: use `{0:d}` to have the register formatted as `d0`
63+
= help: or use `{0:v}` to keep the default formatting of `v0`
6464

6565
warning: formatting may not be suitable for sub-register argument
6666
--> $DIR/type-check-3.rs:63:15
6767
|
6868
LL | asm!("{}", in(vreg_low16) 0f64);
6969
| ^^ ---- for this argument
7070
|
71-
= help: use the `d` modifier to have the register formatted as `d0`
72-
= help: or use the `v` modifier to keep the default formatting of `v0`
71+
= help: use `{0:d}` to have the register formatted as `d0`
72+
= help: or use `{0:v}` to keep the default formatting of `v0`
7373

7474
warning: formatting may not be suitable for sub-register argument
7575
--> $DIR/type-check-3.rs:66:15
7676
|
7777
LL | asm!("{0} {0}", in(reg) 0i16);
7878
| ^^^ ^^^ ---- for this argument
7979
|
80-
= help: use the `w` modifier to have the register formatted as `w0`
81-
= help: or use the `x` modifier to keep the default formatting of `x0`
80+
= help: use `{0:w}` to have the register formatted as `w0`
81+
= help: or use `{0:x}` to keep the default formatting of `x0`
8282

8383
warning: formatting may not be suitable for sub-register argument
8484
--> $DIR/type-check-3.rs:68:15
8585
|
8686
LL | asm!("{0} {0:x}", in(reg) 0i16);
8787
| ^^^ ---- for this argument
8888
|
89-
= help: use the `w` modifier to have the register formatted as `w0`
90-
= help: or use the `x` modifier to keep the default formatting of `x0`
89+
= help: use `{0:w}` to have the register formatted as `w0`
90+
= help: or use `{0:x}` to keep the default formatting of `x0`
9191

9292
error: type `i128` cannot be used with this register class
9393
--> $DIR/type-check-3.rs:73:28

src/test/ui/asm/bad-template.aarch64_mirunsafeck.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ LL | asm!("{:foo}", in(reg) foo);
190190
| ^^^^^^ --- for this argument
191191
|
192192
= note: `#[warn(asm_sub_register)]` on by default
193-
= help: use the `w` modifier to have the register formatted as `w0`
194-
= help: or use the `x` modifier to keep the default formatting of `x0`
193+
= help: use `{0:w}` to have the register formatted as `w0`
194+
= help: or use `{0:x}` to keep the default formatting of `x0`
195195

196196
error: aborting due to 21 previous errors; 1 warning emitted
197197

src/test/ui/asm/bad-template.aarch64_thirunsafeck.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ LL | asm!("{:foo}", in(reg) foo);
190190
| ^^^^^^ --- for this argument
191191
|
192192
= note: `#[warn(asm_sub_register)]` on by default
193-
= help: use the `w` modifier to have the register formatted as `w0`
194-
= help: or use the `x` modifier to keep the default formatting of `x0`
193+
= help: use `{0:w}` to have the register formatted as `w0`
194+
= help: or use `{0:x}` to keep the default formatting of `x0`
195195

196196
error: aborting due to 21 previous errors; 1 warning emitted
197197

src/test/ui/asm/bad-template.x86_64_mirunsafeck.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ LL | asm!("{:foo}", in(reg) foo);
190190
| ^^^^^^ --- for this argument
191191
|
192192
= note: `#[warn(asm_sub_register)]` on by default
193-
= help: use the `e` modifier to have the register formatted as `eax`
194-
= help: or use the `r` modifier to keep the default formatting of `rax`
193+
= help: use `{0:e}` to have the register formatted as `eax`
194+
= help: or use `{0:r}` to keep the default formatting of `rax`
195195

196196
error: aborting due to 21 previous errors; 1 warning emitted
197197

src/test/ui/asm/bad-template.x86_64_thirunsafeck.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ LL | asm!("{:foo}", in(reg) foo);
190190
| ^^^^^^ --- for this argument
191191
|
192192
= note: `#[warn(asm_sub_register)]` on by default
193-
= help: use the `e` modifier to have the register formatted as `eax`
194-
= help: or use the `r` modifier to keep the default formatting of `rax`
193+
= help: use `{0:e}` to have the register formatted as `eax`
194+
= help: or use `{0:r}` to keep the default formatting of `rax`
195195

196196
error: aborting due to 21 previous errors; 1 warning emitted
197197

src/test/ui/asm/x86_64/type-check-3.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,35 @@ LL | asm!("{0} {0}", in(reg) 0i16);
4545
| ^^^ ^^^ ---- for this argument
4646
|
4747
= note: `#[warn(asm_sub_register)]` on by default
48-
= help: use the `x` modifier to have the register formatted as `ax`
49-
= help: or use the `r` modifier to keep the default formatting of `rax`
48+
= help: use `{0:x}` to have the register formatted as `ax`
49+
= help: or use `{0:r}` to keep the default formatting of `rax`
5050

5151
warning: formatting may not be suitable for sub-register argument
5252
--> $DIR/type-check-3.rs:36:15
5353
|
5454
LL | asm!("{0} {0:x}", in(reg) 0i16);
5555
| ^^^ ---- for this argument
5656
|
57-
= help: use the `x` modifier to have the register formatted as `ax`
58-
= help: or use the `r` modifier to keep the default formatting of `rax`
57+
= help: use `{0:x}` to have the register formatted as `ax`
58+
= help: or use `{0:r}` to keep the default formatting of `rax`
5959

6060
warning: formatting may not be suitable for sub-register argument
6161
--> $DIR/type-check-3.rs:38:15
6262
|
6363
LL | asm!("{}", in(reg) 0i32);
6464
| ^^ ---- for this argument
6565
|
66-
= help: use the `e` modifier to have the register formatted as `eax`
67-
= help: or use the `r` modifier to keep the default formatting of `rax`
66+
= help: use `{0:e}` to have the register formatted as `eax`
67+
= help: or use `{0:r}` to keep the default formatting of `rax`
6868

6969
warning: formatting may not be suitable for sub-register argument
7070
--> $DIR/type-check-3.rs:41:15
7171
|
7272
LL | asm!("{}", in(ymm_reg) 0i64);
7373
| ^^ ---- for this argument
7474
|
75-
= help: use the `x` modifier to have the register formatted as `xmm0`
76-
= help: or use the `y` modifier to keep the default formatting of `ymm0`
75+
= help: use `{0:x}` to have the register formatted as `xmm0`
76+
= help: or use `{0:y}` to keep the default formatting of `ymm0`
7777

7878
error: type `i8` cannot be used with this register class
7979
--> $DIR/type-check-3.rs:52:28

0 commit comments

Comments
 (0)