Closed
Description
When trying to compile this incorrect code using cargo, nightly rustc panics.
When compiling using rustc directly without further arguments (or using the same command cargo calls with -C incremental=...
removed), it outputs an error message instead.
Code
trait XTrait<A> {}
struct X<T: XTrait<A>, A> (T, A);
trait Y<'t> {
type M;
type N: 't;
}
impl<'t, T: XTrait<A>, A> Y<'t> for X<T, A> {
type M = X<T, Self::N>;
type N = &'t ();
}
fn main() {
println!("Hello, world!");
}
I also noticed that changing type N = &'t ();
to type N = ();
will also result in an error message instead of a panic.
Meta
rustc --version --verbose
:
rustc 1.56.0-nightly (2faabf579 2021-07-27)
binary: rustc
commit-hash: 2faabf579323f5252329264cc53ba9ff803429a3
commit-date: 2021-07-27
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
Error output
cargo +nightly --verbose run
Compiling crash v0.1.0 (/home/dinky/code/rust/tmp/crash)
Running `rustc --crate-name crash --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=d474572ba93d44de -C extra-filename=-d474572ba93d44de --out-dir /home/dinky/code/rust/tmp/crash/target/debug/deps -C incremental=/home/dinky/code/rust/tmp/crash/target/debug/incremental -L dependency=/home/dinky/code/rust/tmp/crash/target/debug/deps`
error: internal compiler error: compiler/rustc_middle/src/ich/impls_ty.rs:94:17: StableHasher: unexpected region '_#0r
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034: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.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [check_impl_item_well_formed] checking that `<impl at src/main.rs:10:1: 13:2>::M` is well-formed
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `crash`
Caused by:
process didn't exit successfully: `rustc --crate-name crash --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=d474572ba93d44de -C extra-filename=-d474572ba93d44de --out-dir /home/dinky/code/rust/tmp/crash/target/debug/deps -C incremental=/home/dinky/code/rust/tmp/crash/target/debug/incremental -L dependency=/home/dinky/code/rust/tmp/crash/target/debug/deps` (exit status: 101)
Backtrace
RUST_BACKTRACE=1 cargo +nightly --verbose run
Compiling crash v0.1.0 (/home/dinky/code/rust/tmp/crash)
Running `rustc --crate-name crash --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=d474572ba93d44de -C extra-filename=-d474572ba93d44de --out-dir /home/dinky/code/rust/tmp/crash/target/debug/deps -C incremental=/home/dinky/code/rust/tmp/crash/target/debug/incremental -L dependency=/home/dinky/code/rust/tmp/crash/target/debug/deps`
error: internal compiler error: compiler/rustc_middle/src/ich/impls_ty.rs:94:17: StableHasher: unexpected region '_#0r
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
stack backtrace:
0: std::panicking::begin_panic
1: std::panic::panic_any
2: rustc_errors::HandlerInner::bug
3: rustc_errors::Handler::bug
4: rustc_middle::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::bug_fmt
7: rustc_middle::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::RegionKind>::hash_stable
8: <rustc_middle::ty::TyS as rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext>>::hash_stable
9: std::thread::local::LocalKey<T>::with
10: rustc_middle::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::Binder<T>>::hash_stable
11: rustc_query_system::dep_graph::dep_node::DepNode<K>::construct
12: rustc_query_system::query::plumbing::get_query_impl
13: rustc_query_system::query::plumbing::get_query
14: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
15: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
16: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
17: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::select_all_obligations_or_error
18: rustc_infer::infer::InferCtxtBuilder::enter
19: rustc_typeck::check::wfcheck::check_associated_item
20: rustc_typeck::check::check::check_impl_item_well_formed
21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
22: rustc_data_structures::stack::ensure_sufficient_stack
23: rustc_query_system::query::plumbing::force_query_with_job
24: rustc_query_system::query::plumbing::get_query_impl
25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_impl_item_well_formed
26: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::intravisit::Visitor>::visit_impl_item
27: std::panicking::try
28: rustc_data_structures::sync::par_for_each_in
29: rustc_session::session::Session::track_errors
30: rustc_typeck::check_crate
31: rustc_interface::passes::analysis
32: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
33: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
34: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
35: rustc_data_structures::stack::ensure_sufficient_stack
36: rustc_query_system::query::plumbing::force_query_with_job
37: rustc_query_system::query::plumbing::get_query_impl
38: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
39: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
40: rustc_span::with_source_map
41: rustc_interface::interface::create_compiler_and_run
42: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [check_impl_item_well_formed] checking that `<impl at src/main.rs:10:1: 13:2>::M` is well-formed
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `crash`
Caused by:
process didn't exit successfully: `rustc --crate-name crash --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=d474572ba93d44de -C extra-filename=-d474572ba93d44de --out-dir /home/dinky/code/rust/tmp/crash/target/debug/deps -C incremental=/home/dinky/code/rust/tmp/crash/target/debug/incremental -L dependency=/home/dinky/code/rust/tmp/crash/target/debug/deps` (exit status: 101)