fn temp() -> (String, i32) {
(String::from("Hello"), 1)
}
fn main() {
let f = if true { &temp() } else { &temp() };
}
original:
//@ check-pass
fn temp() -> (String, i32) {
(String::from("Hello"), 1)
}
fn main() {
let a = &temp();
let b = [(&temp(),)];
let c = &temp().0;
let d = &temp().0[..];
let e = {
let _ = 123;
&(*temp().0)[..]
};
let f = if true {
&temp()
} else {
&temp()
};
let g = match true {
true => &temp(),
false => {
let _ = 123;
&temp()
}
};
let h = match temp() {
// The {} moves the value, making a new temporary.
owned_non_temporary => &{ owned_non_temporary },
};
println!("{a:?} {b:?} {c:?} {d:?} {e:?} {f:?} {g:?} {h:?}");
}
auto-reduced (treereduce-rust):
original:
Version information
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zlint-mir
Program output (trimmed)
``` warning: unused variable: `f` --> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:6:9 | 6 | let f = if true { &temp() } else { &temp() }; | ^ help: if this is intentional, prefix it with an underscore: `_f` | = note: `#[warn(unused_variables)]` on by default warning: 1 warning emitted note: no errors encountered even though delayed bugs were created note: those delayed bugs will now be shown as internal compiler errors error: internal compiler error: broken MIR in Item(DefId(0:4 ~ mvce[22c9]::main)) (after pass CheckPackedRef) at bb6[3]: use of local _5, which has no storage here --> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1 | 7 | } | ^ | note: delayed at compiler/rustc_mir_transform/src/lint.rs:75:22 0:::emit_diagnostic
1: ::emit_diagnostic
2: ::emit_producing_guarantee
3: ::fail::
4: ::visit_local
5: ::visit_place
6: ::visit_terminator
7: rustc_mir_transform::lint::lint_body
8: rustc_mir_transform::pass_manager::run_passes_inner
9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
10: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
11: rustc_query_impl::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
12: rustc_mir_build::check_unsafety::check_unsafety
13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
14: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
15: rustc_query_impl::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
16: rustc_interface::passes::analysis
17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
18: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
19: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
20: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
21: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
22: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
23: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
24: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
25: std::sys::pal::unix::thread::Thread::new::thread_start
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/std/src/sys/pal/unix/thread.rs:108:17
26:
27:
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
error: internal compiler error: broken MIR in Item(DefId(0:4 ~ mvce[22c9]::main)) (after pass CheckPackedRef) at bb9[0]:
use of local _3, which has no storage here
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
|
note: delayed at compiler/rustc_mir_transform/src/lint.rs:75:22
0: ::emit_diagnostic
1: ::emit_diagnostic
2: ::emit_producing_guarantee
3: ::fail::
4: ::visit_local
5: ::visit_place
6: ::visit_terminator
7: rustc_mir_transform::lint::lint_body
8: rustc_mir_transform::pass_manager::run_passes_inner
9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
10: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
11: rustc_query_impl::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
12: rustc_mir_build::check_unsafety::check_unsafety
13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
14: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
15: rustc_query_impl::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
16: rustc_interface::passes::analysis
17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
18: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
19: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
20: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
21: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
22: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
23: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
24: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
25: std::sys::pal::unix::thread::Thread::new::thread_start
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/std/src/sys/pal/unix/thread.rs:108:17
26:
27:
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
error: internal compiler error: broken MIR in Item(DefId(0:4 ~ mvce[22c9]::main)) (after phase change to runtime-post-cleanup) at bb9[0]:
use of local _5, which has no storage here
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
|
note: delayed at compiler/rustc_mir_transform/src/lint.rs:75:22
0: ::emit_diagnostic
1: ::emit_diagnostic
2: ::emit_producing_guarantee
3: ::fail::
4: ::visit_local
5: ::visit_place
6: ::visit_terminator
7: rustc_mir_transform::lint::lint_body
8: rustc_mir_transform::pass_manager::run_passes_inner
9: rustc_mir_transform::mir_drops_elaborated_and_const_checked
10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
11: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
12: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
13: rustc_interface::passes::analysis
14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
15: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
16: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
17: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
18: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
19: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
20: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
21: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
22: std::sys::pal::unix::thread::Thread::new::thread_start
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/std/src/sys/pal/unix/thread.rs:108:17
23:
24:
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
error: internal compiler error: broken MIR in Item(DefId(0:4 ~ mvce[22c9]::main)) (after phase change to runtime-post-cleanup) at bb11[0]:
use of local _3, which has no storage here
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
|
note: delayed at compiler/rustc_mir_transform/src/lint.rs:75:22
0: ::emit_diagnostic
1: ::emit_diagnostic
2: ::emit_producing_guarantee
3: ::fail::
4: ::visit_local
5: ::visit_place
6: ::visit_terminator
7: rustc_mir_transform::lint::lint_body
8: rustc_mir_transform::pass_manager::run_passes_inner
9: rustc_mir_transform::mir_drops_elaborated_and_const_checked
10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
11: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
12: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
13: rustc_interface::passes::analysis
14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
15: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
16: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
17: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
18: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
19: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
20: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
21: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
22: std::sys::pal::unix::thread::Thread::new::thread_start
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/std/src/sys/pal/unix/thread.rs:108:17
23:
24:
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
error: internal compiler error: broken MIR in Item(DefId(0:4 ~ mvce[22c9]::main)) (after phase change to runtime-post-cleanup) at bb10[0]:
use of local _3, which has no storage here
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
|
note: delayed at compiler/rustc_mir_transform/src/lint.rs:75:22
0: ::emit_diagnostic
1: ::emit_diagnostic
2: ::emit_producing_guarantee
3: ::fail::
4: ::visit_local
5: ::visit_place
6: ::visit_terminator
7: rustc_mir_transform::lint::lint_body
8: rustc_mir_transform::pass_manager::run_passes_inner
9: rustc_mir_transform::mir_drops_elaborated_and_const_checked
10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
11: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
12: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
13: rustc_interface::passes::analysis
14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::>
15: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
16: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
17: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
18: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
19: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
20: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
21: as core::ops::function::FnOnce>::call_once
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/alloc/src/boxed.rs:2018:9
22: std::sys::pal::unix::thread::Thread::new::thread_start
at /rustc/72fe8a0f0049873f4b1d0ab3c482170921819106/library/std/src/sys/pal/unix/thread.rs:108:17
23:
24:
--> /tmp/icemaker_global_tempdir.1uGEfYPHYLhA/rustc_testrunner_tmpdir_reporting.t0U8tjAY2duj/mvce.rs:7:1
|
7 | }
| ^
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: rustc 1.79.0-nightly (72fe8a0f0 2024-04-11) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z lint-mir -Z dump-mir-dir=dir
query stack during panic:
end of query stack
```