Closed
Description
I compiled the following code expecting some sort of error message. Instead, the compiler panicked unexpectedly. (Playground)
fn main() {
let x = String::from("foo");
let x_ref = &x;
let x_ref_ref = &x_ref;
x_ref.push_str("bar");
println!("{}", x_ref_ref);
}
cargo run
errors:
Compiling hello v0.1.0 (/home/vagrant/hello)
thread 'rustc' panicked at 'no entry found for key', src/libcore/option.rs:1034:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a 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.35.0 (3c235d560 2019-05-20) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `hello`.
To learn more, run the command again with --verbose.
RUST_BACKTRACE=1 cargo run --verbose
errors:
Compiling hello v0.1.0 (/home/vagrant/hello)
Running `rustc --edition=2018 --crate-name hello src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=3088e465bdea9221 -C extra-filename=-3088e465bdea9221 --out-dir /home/vagrant/hello/ta
rget/debug/deps -C incremental=/home/vagrant/hello/target/debug/incremental -L dependency=/home/vagrant/hello/target/debug/deps`
thread 'rustc' panicked at 'no entry found for key', src/libcore/option.rs:1034:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print [0/372]
at src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:197
3: std::panicking::default_hook
at src/libstd/panicking.rs:211
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
6: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:381
7: rust_begin_unwind
at src/libstd/panicking.rs:308
8: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
9: core::option::expect_failed
at src/libcore/option.rs:1034
10: rustc_mir::borrow_check::path_utils::each_borrow_involving_path
11: rustc_mir::borrow_check::MirBorrowckCtxt::access_place
12: <rustc_mir::borrow_check::MirBorrowckCtxt as rustc_mir::dataflow::DataflowResultsConsumer>::visit_statement_entry
13: rustc_mir::borrow_check::do_mir_borrowck
14: rustc::ty::context::GlobalCtxt::enter_local
15: rustc_mir::borrow_check::mir_borrowck
16: rustc::ty::query::__query_compute::mir_borrowck
17: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
18: rustc::dep_graph::graph::DepGraph::with_task_impl
19: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
20: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
21: rustc::util::common::time
22: rustc_interface::passes::analysis
23: rustc::ty::query::__query_compute::analysis
24: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
25: rustc::dep_graph::graph::DepGraph::with_task_impl
26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
27: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
28: rustc_interface::passes::create_global_ctxt::{{closure}}
29: rustc_interface::interface::run_compiler_in_existing_thread_pool
30: std::thread::local::LocalKey<T>::with
31: scoped_tls::ScopedKey<T>::set
32: syntax::with_globals
query stack during panic:
#0 [mir_borrowck] processing `main`
#1 [analysis] running analysis passes on this crate
end of query stack
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.35.0 (3c235d560 2019-05-20) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `hello`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name hello src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=3088e465bdea9221 -C extra-filename=-3088e465bdea9221 --out-dir /home/vagrant/hello/target/debug/deps -C incremental=/home/vagrant/hello/target/debug/incremental -L dependency=/home/vagrant/hello/target/debug/deps` (exit code: 101)
rustc --version --verbose
:
rustc 1.35.0 (3c235d560 2019-05-20)
binary: rustc
commit-hash: 3c235d5600393dfe6c36eeed34042efad8d4f26e
commit-date: 2019-05-20
host: x86_64-unknown-linux-gnu
release: 1.35.0
LLVM version: 8.0