Repository navigation
Closed
Closed
Copy link
Labels
A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Description
EDITED: MCVE is here: #47814 (comment)
I tried to compile the following, which caused the rust compiler to panic.
...
�impl<'a> ArpIPv4<'a> {
const LENGTH: usize = 20;
...
pub fn to_buffer(&self) -> [u8; Self::LENGTH] {
[0; ArpIPv4::LENGTH]
}
}
The following compiles just fine:
...
�impl<'a> ArpIPv4<'a> {
const LENGTH: usize = 20;
...
pub fn to_buffer(&self) -> [u8; ArpIPv4::LENGTH] {
[0; ArpIPv4::LENGTH]
}
}
The error message:
[nix-shell:~/Code/nerd-stack]$ cargo run
Compiling nerd-stack v0.1.0 (file:///home/richard/Code/nerd-stack)
warning: unused imports: `ipv4_to_string`, `mac_to_string`
--> src/protocols/arp.rs:1:26
|
1 | use address::{MAC, IPv4, mac_to_string, ipv4_to_string};
| ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
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.24.0-nightly (9389e23a8 2017-12-31) running on x86_64-unknown-linux-gnu
thread 'rustc' panicked at 'assertion failed: `(left == right)`
left: `Some(NodeId(820))`,
right: `None`: free_scope: DefId(0/0:83 ~ nerd_stack[3074]::protocols[0]::arp[0]::{{impl}}[2]) not recognized by the region scope tree for None / Some(DefId(0/0:86 ~ nerd_stack[3074]::protocols[0]::arp[0]::{{impl}}[2]::to_buffer[0]))', /checkout/src/librustc/middle/region.rs:729:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `nerd-stack`.
To learn more, run the command again with --verbose.
And running again with verbosity and backtrace:
[nix-shell:~/Code/nerd-stack]$ RUST_BACKTRACE=1 cargo run --verbose
Fresh libc v0.2.36
Compiling nerd-stack v0.1.0 (file:///home/richard/Code/nerd-stack)
Running `rustc --crate-name nerd_stack src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=320d9acf78f2e38b -C extra-filename=-320d9acf78f2e38b --out-dir /home/richard/Code/nerd-stack
/target/debug/deps -C incremental=/home/richard/Code/nerd-stack/target/debug/incremental -L dependency=/home/richard/Code/nerd-stack/target/debug/deps --extern libc=/home/richard/Code/nerd-stack/target/debug/deps
/liblibc-1d53503271082800.rlib`
warning: unused imports: `ipv4_to_string`, `mac_to_string`
--> src/protocols/arp.rs:1:26
|
1 | use address::{MAC, IPv4, mac_to_string, ipv4_to_string};
| ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
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.24.0-nightly (9389e23a8 2017-12-31) running on x86_64-unknown-linux-gnu
note: run with `RUST_BACKTRACE=1` for a backtrace thread 'rustc' panicked at 'assertion failed: `(left == right)`
left: `Some(NodeId(820))`,
right: `None`: free_scope: DefId(0/0:83 ~ nerd_stack[3074]::protocols[0]::arp[0]::{{impl}}[2]) not recognized by the region scope tree for None / Some(DefId(0/0:86 ~ nerd_stack[3074]::protocols[0]::arp[0]::{{imp
l}}[2]::to_buffer[0]))', /checkout/src/librustc/middle/region.rs:729:13
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
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::begin_panic
6: std::panicking::begin_panic_fmt
7: rustc::middle::region::ScopeTree::early_free_scope
8: rustc::middle::free_region::RegionRelations::is_subregion_of
9: rustc::infer::lexical_region_resolve::resolve
10: rustc::infer::InferCtxt::resolve_regions_and_report_errors_inner
11: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_expr
12: <std::thread::local::LocalKey<T>>::with
13: rustc::infer::InferCtxtBuilder::enter
14: rustc_typeck::check::typeck_tables_of
15: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::compute_result
16: rustc::dep_graph::graph::DepGraph::with_task_impl
17: rustc_errors::Handler::track_diagnostics
18: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
19: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::force
20: rustc::ty::maps::plumbing::force_from_dep_node
21: rustc::dep_graph::graph::DepGraph::try_mark_green
22: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
23: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
24: rustc::ty::maps::TyCtxtAt::const_eval
25: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
26: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
27: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
28: <rustc_data_structures::accumulate_vec::AccumulateVec<A> as core::iter::traits::FromIterator<<A as rustc_data_structures::array_vec::Array>::Element>>::from_iter
29: rustc::ty::fold::TypeFoldable::fold_with
30: rustc::traits::project::normalize
31: rustc_typeck::check::FnCtxt::normalize_associated_types_in
32: <std::thread::local::LocalKey<T>>::with
33: rustc::infer::InferCtxtBuilder::enter
34: rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor::check_associated_item
35: rustc::hir::Crate::visit_all_item_likes
36: rustc::session::Session::track_errors
37: rustc_typeck::check_crate
38: <std::thread::local::LocalKey<T>>::with
39: <std::thread::local::LocalKey<T>>::with
40: rustc::ty::context::TyCtxt::create_and_enter
41: rustc_driver::driver::compile_input
42: rustc_driver::run_compiler
error: Could not compile `nerd-stack`.
Caused by:
process didn't exit successfully: `rustc --crate-name nerd_stack src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=320d9acf78f2e38b -C extra-filename=-320d9acf78f2e38b --out-dir /home/richard/Code/nerd-stack/target/debug/deps -C incremental=/home/richard/Code/nerd-stack/target/debug/incremental -L dependency=/home/richard/Code/nerd-stack/target/debug/deps --extern libc=/home/richard/Code/nerd-stack/target/debug/deps/liblibc-1d53503271082800.rlib` (exit code: 101)
Running nixos 17.09 using rust nightly installed using the mozilla nixpkgs overlay. It's about a month out of date, so I'll check the updates.
Metadata
Metadata
Assignees
Labels
A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Activity
dtolnay commentedon Jan 28, 2018
This still crashes as of the most recent nightly. Self-contained repro:
Mentioning @eddyb who added this assertion in #41914.
eddyb commentedon Jan 28, 2018
@dtolnay That was confusing at first, heh - the multi-line
assert_eqmessage which doesn't split custom messages on their own line doesn't help at all (can we split it off?).So what's happening is the length expression is using a generic parameter in its outer scope. This hasn't ever been supported, but it's extremely obnoxious to prevent - we could ban
Selfinrustc_resolvebut that already works in some specific situations, so it'd be backwards-incompatible.This problem would get properly fixed once we actually start supporting generics-in-scope for array expressions, and that can't happen without lazy normalization (cc @nikomatsakis).
internally-combusted commentedon Mar 19, 2019
I'm having the same problem still.
succeeds in making the compiler cry about the function call in the array size, but with
the compiler panics.
Here's my
rustc --version --verbose:Centril commentedon Mar 10, 2020
@dtolnay's exampe ICEs at
rustc_mir::borrow_check::universal_regions::UniversalRegionIndices::to_region_vid::{{closure}}, cc @matthewjasperRollup merge of rust-lang#74000 - lcnr:lazy_normalisation_consts, r=v…
Rollup merge of rust-lang#74000 - lcnr:lazy_normalisation_consts, r=v…
Rollup merge of rust-lang#74000 - lcnr:lazy_normalisation_consts, r=v…
philw07 commentedon Dec 12, 2020
Issue is still present on current stable and nightly.
Just wanted to add that it only occurs when using a lifetime parameter.
@dtolnay's example ICEs whereas the following with removed lifetime parameter works fine.
JohnTitor commentedon Dec 30, 2020
Triage:
This is no longer ICE with the latest nightly: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=fcbba8b50e86684074a03bc27d825d91
Add regression test for rust-lang#47814
Rollup merge of rust-lang#105236 - JohnTitor:issue-47814, r=compiler-…
Auto merge of rust-lang#105261 - matthiaskrgr:rollup-9ghhc9c, r=matth…