diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-06-11 19:04:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-11 19:04:20 +0200 |
| commit | 8650df5dea7a27852a7fa6bd2585905abb521db7 (patch) | |
| tree | df7e39d8ffe113bd11f9cf75a54bec2157d219b8 /src/test/ui | |
| parent | 6b418b307c0222ecceb3d82b46621a377b592c79 (diff) | |
| parent | ddacc671901359ef1cd95722af0ff23a7ca6e212 (diff) | |
Rollup merge of #73230 - Amanieu:asm-unused2, r=petrochenkov
Suggest including unused asm arguments in a comment to avoid error We require all arguments to an `asm!` to be used in the template string, just like format strings. However in some cases (e.g. `black_box`) it may be desirable to have `asm!` arguments that are not used in the template string. Currently this is a hard error rather than a lint since `#[allow]` does not work on macros (#63221), so this PR suggests using the unused arguments in an asm comment as a workaround. r? @petrochenkov
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/asm/bad-template.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/asm/bad-template.stderr | 18 | ||||
| -rw-r--r-- | src/test/ui/asm/parse-error.stderr | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/test/ui/asm/bad-template.rs b/src/test/ui/asm/bad-template.rs index 0b333eca1ab..21ce8c6236d 100644 --- a/src/test/ui/asm/bad-template.rs +++ b/src/test/ui/asm/bad-template.rs @@ -22,5 +22,7 @@ fn main() { //~^ ERROR invalid reference to argument at index 0 asm!("{:foo}", in(reg) foo); //~^ ERROR asm template modifier must be a single character + asm!("", in(reg) 0, in(reg) 1); + //~^ ERROR multiple unused asm arguments } } diff --git a/src/test/ui/asm/bad-template.stderr b/src/test/ui/asm/bad-template.stderr index 2de76ef8241..1aea7467ed0 100644 --- a/src/test/ui/asm/bad-template.stderr +++ b/src/test/ui/asm/bad-template.stderr @@ -19,6 +19,8 @@ error: argument never used | LL | asm!("{1}", in(reg) foo); | ^^^^^^^^^^^ argument never used + | + = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"` error: there is no argument named `a` --> $DIR/bad-template.rs:13:15 @@ -46,6 +48,8 @@ error: named argument never used | LL | asm!("{}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ named argument never used + | + = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 1 --> $DIR/bad-template.rs:18:15 @@ -60,6 +64,8 @@ error: named argument never used | LL | asm!("{1}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ named argument never used + | + = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 0 --> $DIR/bad-template.rs:21:15 @@ -82,5 +88,15 @@ error: asm template modifier must be a single character LL | asm!("{:foo}", in(reg) foo); | ^^^ -error: aborting due to 10 previous errors +error: multiple unused asm arguments + --> $DIR/bad-template.rs:25:18 + | +LL | asm!("", in(reg) 0, in(reg) 1); + | ^^^^^^^^^ ^^^^^^^^^ argument never used + | | + | argument never used + | + = help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"` + +error: aborting due to 11 previous errors diff --git a/src/test/ui/asm/parse-error.stderr b/src/test/ui/asm/parse-error.stderr index fa422f56bec..583a1057036 100644 --- a/src/test/ui/asm/parse-error.stderr +++ b/src/test/ui/asm/parse-error.stderr @@ -127,6 +127,8 @@ error: argument never used | LL | asm!("{a}", a = const foo, a = const bar); | ^^^^^^^^^^^^^ argument never used + | + = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: explicit register arguments cannot have names --> $DIR/parse-error.rs:47:18 |
