diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-05-30 10:23:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-30 10:23:07 +0200 |
| commit | 7ed5d469e8dac6a7381cd7300d0b420c5f0bf4c1 (patch) | |
| tree | bd37c28651c69bb73cbeca955b43f6b64a6fd7bf /tests | |
| parent | 70e7b49cf225f0036861a7e530a37300fc609986 (diff) | |
| parent | a34c26e7ecfbfe3f4fd5fbd4868a0cba5676e6a5 (diff) | |
| download | rust-7ed5d469e8dac6a7381cd7300d0b420c5f0bf4c1.tar.gz rust-7ed5d469e8dac6a7381cd7300d0b420c5f0bf4c1.zip | |
Rollup merge of #125711 - oli-obk:const_block_ice2, r=Nadrieril
Make `body_owned_by` return the `Body` instead of just the `BodyId` fixes #125677 Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly. This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too. I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/inline-const/uninit_local.rs | 6 | ||||
| -rw-r--r-- | tests/ui/inline-const/uninit_local.stderr | 16 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/inline-const/uninit_local.rs b/tests/ui/inline-const/uninit_local.rs new file mode 100644 index 00000000000..548c053affc --- /dev/null +++ b/tests/ui/inline-const/uninit_local.rs @@ -0,0 +1,6 @@ +fn main() { + let _my_usize = const { + let x: bool; + while x {} //~ ERROR: `x` isn't initialized + }; +} diff --git a/tests/ui/inline-const/uninit_local.stderr b/tests/ui/inline-const/uninit_local.stderr new file mode 100644 index 00000000000..37b78e337e7 --- /dev/null +++ b/tests/ui/inline-const/uninit_local.stderr @@ -0,0 +1,16 @@ +error[E0381]: used binding `x` isn't initialized + --> $DIR/uninit_local.rs:4:15 + | +LL | let x: bool; + | - binding declared here but left uninitialized +LL | while x {} + | ^ `x` used here but it isn't initialized + | +help: consider assigning a value + | +LL | let x: bool = false; + | +++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0381`. |
