Repository navigation
Unwrap on a None in librustc_mir/borrow_check/region_infer when using rustc_args_required_const #74599
Copy link
Copy link
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.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.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Description
Code
Minimization by @Kixiron
#![feature(rustc_attrs)]
extern "C" {
#[rustc_args_required_const(0, 1)]
pub fn print_raw(data: *const u8, len: usize);
}
pub enum Stmt {
Print {},
Let {},
Loop {}
}
pub fn interpret() {
match (Stmt::Print {}) {
Stmt::Let {} => {
[()].iter().find(|v| *v == &());
}
Stmt::Print {} => {
print_raw(b"hello".as_ptr(), 5);
}
Stmt::Loop {} => {}
}
}Meta
This can only be built on nightly, since it requires an internal rustc attribute on print_raw.
rustc +nightly --version --verbose:
rustc 1.46.0-nightly (346aec9b0 2020-07-11)
binary: rustc
commit-hash: 346aec9b02f3c74f3fce97fd6bda24709d220e49
commit-date: 2020-07-11
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
Error output
When run with RUST_BACKTRACE=1 rustc +nightly main.rs
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/librustc_mir/borrow_check/region_infer/mod.rs:2109:35
stack backtrace:
<... shown below ...>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.46.0-nightly (346aec9b0 2020-07-11) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
Backtrace
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1076
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1537
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:198
9: std::panicking::default_hook
at src/libstd/panicking.rs:217
10: rustc_driver::report_ice
11: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:530
12: rust_begin_unwind
at src/libstd/panicking.rs:437
13: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
14: core::panicking::panic
at src/libcore/panicking.rs:50
15: rustc_mir::borrow_check::region_infer::RegionInferenceContext::find_outlives_blame_span
16: rustc_mir::borrow_check::do_mir_borrowck
17: rustc_infer::infer::InferCtxtBuilder::enter
18: rustc_mir::borrow_check::mir_borrowck
19: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
21: rustc_query_system::query::plumbing::get_query_impl
22: rustc_query_system::query::plumbing::ensure_query_impl
23: rustc_session::utils::<impl rustc_session::session::Session>::time
24: rustc_interface::passes::analysis
25: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
26: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
27: rustc_query_system::query::plumbing::get_query_impl
28: rustc_middle::ty::context::tls::enter_global
29: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
30: rustc_span::with_source_map
31: rustc_interface::interface::create_compiler_and_run
32: scoped_tls::ScopedKey<T>::set
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.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.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Activity
Kixiron commentedon Jul 21, 2020
The absolute smallest I was able to get it is this (playground)
The specific external function doesn't seem to matter, nor do any variable names
The panicking line of code is here, as the comment above it says, "Maybe everything is in the same SCC or something?"
mibac138 commentedon Jul 21, 2020
Further minimized (playground)minimized the wrong ICE, see here for correct minimization or see #74608 for bug report.It appears this issue happens when in
#[rustc_args_required_const(x)],xis greater than the amount of a function's parametersSuperTails commentedon Jul 21, 2020
But in the original example, that's not true--
There are two parameters, and in the code I use both of them, yet the issue still seems to occur.
Same outcome, different cause?
mibac138 commentedon Jul 21, 2020
I might've worded my response poorly, however I still stand my ground. I believe that whenever any of the indexes in
rustc_args_required_constexceeds the amount of parameters a function has, it will ICE. So, for exampleDoes this match with your experience?
Kixiron commentedon Jul 21, 2020
This ICE's, it's the original example
The indices line up with the function parameters, yet it still ICE's
mibac138 commentedon Jul 21, 2020
Oh sorry, turns out I have misunderstood what @SuperTails meant. I guess I have accidentally found another ICE then.
Edit: A bit minimized example this time of the correct ICE (playground)
isabelmu commentedon Jan 22, 2021
The snippet in the original report starts ICE'ing on
nightly-2019-10-05. Tracked it down to 2180c24. (EDIT: same for the minimized example.)Alexendoo commentedon May 14, 2021
rustc_args_required_consthas been removed - #85110