diff options
| author | bors <bors@rust-lang.org> | 2024-05-30 08:00:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-30 08:00:11 +0000 |
| commit | d43930dab36b81267d436fd16066419d3a66e054 (patch) | |
| tree | 1bf06acd6872904d9bc1899203d8145642dddbef /tests/ui/inline-const | |
| parent | 32a3ed229caaaa6476ee1b0e644dd53579454536 (diff) | |
| parent | a34c26e7ecfbfe3f4fd5fbd4868a0cba5676e6a5 (diff) | |
| download | rust-d43930dab36b81267d436fd16066419d3a66e054.tar.gz rust-d43930dab36b81267d436fd16066419d3a66e054.zip | |
Auto 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/ui/inline-const')
| -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`. |
