Closed
Description
The code below produces an internal compiler error on the current nightly. The bug was already present on a ~2 weeks old nightly.
Note that while this ICE was found while writing code using #![feature(type_alias_impl_trait)]
, it also manifests itself when the unstable feature is turned off.
Code
trait Trait {
type Associated;
fn func() -> Self::Associated;
}
trait Bound {}
pub struct Struct;
impl Trait for Struct {
type Associated = impl Bound;
fn func() -> Self::Associated {
Some(42).map(|_| j)
}
}
Meta
rustc --version --verbose
:
rustc 1.52.0-nightly (5fa22fe6f 2021-02-14)
binary: rustc
commit-hash: 5fa22fe6f821ac3801d05f624b123dda25fde32c
commit-date: 2021-02-14
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1
Error output
error: internal compiler error: compiler/rustc_mir/src/borrow_check/universal_regions.rs:533:26: expected defining type for `DefId(0:13 ~ bug[fad1]::{impl#0}::func::{closure#0})`: `[type error]`
--> src/lib.rs:13:22
|
13 | Some(42).map(|_| j)
| ^^^^^
thread 'rustc' panicked at 'Box<Any>', /rustc/5fa22fe6f821ac3801d05f624b123dda25fde32c/library/std/src/panic.rs:59:5
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.52.0-nightly (5fa22fe6f 2021-02-14) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `<Struct as Trait>::func::{closure#0}`
#1 [type_of] computing type of `<Struct as Trait>::Associated::{opaque#0}`
end of query stack
Backtrace
thread 'rustc' panicked at 'Box<Any>', /rustc/5fa22fe6f821ac3801d05f624b123dda25fde32c/library/std/src/panic.rs:59:5
stack backtrace:
0: std::panicking::begin_panic
1: std::panic::panic_any
2: rustc_errors::HandlerInner::span_bug
3: rustc_errors::Handler::span_bug
4: rustc_middle::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::span_bug_fmt
7: rustc_mir::borrow_check::universal_regions::UniversalRegions::new
8: rustc_mir::borrow_check::nll::replace_regions_in_mir
9: rustc_mir::borrow_check::do_mir_borrowck
10: rustc_infer::infer::InferCtxtBuilder::enter
11: rustc_mir::borrow_check::mir_borrowck
12: 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
13: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
15: rustc_data_structures::stack::ensure_sufficient_stack
16: rustc_query_system::query::plumbing::force_query_with_job
17: rustc_query_system::query::plumbing::get_query_impl
18: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
19: <rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator as rustc_hir::intravisit::Visitor>::visit_expr
20: rustc_hir::intravisit::walk_expr
21: rustc_hir::intravisit::Visitor::visit_nested_body
22: rustc_hir::intravisit::Visitor::visit_fn
23: rustc_hir::intravisit::walk_impl_item
24: rustc_hir::intravisit::Visitor::visit_nested_impl_item
25: rustc_hir::intravisit::walk_impl_item_ref
26: rustc_hir::intravisit::walk_item
27: rustc_typeck::collect::type_of::type_of
28: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::type_of>::compute
29: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
31: rustc_data_structures::stack::ensure_sufficient_stack
32: rustc_query_system::query::plumbing::force_query_with_job
33: rustc_query_system::query::plumbing::get_query_impl
34: rustc_typeck::check::check::check_item_type
35: rustc_middle::hir::map::Map::visit_item_likes_in_module
36: rustc_typeck::check::check::check_mod_item_types
37: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_mod_item_types>::compute
38: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
39: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
40: rustc_data_structures::stack::ensure_sufficient_stack
41: rustc_query_system::query::plumbing::force_query_with_job
42: rustc_query_system::query::plumbing::get_query_impl
43: rustc_query_system::query::plumbing::ensure_query_impl
44: rustc_session::utils::<impl rustc_session::session::Session>::time
45: rustc_typeck::check_crate
46: rustc_interface::passes::analysis
47: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
48: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
49: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
50: rustc_data_structures::stack::ensure_sufficient_stack
51: rustc_query_system::query::plumbing::force_query_with_job
52: rustc_query_system::query::plumbing::get_query_impl
53: rustc_interface::passes::QueryContext::enter
54: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
55: rustc_span::with_source_map
56: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Category: This is a bug.`#[feature(type_alias_impl_trait)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.
Type
Projects
Status
Done