Closed
Description
Code
Assuming the following header:
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
use core::{convert::TryFrom, num::NonZeroUsize};
struct A<const N: NonZeroUsize>([u8; N.get()]) where [u8; N.get()]: Sized;
The following example in trait impl causes an ICE:
impl<'a, const N: NonZeroUsize> TryFrom<&'a [u8]> for A<N> where [u8; N.get()]: Sized {
type Error = ();
fn try_from(slice: &'a [u8]) -> Result<A<N>, ()> {
let _x = <&[u8; N.get()] as TryFrom<&[u8]>>::try_from(slice);
unimplemented!();
}
}
The following without a trait implementation does not:
fn try_from<'a, const N: NonZeroUsize>(slice: &'a [u8]) -> Result<A<N>, ()> where [u8; N.get()]: Sized {
let x = <&[u8; N.get()] as TryFrom<&[u8]>>::try_from(slice);
unimplemented!();
}
Neither does the equivalent implementation without const_evaluatable_checked
:
struct B<const N: usize>([u8; N]) where [u8; N]: Sized;
impl<'a, const N: usize> TryFrom<&'a [u8]> for B<N> where [u8; N]: Sized {
type Error = ();
fn try_from(slice: &'a [u8]) -> Result<B<N>, ()> {
let _x = <&[u8; N] as TryFrom<&[u8]>>::try_from(slice);
unimplemented!();
}
}
Meta
rustc --version --verbose
:
rustc 1.49.0-nightly (91a79fb29 2020-10-07)
binary: rustc
commit-hash: 91a79fb29ac78d057d04dbe86be13d5dcc64309a
commit-date: 2020-10-07
host: x86_64-pc-windows-msvc
release: 1.49.0-nightly
LLVM version: 11.0
Error output
cargo check
error: internal compiler error: compiler\rustc_middle\src\ich\impls_ty.rs:94:17: StableHasher: unexpected region '_#2r
thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:945: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.49.0-nightly (91a79fb29 2020-10-07) running on x86_64-pc-windows-msvc
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
error: aborting due to previous error; 2 warnings emitted
Backtrace
stack backtrace:
0: 0x7ff947a09989 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc20a26e0f7659afd
1: 0x7ff947a370bb - core::fmt::write::h435be716304d26a1
2: 0x7ff9479fb1d8 - <std::io::IoSlice as core::fmt::Debug>::fmt::h997d94c78f1ba97b
3: 0x7ff947a0ed74 - std::panicking::take_hook::hbf7e33d26fc3ca30
4: 0x7ff947a0e958 - std::panicking::take_hook::hbf7e33d26fc3ca30
5: 0x7ff8fbdcf5a7 - rustc_driver::report_ice::h901ed469a4afd632
6: 0x7ff947a0f7d0 - std::panicking::rust_panic_with_hook::h19068ccbe4b337a1
7: 0x7ff900537870 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
8: 0x7ff900537799 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
9: 0x7ff9005377e1 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
10: 0x7ff90056a80f - rustc_errors::HandlerInner::err_count::hc7ff30e58befa0c0
11: 0x7ff900568ec2 - rustc_errors::Handler::bug::h9f679e586b05b709
12: 0x7ff900043d4f - rustc_middle::util::bug::bug_fmt::h333e4a32fa9b0768
13: 0x7ff90003fe70 - <rustc_middle::ty::consts::int::ConstInt as core::fmt::Debug>::fmt::he16df1c1cd9a0739
14: 0x7ff90003fe13 - <rustc_middle::ty::consts::int::ConstInt as core::fmt::Debug>::fmt::he16df1c1cd9a0739
15: 0x7ff900043c7c - rustc_middle::util::bug::bug_fmt::h333e4a32fa9b0768
16: 0x7ff900043be0 - rustc_middle::util::bug::bug_fmt::h333e4a32fa9b0768
17: 0x7ff90003bd54 - 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::h1b2fcdca26fe65c7
18: 0x7ff8fe089e72 - rustc_ty::provide::h0935123a64901122
19: 0x7ff8ffccce57 - <rustc_trait_selection::traits::fulfill::PendingPredicateObligation as core::fmt::Debug>::fmt::h193f29610c75bb2a
20: 0x7ff8ffb69daf - <rustc_trait_selection::traits::TraitQueryMode as core::fmt::Debug>::fmt::h933d8945b4748b17
21: 0x7ff8ffc24e3d - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hb9cecb2f776e6243
22: 0x7ff8ffcca571 - rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations::h6e0b9a7a32cf419d
23: 0x7ff8ffcf7944 - <rustc_trait_selection::traits::fulfill::PendingPredicateObligation as core::fmt::Debug>::fmt::h193f29610c75bb2a
24: 0x7ff8ffcc9b3f - <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible::h1148d87c05c2aec0
25: 0x7ff8fe12fb9f - <rustc_middle::ty::sty::TraitRef as rustc_traits::chalk::lowering::LowerInto<chalk_solve::rust_ir::TraitBound<rustc_middle::traits::chalk::RustInterner>>>::lower_into::h8ff0d70e3d0188ac
26: 0x7ff8fe1234e1 - <rustc_middle::ty::sty::TraitRef as rustc_traits::chalk::lowering::LowerInto<chalk_solve::rust_ir::TraitBound<rustc_middle::traits::chalk::RustInterner>>>::lower_into::h8ff0d70e3d0188ac
27: 0x7ff8fe1f56da - <rustc_traits::chalk::db::RustIrDatabase as chalk_solve::RustIrDatabase<rustc_middle::traits::chalk::RustInterner>>::generator_witness_datum::h56e9b357d981663c
28: 0x7ff8ffca08b2 - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hb9cecb2f776e6243
29: 0x7ff8ffca476b - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hb9cecb2f776e6243
30: 0x7ff8ffb34698 - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::h491f1d8abd137254
31: 0x7ff8ffca8e4b - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hb9cecb2f776e6243
32: 0x7ff8ffc536c3 - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hb9cecb2f776e6243
33: 0x7ff8ffccc165 - rustc_trait_selection::traits::query::type_op::ascribe_user_type::<impl rustc_trait_selection::traits::query::type_op::QueryTypeOp for rustc_middle::traits::query::type_op::AscribeUserType>::perform_query::h79d7e0f340ea47eb
34: 0x7ff8ff026445 - <rustc_mir::transform::dest_prop::CandidateAssignment as core::fmt::Debug>::fmt::h52c7195478494fc1
35: 0x7ff8fec586c0 - <rustc_middle::mir::traversal::ReversePostorder as core::iter::traits::iterator::Iterator>::size_hint::h344f471fd1cfc36d
36: 0x7ff8fef20f53 - <rustc_middle::ty::sty::RegionVid as rustc_mir::borrow_check::facts::FactRow>::write::h2cc1e203cd8b8d95
37: 0x7ff8ff0c5d07 - rustc_mir::borrow_check::provide::hca974026c7954712
38: 0x7ff8febc3d7b - <rustc_mir_build::thir::pattern::_match::split_grouped_constructors::Border as core::fmt::Debug>::fmt::h2468913b704d8b89
39: 0x7ff8ff0c2e00 - rustc_mir::borrow_check::provide::hca974026c7954712
40: 0x7ff8ff092e9f - <rustc_mir::util::spanview::SpanViewable as core::fmt::Debug>::fmt::h8fc74e5ad64e2a6b
41: 0x7ff8fbfc9fae - rustc_interface::interface::parse_cfgspecs::hf1434c0a659b9ddd
42: 0x7ff8fbfb7326 - <rls_span::serde_expanded::_IMPL_DESERIALIZE_FOR_OneIndexed::<impl serde::de::Deserialize for rls_span::OneIndexed>::deserialize::__Visitor as serde::de::Visitor>::expecting::h9a9b74719e191e7e
43: 0x7ff8fbf7c877 - <rls_span::serde_expanded::_IMPL_DESERIALIZE_FOR_OneIndexed::<impl serde::de::Deserialize for rls_span::OneIndexed>::deserialize::__Visitor as serde::de::Visitor>::expecting::h9a9b74719e191e7e
44: 0x7ff8fbfcc3dd - rustc_interface::interface::parse_cfgspecs::hf1434c0a659b9ddd
45: 0x7ff8fbf69f5e - <rls_span::serde_expanded::_IMPL_DESERIALIZE_FOR_OneIndexed::<impl serde::de::Deserialize for rls_span::OneIndexed>::deserialize::__Visitor as serde::de::Visitor>::expecting::h9a9b74719e191e7e
46: 0x7ff8fbf7566f - <rls_span::serde_expanded::_IMPL_DESERIALIZE_FOR_OneIndexed::<impl serde::de::Deserialize for rls_span::OneIndexed>::deserialize::__Visitor as serde::de::Visitor>::expecting::h9a9b74719e191e7e
47: 0x7ff8fbfbc034 - <rls_span::serde_expanded::_IMPL_DESERIALIZE_FOR_OneIndexed::<impl serde::de::Deserialize for rls_span::OneIndexed>::deserialize::__Visitor as serde::de::Visitor>::expecting::h9a9b74719e191e7e
48: 0x7ff8fbff5d3d - rustc_interface::passes::QueryContext::print_stats::hd29879a8b3af7832
49: 0x7ff8fbe1957b - tracing_core::event::Event::metadata::h86572d73d587b6bd
50: 0x7ff8fbe1ddb6 - tracing_core::event::Event::metadata::h86572d73d587b6bd
51: 0x7ff8fbdddf02 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
52: 0x7ff8fbdf8ba6 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
53: 0x7ff8fbd81b26 - rustc_errors::snippet::MultilineAnnotation::increase_depth::h93baa802966d31ca
54: 0x7ff8fbe1e53b - tracing_core::event::Event::metadata::h86572d73d587b6bd
55: 0x7ff8fbdf4a34 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
56: 0x7ff8fbd9074c - <rustc_driver::args::Error as core::fmt::Debug>::fmt::h500583d00d12c2d9
57: 0x7ff8fbdf6b28 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
58: 0x7ff8fbdd3a30 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
59: 0x7ff8fbdfa123 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h234a3cece69c9eed
60: 0x7ff8fbd77523 - rustc_errors::snippet::MultilineAnnotation::increase_depth::h93baa802966d31ca
61: 0x7ff947a1f6a7 - std::sys::windows::thread::Thread::new::h04914a10b014a9d7
62: 0x7ff99b6c7bd4 - BaseThreadInitThunk
63: 0x7ff99d2ace51 - RtlUserThreadStart
Query Stack
query stack during panic:
#0 [type_op_ascribe_user_type] evaluating `type_op_ascribe_user_type` `Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [ConstEvaluatable(WithOptConstParam { did: DefId(0:15 ~ bugtest[35b2]::{impl#0}::{constant#0}), const_param_did: None }, [ReLateBound(DebruijnIndex(0), BrAnon(0)), Const { ty: std::num::NonZeroUsize, val: Param(N/#1) }]), TraitPredicate(<[u8; _] as std::marker::Sized>)], reveal: UserFacing }, value: AscribeUserType { mir_ty: fn(&[u8]) -> std::result::Result<&[u8; _], <&[u8; _] as std::convert::TryFrom<&[u8]>>::Error> {<&[u8; _] as std::convert::TryFrom<&[u8]>>::try_from}, def_id: DefId(2:1966 ~ core[5e46]::convert::TryFrom::try_from), user_substs: UserSubsts { substs: [&[u8; _], &[u8]], user_self_ty: None } } } }`
#1 [mir_borrowck] borrow-checking `<A<N> as std::convert::TryFrom<&'a [u8]>>::try_from`
#2 [analysis] running analysis passes on this crate
end of query stack
Possibly related to #77650
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Incremental compilationCategory: This is a bug.`#![feature(const_generics)]``#![feature(generic_const_exprs)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.Performance or correctness regression from one stable version to another.This issue requires a nightly compiler in some way.