diff options
| author | Eric Huss <eric@huss.org> | 2021-09-29 19:33:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-29 19:33:39 -0700 |
| commit | c5f8675291de47c5a189b750feb8cd2c3fef6f73 (patch) | |
| tree | ded416035cfedbef2b5a38990a41c7023d293c4b /src/test/ui/asm | |
| parent | 8dfe52293a61aaa4ff44b20d538c52ddc7834617 (diff) | |
| parent | cd0873b50276bca8bfcaf8d12beeb28d3fffb692 (diff) | |
Rollup merge of #89311 - FabianWolff:issue-89305, r=oli-obk
Add unit assignment to MIR for `asm!()` Fixes #89305. `ExprKind::LlvmInlineAsm` gets a `push_assign_unit()` here: https://github.com/rust-lang/rust/blob/2b6ed3b675475abc01ce7e68bb75b457f0c85684/compiler/rustc_mir_build/src/build/expr/into.rs#L475-L479 The same should probably happen for `ExprKind::InlineAsm`, which fixes the "use of possibly-uninitialized variable" error described in #89305.
Diffstat (limited to 'src/test/ui/asm')
| -rw-r--r-- | src/test/ui/asm/issue-89305.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/asm/issue-89305.stderr | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/asm/issue-89305.rs b/src/test/ui/asm/issue-89305.rs new file mode 100644 index 00000000000..bdcf3f305eb --- /dev/null +++ b/src/test/ui/asm/issue-89305.rs @@ -0,0 +1,14 @@ +// Regression test for #89305, where a variable was erroneously reported +// as both unused and possibly-uninitialized. + +// check-pass + +#![feature(asm)] +#![warn(unused)] + +fn main() { + unsafe { + let x: () = asm!("nop"); + //~^ WARNING: unused variable: `x` + } +} diff --git a/src/test/ui/asm/issue-89305.stderr b/src/test/ui/asm/issue-89305.stderr new file mode 100644 index 00000000000..9cc127b44d0 --- /dev/null +++ b/src/test/ui/asm/issue-89305.stderr @@ -0,0 +1,15 @@ +warning: unused variable: `x` + --> $DIR/issue-89305.rs:11:13 + | +LL | let x: () = asm!("nop"); + | ^ help: if this is intentional, prefix it with an underscore: `_x` + | +note: the lint level is defined here + --> $DIR/issue-89305.rs:7:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` + +warning: 1 warning emitted + |
