Repository navigation
Closed
Closed
Copy link
Description
I tried this code:
struct TestStruct<T>(T);
impl<T> TestStruct<T> {
const SOME_CONST: u8 = 1;
fn call(&mut self) {
let item = self.0;
something(&item, &Self::SOME_CONST);
}
}
fn something<T1, T2>(_: T1, _: T2) {
unimplemented!()
}I expected to see this happen: cannot move out of borrowed content for the let item = self.0; line..
Instead, this happened:
thread 'main' panicked at 'assertion failed: !impl_self_ty.has_infer_types()', librustc_mir/borrow_check/nll/type_check/mod.rs:1033:21
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: internal compiler error: unexpected panic
I also tried CARGO_INCREMENTAL=0 but it didn't affect the build (apart from the -C incremental argument to disappear).
My rust version:
rustc 1.31.0-nightly (424a749a0 2018-10-21)
binary: rustc
commit-hash: 424a749a01224239ba2c8850f16007d57db0a242
commit-date: 2018-10-21
host: x86_64-unknown-linux-gnu
release: 1.31.0-nightly
LLVM version: 8.0
Here's a run with backtrace enabled:
Running `rustc --crate-name ice src/lib.rs --color always --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=2a9b80ba2717f3bb -C extra-filename=-2a9b80ba2717f3bb --out-dir /home/mexus/test/rust/ice/target/debug/deps -C incremental=/home/mexus/test/rust/ice/target/debug/incremental -L dependency=/home/mexus/test/rust/ice/target/debug/deps`
thread 'main' panicked at 'assertion failed: !impl_self_ty.has_infer_types()', librustc_mir/borrow_check/nll/type_check/mod.rs:1033:21
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:480
6: std::panicking::begin_panic
7: rustc_mir::borrow_check::nll::type_check::TypeChecker::relate_type_and_user_type
8: <rustc_mir::borrow_check::nll::type_check::TypeVerifier<'a, 'b, 'gcx, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_constant
9: <rustc_mir::borrow_check::nll::type_check::TypeVerifier<'a, 'b, 'gcx, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_rvalue
10: <rustc_mir::borrow_check::nll::type_check::TypeVerifier<'a, 'b, 'gcx, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_mir
11: rustc_mir::borrow_check::nll::type_check::type_check_internal
12: rustc::ty::context::tls::with_related_context
13: rustc::infer::InferCtxtBuilder::enter
14: <rustc_mir::borrow_check::nll::type_check::TypeckMir as rustc_mir::transform::MirPass>::run_pass
15: rustc_mir::transform::mir_const::{{closure}}
16: rustc_mir::transform::mir_const
17: rustc::ty::query::__query_compute::mir_const
18: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_const<'tcx>>::compute
19: rustc::ty::context::tls::with_context
20: rustc::dep_graph::graph::DepGraph::with_task_impl
21: rustc::ty::context::tls::with_related_context
22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
24: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const
25: rustc_mir::transform::mir_validated
26: rustc::ty::query::__query_compute::mir_validated
27: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_validated<'tcx>>::compute
28: rustc::ty::context::tls::with_context
29: rustc::dep_graph::graph::DepGraph::with_task_impl
30: rustc::ty::context::tls::with_related_context
31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
32: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
34: rustc_borrowck::borrowck::borrowck
35: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::borrowck<'tcx>>::compute
36: rustc::ty::context::tls::with_context
37: rustc::dep_graph::graph::DepGraph::with_task_impl
38: rustc::ty::context::tls::with_related_context
39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
41: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
42: rustc_borrowck::borrowck::check_crate
43: rustc::util::common::time
44: rustc::ty::context::tls::enter_context
45: <std::thread::local::LocalKey<T>>::with
46: rustc::ty::context::TyCtxt::create_and_enter
47: rustc_driver::driver::compile_input
48: rustc_driver::run_compiler_with_pool
49: rustc_driver::driver::spawn_thread_pool
50: rustc_driver::run_compiler
51: <scoped_tls::ScopedKey<T>>::set
52: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
53: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
54: rustc_driver::run
55: rustc_driver::main
56: std::rt::lang_start::{{closure}}
57: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
58: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
59: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:392
at libstd/rt.rs:58
60: main
61: __libc_start_main
62: <unknown>
query stack during panic:
#0 [mir_const] processing `<TestStruct<T>>::call`
#1 [mir_validated] processing `<TestStruct<T>>::call`
#2 [borrowck] processing `<TestStruct<T>>::call`
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.31.0-nightly (424a749a0 2018-10-21) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `ice`.
Caused by:
process didn't exit successfully: `rustc --crate-name ice src/lib.rs --color always --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=2a9b80ba2717f3bb -C extra-filename=-2a9b80ba2717f3bb --out-dir /home/mexus/test/rust/ice/target/debug/deps -C incremental=/home/mexus/test/rust/ice/target/debug/incremental -L dependency=/home/mexus/test/rust/ice/target/debug/deps` (exit code: 101)
Here's a playground link with the examples:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=3a4690e53464d2c8f0a4824b9f31d31d
Activity
mexus commentedon Oct 22, 2018
I see there are a couple of probably related issues (at least seems to be MIR-related), but I'm not quite sure and, and since they don't provide a minimal example I've decided to file an issue :)
pnkfelix commentedon Oct 23, 2018
Worth noting that this is happening on the 2015 edition without
#![feature(nll)]. (Do we need a separate tag to distinguish bugs that are presumably caused by MIR-typeck ?[-]ICE: 'assertion failed: !impl_self_ty.has_infer_types()' in MIR[/-][+]ICE: '!impl_self_ty.has_infer_types()' in MIR from const underneath `impl<T> { ... }`[/+]mexus commentedon Oct 23, 2018
I confirm that either with the feature enabled or edition set to 2018 there problem doesn't reproduce
pnkfelix commentedon Oct 23, 2018
closing as duplicate of #55219