Closed
Description
Code
const FOO: *const u32 = {
let x;
&x
};
fn main() {
let FOO = FOO;
}
Meta
rustc --version --verbose
:
rustc 1.49.0-nightly (4f7612ac1 2020-10-31)
binary: rustc
commit-hash: 4f7612ac1499258025077f1fd05d2f429f9accfb
commit-date: 2020-10-31
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
Error output
error[E0381]: borrow of possibly-uninitialized variable: `x`
--> reduced_mutant.rs:3:5
|
3 | &x
| ^^ use of possibly-uninitialized `x`
error: encountered dangling pointer in final constant
--> reduced_mutant.rs:1:1
|
1 | / const FOO: *const u32 = {
2 | | let x;
3 | | &x
4 | | };
| |__^
error[E0005]: refutable pattern in local binding: `_` not covered
--> reduced_mutant.rs:6:9
|
1 | / const FOO: *const u32 = {
2 | | let x;
3 | | &x
4 | | };
| |__- constant defined here
5 | fn main() {
6 | let FOO = FOO;
| ^^^
| |
| interpreted as a constant pattern, not a new variable
| help: introduce a variable instead: `foo_var`
|
= note: the matched value is of type `*const u32`
error: internal compiler error: compiler/rustc_middle/src/mir/mod.rs:2306:49: could not find allocation for alloc1
thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:942:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: the compiler unexpectedly panicked. this is a bug.
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: rustc 1.49.0-nightly (4f7612ac1 2020-10-31) 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
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0005, E0381.
For more information about an error, try `rustc --explain E0005`.
Backtrace
thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:942:9
stack backtrace:
0: std::panicking::begin_panic
1: rustc_errors::HandlerInner::bug
2: rustc_errors::Handler::bug
3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
4: rustc_middle::ty::context::tls::with_opt::{{closure}}
5: rustc_middle::ty::context::tls::with_opt
6: rustc_middle::util::bug::opt_span_bug_fmt
7: rustc_middle::util::bug::bug_fmt
8: rustc_middle::mir::Constant::check_static_ptr
9: <rustc_mir::borrow_check::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_constant
10: rustc_middle::mir::visit::Visitor::super_rvalue
11: <rustc_mir::borrow_check::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
12: rustc_mir::borrow_check::type_check::type_check
13: rustc_mir::borrow_check::nll::compute_regions
14: rustc_mir::borrow_check::do_mir_borrowck
15: rustc_infer::infer::InferCtxtBuilder::enter
16: rustc_mir::borrow_check::mir_borrowck
17: core::ops::function::FnOnce::call_once
18: 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
19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
20: rustc_data_structures::stack::ensure_sufficient_stack
21: rustc_query_system::query::plumbing::get_query_impl
22: rustc_query_system::query::plumbing::ensure_query_impl
23: rustc_interface::passes::analysis
24: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
25: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
26: rustc_data_structures::stack::ensure_sufficient_stack
27: rustc_query_system::query::plumbing::get_query_impl
28: rustc_interface::passes::QueryContext::enter
29: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
30: rustc_span::with_source_map
31: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Category: This is a bug.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.