Reduced test case (play) from comment below:
struct OnDiskDirEntry<'a> { _s: &'a usize }
impl<'a> OnDiskDirEntry<'a> {
const LFN_FRAGMENT_LEN: usize = 2;
fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } }
}
Another repro case: https://github.com/rust-lang/rust/issues/56445#issuecomment-524494170
Original bug report follows
If I run cargo test
on https://github.com/thejpster/embedded-sdmmc-rs/tree/generates_ice, I get an ICE:
user@host:~/Documents/programming/embedded-sdmmc$ cargo test
Compiling embedded-sdmmc v0.1.0 (/home/jonathan/Documents/programming/embedded-sdmmc)
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Some(NodeId(1093))`,
right: `None`: free_scope: DefId(0/0:72 ~ embedded_sdmmc[4f8a]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:79 ~ embedded_sdmmc[4f8a]::fat[0]::{{impl}}[4]::lfn_contents[0]))', librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for 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.31.0-beta.19 (42053f9f0 2018-11-26) 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 `embedded-sdmmc`.
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Some(NodeId(1090))`,
right: `None`: free_scope: DefId(0/0:71 ~ embedded_sdmmc[be94]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:78 ~ embedded_sdmmc[be94]::fat[0]::{{impl}}[4]::lfn_contents[0]))', librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for 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.31.0-beta.19 (42053f9f0 2018-11-26) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `embedded-sdmmc`.
To learn more, run the command again with --verbose.
user@host:~/Documents/programming/embedded-sdmmc$ cargo +nightly test
Compiling embedded-sdmmc v0.1.0 (/home/jonathan/Documents/programming/embedded-sdmmc)
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Some(NodeId(1093))`,
right: `None`: free_scope: DefId(0/0:72 ~ embedded_sdmmc[46a7]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:79 ~ embedded_sdmmc[46a7]::fat[0]::{{impl}}[4]::lfn_contents[0]))', src/librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for 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.32.0-nightly (400c2bc5e 2018-11-27) 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 `embedded-sdmmc`.
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Some(NodeId(1090))`,
right: `None`: free_scope: DefId(0/0:71 ~ embedded_sdmmc[93d1]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:78 ~ embedded_sdmmc[93d1]::fat[0]::{{impl}}[4]::lfn_contents[0]))', src/librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for 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.32.0-nightly (400c2bc5e 2018-11-27) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `embedded-sdmmc`.
To learn more, run the command again with --verbose.
user@host:~/Documents/programming/embedded-sdmmc$ cargo version
cargo 1.31.0-beta (339d9f9c8 2018-11-16)
user@host:~/Documents/programming/embedded-sdmmc$ cargo +nightly version
cargo 1.32.0-nightly (b3d0b2e54 2018-11-15)
I'm using 2018 edition syntax, so I can only test on beta and nightly.
Commenting out the lfn_contents()
function in fat.rs makes the ICE go away.
The ICE occurs on a cargo build
as well as a cargo test
.
Replacing both instances of Self::FRAGMENT_LEN in the lfn_contents()
function with the literal integer 13 makes the ICE go away.
Still reproduces on 1.35.0 and nightly (rustc 1.37.0-nightly (991c719a1 2019-06-08)
).
Click for backtrace
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
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: std::panicking::begin_panic_fmt
at src/libstd/panicking.rs:336
8: rustc::middle::region::ScopeTree::early_free_scope
9: rustc::middle::free_region::RegionRelations::is_subregion_of
10: rustc::infer::lexical_region_resolve::resolve
11: rustc::infer::InferCtxt::resolve_regions_and_report_errors
12: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt>::regionck_expr
13: rustc::ty::context::GlobalCtxt::enter_local
14: rustc_typeck::check::typeck_tables_of
15: rustc::ty::query::__query_compute::typeck_tables_of
16: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
17: rustc::dep_graph::graph::DepGraph::with_task_impl
18: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
19: rustc_mir::const_eval::const_eval_raw_provider
20: rustc::ty::query::__query_compute::const_eval_raw
21: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute
22: rustc::dep_graph::graph::DepGraph::with_task_impl
23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
24: rustc_mir::const_eval::const_eval_provider
25: rustc::ty::query::__query_compute::const_eval
26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
27: rustc::dep_graph::graph::DepGraph::with_task_impl
28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
29: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
30: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
31: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
32: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
33: rustc::ty::fold::TypeFoldable::fold_with
34: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
35: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
36: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
37: rustc::ty::fold::TypeFoldable::fold_with
38: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
39: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
40: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
41: rustc::ty::fold::TypeFoldable::fold_with
42: rustc::traits::project::normalize
43: rustc::infer::InferCtxt::partially_normalize_associated_types_in
44: rustc::ty::context::GlobalCtxt::enter_local
45: rustc_typeck::check::wfcheck::check_associated_item
46: rustc::ty::query::__query_compute::check_impl_item_well_formed
47: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_impl_item_well_formed>::compute
48: rustc::dep_graph::graph::DepGraph::with_task_impl
49: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
50: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc::hir::itemlikevisit::ParItemLikeVisitor>::visit_impl_item
51: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:87
52: rustc_data_structures::sync::par_for_each_in
53: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:87
54: rustc::hir::Crate::par_visit_all_item_likes
55: rustc::util::common::time
56: rustc_typeck::check_crate
57: rustc_interface::passes::analysis
58: rustc::ty::query::__query_compute::analysis
59: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
60: rustc::dep_graph::graph::DepGraph::with_task_impl
61: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
62: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
63: rustc_interface::passes::create_global_ctxt::{{closure}}
64: rustc_interface::interface::run_compiler_in_existing_thread_pool
65: std::thread::local::LocalKey<T>::with
66: scoped_tls::ScopedKey<T>::set
67: syntax::with_globals
query stack during panic:
#0 [typeck_tables_of] processing `fat::OnDiskDirEntry::<'a>::lfn_contents::{{constant}}#0`
#1 [const_eval_raw] const-evaluating `fat::OnDiskDirEntry::<'a>::lfn_contents::{{constant}}#0`
#2 [const_eval] const-evaluating + checking `fat::OnDiskDirEntry::<'a>::lfn_contents::{{constant}}#0`
#3 [check_impl_item_well_formed] processing `fat::OnDiskDirEntry::<'a>::lfn_contents`
#4 [analysis] running analysis passes on this crate
end of query stack
triage: P-high, removing nomination, assigning to self for initial investigation.
Note: While I replicate the ICE as described on beta, I see a different ICE on nightly on this branch, namely:
error: internal compiler error: src/librustc_mir/borrow_check/nll/universal_regions.rs:741: cannot convert `ReEarlyBound(0, 'a)` to a region vid
For reference (in case it matters e.g. for a hypothetical backport) was injected between +nightly-2019-05-25 and +nightly-2019-05-26. Further bisection thanks to rustup-toolchain-install-master "pinpointed" the change to this rollup PR:
I'm pretty sure the change in behavior is due to PR #61118.
Click for stack trace
error: internal compiler error: src/librustc_mir/borrow_check/nll/universal_regions.rs:741: cannot convert `ReEarlyBound(0, 'a)` to a region vid
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
stack backtrace:
0: 0x7ffb4696718b - backtrace::backtrace::libunwind::trace::h41595b2657878dbc
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
1: 0x7ffb4696718b - backtrace::backtrace::trace_unsynchronized::h4efe511900bf5e12
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
2: 0x7ffb4696718b - std::sys_common::backtrace::_print::h7275b63687b21f98
at src/libstd/sys_common/backtrace.rs:47
3: 0x7ffb4696718b - std::sys_common::backtrace::print::h790c12384440cac4
at src/libstd/sys_common/backtrace.rs:36
4: 0x7ffb4696718b - std::panicking::default_hook::{{closure}}::he6cba1bdf748f1c3
at src/libstd/panicking.rs:198
5: 0x7ffb46966e8c - std::panicking::default_hook::h1296d9a476e7a9c2
at src/libstd/panicking.rs:212
6: 0x7ffb446bb3f1 - rustc::util::common::panic_hook::ha2e96a0b919e5a1a
7: 0x7ffb469679e9 - std::panicking::rust_panic_with_hook::h8d2408723e9a2bd4
at src/libstd/panicking.rs:479
8: 0x7ffb433253ad - std::panicking::begin_panic::h234a5167f045a72d
9: 0x7ffb4334544f - rustc_errors::Handler::bug::h3246723a0b2031e4
10: 0x7ffb44420643 - rustc::util::bug::opt_span_bug_fmt::{{closure}}::hb8ea6d6e88ca54f4
11: 0x7ffb444125da - rustc::ty::context::tls::with_opt::{{closure}}::h9f1dda041ea3d8ca
12: 0x7ffb444124f5 - rustc::ty::context::tls::with_context_opt::h84ca529c2ea4a682
13: 0x7ffb44412587 - rustc::ty::context::tls::with_opt::h875054e282c744c1
14: 0x7ffb44420558 - rustc::util::bug::opt_span_bug_fmt::h24d0b9fdc514170c
15: 0x7ffb444204c2 - rustc::util::bug::bug_fmt::hc0ddc16f6cc56100
16: 0x7ffb459c72e2 - rustc_mir::borrow_check::nll::universal_regions::UniversalRegionIndices::to_region_vid::{{closure}}::h8f1191649fe952ee
17: 0x7ffb45a9f866 - rustc_mir::borrow_check::nll::type_check::constraint_conversion::ConstraintConversion::convert_all::hff38c8376a2f82d5
18: 0x7ffb45c4bd1c - rustc_mir::borrow_check::nll::type_check::TypeChecker::fully_perform_op::h78748fd6d92e387d
19: 0x7ffb45c46a4b - rustc_mir::borrow_check::nll::type_check::type_check::hea7e4d9e23e5ba76
20: 0x7ffb458bcd6f - rustc_mir::borrow_check::nll::compute_regions::h80ed7c7d15df620d
21: 0x7ffb45976f83 - rustc_mir::borrow_check::do_mir_borrowck::hd7e464220fc5eca7
22: 0x7ffb45cfe746 - rustc::ty::context::GlobalCtxt::enter_local::heaa8c87e8f8669e9
23: 0x7ffb459765da - rustc_mir::borrow_check::mir_borrowck::hae96041a19836cd8
24: 0x7ffb45954cb7 - rustc::ty::query::__query_compute::mir_borrowck::hc7e574fc48878e80
25: 0x7ffb45c735a5 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute::h4a666fc8e52be0d8
26: 0x7ffb459ed121 - rustc::dep_graph::graph::DepGraph::with_task_impl::hd0890e01d4a2bb3e
27: 0x7ffb45cf234c - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hf2f4510df37bed60
28: 0x7ffb45c73d25 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query::hf9d9f7fd3e34fbdf
29: 0x7ffb458d1164 - rustc_mir::transform::optimized_mir::hcdb77108b4828931
30: 0x7ffb4595507d - rustc::ty::query::__query_compute::optimized_mir::h2402952c578cb24c
31: 0x7ffb45c7365d - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute::ha863b92e11001b35
32: 0x7ffb459f1497 - rustc::dep_graph::graph::DepGraph::with_task_impl::hf4b7b9c362d667eb
33: 0x7ffb45c915ad - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h2ec66e6851178136
34: 0x7ffb45aafff4 - rustc_mir::interpret::eval_context::InterpretCx<M>::load_mir::haeda8af7b0b03ee9
35: 0x7ffb45c65bee - rustc_mir::const_eval::const_eval_raw_provider::hf339294a1d76412a
36: 0x7ffb459553b1 - rustc::ty::query::__query_compute::const_eval_raw::hf79a48c673afa965
37: 0x7ffb45c7370c - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute::ha61cce162d227846
38: 0x7ffb459ea072 - rustc::dep_graph::graph::DepGraph::with_task_impl::ha02743b6acac21ff
39: 0x7ffb45c9dd2b - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h40523fc999af8bae
40: 0x7ffb45c64e79 - rustc_mir::const_eval::const_eval_provider::h8ecd0d4acacbded6
41: 0x7ffb442b17f8 - rustc::ty::query::__query_compute::const_eval::h1119198b82c92e58
42: 0x7ffb4464f7bc - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute::hbc876f0f390d6c25
43: 0x7ffb4420173a - rustc::dep_graph::graph::DepGraph::with_task_impl::h35ad45147a002223
44: 0x7ffb444796ab - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h0caac3b3a703e7cc
45: 0x7ffb446a81e9 - <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const::h09fb34e6e6e164e6
46: 0x7ffb44415311 - rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with::h13b491c0c3eac0bf
47: 0x7ffb446a7975 - <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty::h233440fce128939b
48: 0x7ffb442c0659 - <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter::h590f39025e063bfa
49: 0x7ffb443fa94c - rustc::ty::fold::TypeFoldable::fold_with::hb694e0d0547dc004
50: 0x7ffb444154bd - rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with::h13b491c0c3eac0bf
51: 0x7ffb446a7975 - <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty::h233440fce128939b
52: 0x7ffb442c0659 - <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter::h590f39025e063bfa
53: 0x7ffb443fa94c - rustc::ty::fold::TypeFoldable::fold_with::hb694e0d0547dc004
54: 0x7ffb444152dd - rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with::h13b491c0c3eac0bf
55: 0x7ffb446a7975 - <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty::h233440fce128939b
56: 0x7ffb41701954 - <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter::he9a71a7d2a8e41a4
57: 0x7ffb4155e9bc - rustc::ty::fold::TypeFoldable::fold_with::hb877186dcdde4a8a
58: 0x7ffb4169fc64 - rustc::traits::project::normalize::hd55b9356461a2c54
59: 0x7ffb414c0e58 - rustc_typeck::check::FnCtxt::normalize_associated_types_in::hd4ed4b1269b53182
60: 0x7ffb4163c92d - rustc::ty::context::GlobalCtxt::enter_local::ha314227e251792e5
61: 0x7ffb41713dd0 - rustc_typeck::check::wfcheck::check_associated_item::h7a5ca14b80bab58e
62: 0x7ffb414e147e - rustc::ty::query::__query_compute::check_impl_item_well_formed::hca2766a1fa632057
63: 0x7ffb415ab05d - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_impl_item_well_formed>::compute::h04a3209f07ea56a6
64: 0x7ffb4150f69b - rustc::dep_graph::graph::DepGraph::with_task_impl::h4963b94af07ea903
65: 0x7ffb41620270 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::he56dc8058550bfc1
66: 0x7ffb41716e67 - <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc::hir::itemlikevisit::ParItemLikeVisitor>::visit_impl_item::h77cafc90c30a5ec3
67: 0x7ffb469788da - __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:82
68: 0x7ffb41520dc9 - rustc_data_structures::sync::par_for_each_in::h550ca05f0ca541fa
69: 0x7ffb469788da - __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:82
70: 0x7ffb416d8699 - rustc::hir::Crate::par_visit_all_item_likes::h2fa6afd0da02bfad
71: 0x7ffb414e4c5d - rustc::util::common::time::he5d849132f13a9ee
72: 0x7ffb416f8e08 - rustc_typeck::check_crate::h261fa85c0eefa2e6
73: 0x7ffb46346855 - rustc_interface::passes::analysis::hd7064ffdb52b6f45
74: 0x7ffb46cc71e6 - rustc::ty::query::__query_compute::analysis::hc63e7bbcf2ef51b7
75: 0x7ffb46c32462 - rustc::dep_graph::graph::DepGraph::with_task_impl::h6ecc24de8ad82664
76: 0x7ffb46c2a0ad - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h3d879e5498479529
77: 0x7ffb46c3b606 - rustc::ty::context::tls::enter_global::h429817b273ef3027
78: 0x7ffb46c5a407 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h0a59fddc00963551
79: 0x7ffb463a3b05 - rustc_interface::passes::create_global_ctxt::{{closure}}::h7a059b6cf199597d
80: 0x7ffb46c5b7aa - rustc_interface::interface::run_compiler_in_existing_thread_pool::h35eddbfcfbbe0eb4
81: 0x7ffb46ccd5f6 - std::thread::local::LocalKey<T>::with::hea85159711765771
82: 0x7ffb46c65fb5 - scoped_tls::ScopedKey<T>::set::he08d6211f459724f
83: 0x7ffb46c98ad4 - syntax::with_globals::h2c63be024f0c1f38
84: 0x7ffb46cb789d - std::sys_common::backtrace::__rust_begin_short_backtrace::hfc7fb053a9ed90ec
85: 0x7ffb469788da - __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:82
86: 0x7ffb46c436d9 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0cd7d8fc1b0a39a3
87: 0x7ffb4694aeef - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::he71721d2d956d451
at /rustc/0e4a56b4b04ea98bb16caada30cb2418dd06e250/src/liballoc/boxed.rs:746
88: 0x7ffb469775b0 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::he520045b8d28ce5c
at /rustc/0e4a56b4b04ea98bb16caada30cb2418dd06e250/src/liballoc/boxed.rs:746
89: 0x7ffb469775b0 - std::sys_common::thread::start_thread::h2e98d1272dc6d74b
at src/libstd/sys_common/thread.rs:13
90: 0x7ffb469775b0 - std::sys::unix::thread::Thread::new::thread_start::h18485805666ccd3c
at src/libstd/sys/unix/thread.rs:79
91: 0x7ffb468bf58e - start_thread
at /usr/src/debug/glibc-2.28-60-g4d7af7815a/nptl/pthread_create.c:486
92: 0x7ffb467de6a3 - clone
93: 0x0 - <unknown>
query stack during panic:
#0 [mir_borrowck] processing `fat::OnDiskDirEntry::<'a>::lfn_contents::{{constant}}#0`
#1 [optimized_mir] processing `fat::OnDiskDirEntry::<'a>::lfn_contents::{{constant}}#0`
--> src/fat.rs:276:56
|
276 | fn lfn_contents(&self) -> Option<(bool, u8, [char; Self::LFN_FRAGMENT_LEN])> {
| ^^^^^^^^^^^^^^^^^^^^^^
#2 [const_eval_raw] const-evaluating `fat::OnDiskDirEntry::<'a>::lfn_contents::{{constant}}#0`
#3 [const_eval] const-evaluating + checking `fat::OnDiskDirEntry::<'a>::lfn_contents::{{constant}}#0`
#4 [check_impl_item_well_formed] processing `fat::OnDiskDirEntry::<'a>::lfn_contents`
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
Okay here is reduced test case (play):
struct OnDiskDirEntry<'a> { _s: &'a usize }
impl<'a> OnDiskDirEntry<'a> {
const LFN_FRAGMENT_LEN: usize = 2;
fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } }
}
@thejpster another workaround, by the way, is to move the const LFN_FRAGMENT_LEN
out of the impl
(and then change the use to say LFN_FRAGMENT_LEN
instead of Self::LFN_FRAGMENT_LEN
)
And yet another workaround is to say [char; OnDiskDirEntry::LFN_FRAGMENT_LEN]
instead of [char; Self::LFN_FRAGMENT_LEN]
in the return type.
I am taking a break for a few months and I wont be able to look at this; unassigning self.
Another repro case taken from duplicate #63290:
#![feature(const_generics)]
use core::marker::PhantomData;
struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
impl Bug<'_, {""}> {}
Another occurrence in https://github.com/rust-lang/rust/issues/63838:
pub struct Memory<'rom> {
rom: &'rom [u8],
ram: [u8; Self::SIZE],
}
impl<'rom> Memory<'rom> {
pub const SIZE: usize = 0x8000;
}
I've been trying to trace this down, and I think it's due to #43408 (or at least it's the same code that needs fixed there, in rustc_typeck::collect::generics_of). I believe the UniversalRegionIndices aren't being properly populated for the constant, because in the HIR the constant doesn't have a parent. ConstraintConversion needs the UniversalRegionIndices to convert the ReEarlyBound into a RegionVid, but it's missing due to the previous problem.
Simply replacing this line with if true {
makes the last Memory examples compile, but the original example fails later in free_scope. I'm super new to the rust compiler, but hopefully someone else can use this information to fix the problem :)
I also believe that the const generics issue is separate, but it's possible that I'm simply trying to solve this in the wrong manner, and a correct solution would also solve the const generics issue.
triage: It would be good to at least figure out a way to give a better error message in these array length cases. (other cases include #43408, #52808...)
Another case in https://github.com/rust-lang/rust/issues/72242:
use std::marker::PhantomData;
struct S<'a>
{
m1: PhantomData<&'a u8>,
m2: [u8; S::size()],
}
impl<'a> S<'a>
{
const fn size() -> usize { 1 }
fn new() -> Self
{
Self
{
m1: PhantomData,
m2: [0; Self::size()],
}
}
}
Triage: This ICE is now fixed in the latest nightly (rustc 1.45.0-nightly (46e85b432 2020-05-24)) (fixed by #72362).
Triage: https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995 is now fixed in the latest nightly (I think it's fixed by #74051).
(And I've hidden comment as resolved to make the un-fixed ICEs easier to find.)
Most helpful comment
Triage: This ICE is now fixed in the latest nightly (rustc 1.45.0-nightly (46e85b432 2020-05-24)) (fixed by #72362).