-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-guard_patterns`#![feature(guard_patterns)]``#![feature(guard_patterns)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
auto-reduced (treereduce-rust):
#![feature(guard_patterns)]
fn main() {
match (0,) {
(_ if { let main = false; main },) => {}
_ => {}
}
}
original:
//@ check-pass
//! Test that `GatherLocalsVisitor` only visits expressions in guard patterns when checking the
//! expressions, and not a second time when visiting the pattern. If locals are declared inside the
//! the guard expression, it would ICE if visited twice ("evaluated expression more than once").
#![feature(guard_patterns)]
#![expect(guard_patterns)]
fn main() {
match (0,) {
// FIXME(guard_patterns): liveness lints don't work yet; this will ICE without the `_`.
(_ if { let main = false; main },) => {
match (0,) {
// FIXME(guard_patterns): liveness lints don't work yet; this will ICE without the `_`.
(_ if { let _x = false; _x },) => {}
_ => {}
}
}
_ => {}
}
}
Version information
rustc 1.91.0-nightly (f4665ab83 2025-09-10)
binary: rustc
commit-hash: f4665ab8368ad2e8a86d4390ae35c28bdd9561bb
commit-date: 2025-09-10
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: the feature `guard_patterns` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.lrrS5NseB5VV/rustc_testrunner_tmpdir_reporting.IHAQeISeUx35/mvce.rs:1:12
|
1 | #![feature(guard_patterns)]
| ^^^^^^^^^^^^^^
|
= note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: unreachable pattern
--> /tmp/icemaker_global_tempdir.lrrS5NseB5VV/rustc_testrunner_tmpdir_reporting.IHAQeISeUx35/mvce.rs:6:9
|
5 | (_ if { let main = false; main },) => {}
| ---------------------------------- matches any value
6 | _ => {}
| ^ no value can reach this
|
= note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default
warning: variable `main` is assigned to, but never used
--> /tmp/icemaker_global_tempdir.lrrS5NseB5VV/rustc_testrunner_tmpdir_reporting.IHAQeISeUx35/mvce.rs:5:21
|
5 | (_ if { let main = false; main },) => {}
| ^^^^
|
= note: consider using `_main` instead
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
warning: 3 warnings 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: no successor
|
= note: delayed at compiler/rustc_passes/src/liveness.rs:575:35
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
3: <rustc_passes::liveness::Liveness>::report_unused
4: rustc_hir::intravisit::walk_block::<rustc_passes::liveness::Liveness>
5: <rustc_passes::liveness::Liveness as rustc_hir::intravisit::Visitor>::visit_expr
6: <rustc_passes::liveness::Liveness as rustc_hir::intravisit::Visitor>::visit_pat
7: <rustc_passes::liveness::Liveness as rustc_hir::intravisit::Visitor>::visit_expr
8: rustc_hir::intravisit::walk_block::<rustc_passes::liveness::Liveness>
9: <rustc_passes::liveness::Liveness as rustc_hir::intravisit::Visitor>::visit_expr
10: rustc_passes::liveness::check_liveness
11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_liveness::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 0]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
13: rustc_query_impl::query_impl::check_liveness::get_query_non_incr::__rust_end_short_backtrace
14: rustc_mir_build::builder::build_mir
15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
17: rustc_query_impl::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
18: rustc_mir_build::check_unsafety::check_unsafety
19: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 0]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
21: rustc_query_impl::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
22: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
23: rustc_interface::passes::analysis
24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
26: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
27: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
30: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
31: std::sys::pal::unix::thread::Thread::new::thread_start
32: <unknown>
33: <unknown>
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.91.0-nightly (f4665ab83 2025-09-10) running on x86_64-unknown-linux-gnu
query stack during panic:
end of query stack
@rustbot label +F-guard_patterns
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-guard_patterns`#![feature(guard_patterns)]``#![feature(guard_patterns)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.