-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: internal compiler error: broken MIR in DefId #105821
Comments
I got another instance of this here: (sorry for the large producer) terrarier2111/Miri-weirdness@705ced8 And this is the error:
|
Shorter variant that avoids #![allow(incomplete_features)]
#![feature(adt_const_params, const_ptr_read, generic_const_exprs)]
#![allow(dead_code)]
const fn catone<const M: usize>(_a: &[u8; M]) -> [u8; M + 1]
where
[(); M + 1]:,
{
unimplemented!()
}
struct Catter<const A: &'static [u8]>;
impl<const A: &'static [u8]> Catter<A>
where
[(); A.len() + 1]:,
{
const ZEROS: &'static [u8; A.len()] = &[0_u8; A.len()];
const R: &'static [u8] = &catone(Self::ZEROS);
}
fn main() {} Regression in nightly-2021-12-06. In earlier versions, the compiler reported "error: overly complex generic constant". Commits in range
|
Just to clarify, the issue is almost certainly just in |
Update: the issue is somewhere in the use of #![allow(incomplete_features)]
#![feature(adt_const_params, generic_const_exprs)]
const fn str_to_arr<const FOO: &'static str>() -> [u8; FOO.len()] {
let mut out = [0; FOO.len()];
let bytes = FOO.as_bytes();
let mut i = 0;
while i < bytes.len() {
out[i] = bytes[i];
i += 1;
}
out
}
const fn concat_strs<const A: &'static str, const B: &'static str>() -> &'static str
where
[(); A.len()]:,
[(); B.len()]:,
[(); A.len() + B.len()]:,
{
struct Inner<const A: &'static str, const B: &'static str>;
impl<const A: &'static str, const B: &'static str> Inner<A, B>
where
[(); A.len()]:,
[(); B.len()]:,
[(); A.len() + B.len()]:,
{
const ARRA: [u8; A.len()] = str_to_arr::<A>();
const ARRB: [u8; B.len()] = str_to_arr::<B>();
const ARRJOIN: [u8; A.len() + B.len()] = {
let mut out = [0; A.len() + B.len()];
let mut i = 0;
while i < A.len() {
out[i] = Self::ARRA[i];
i += 1;
}
while i - A.len() < B.len() {
out[i] = Self::ARRB[i - A.len()];
i += 1;
}
out
};
const STRJOIN: &str = unsafe { std::str::from_utf8_unchecked(&Self::ARRJOIN) };
}
Inner::<A, B>::STRJOIN
}
const TESTL: &str = "Hello, ";
const TESTR: &str = "world!";
const TESTJOIN: &str = concat_strs::<TESTL, TESTR>();
fn main() {
println!("'{TESTL}'");
println!("'{TESTR}'");
println!("'{TESTJOIN}'");
} This was as part of trying to confirm the issue was not in #[repr(C)]
struct ConcatJoin<const M: usize, const N: usize> {
left: [u8; M],
right: [u8; N],
}
#[repr(C)]
union ConcatJoiner<const M: usize, const N: usize>
where
[(); M + N]:,
{
whole: ManuallyDrop<[u8; M + N]>,
split: ManuallyDrop<ConcatJoin<M, N>>,
}
const fn concat_arrs<const M: usize, const N: usize>(a: [u8; M], b: [u8; N]) -> [u8; M + N]
where
[(); M + N]:,
{
unsafe {
let joiner = ConcatJoiner {
split: ManuallyDrop::new(ConcatJoin { left: a, right: b }),
};
let join = joiner.whole;
ManuallyDrop::into_inner(join)
}
} and then const ARRA: [u8; A.len()] = str_to_arr::<A>();
const ARRB: [u8; B.len()] = str_to_arr::<B>();
const ARRJOIN: [u8; A.len() + B.len()] = concat_arrs(Self::ARRA, Self::ARRB);
const STRJOIN: &str = unsafe { std::str::from_utf8_unchecked(&Self::ARRJOIN) }; I get the exact same issue as in what was initially reported. |
No longer ICEs since #107434 |
Signed-off-by: Yuki Okushi <[email protected]>
Rollup of 7 pull requests Successful merges: - rust-lang#108143 (rustdoc: search by macro when query ends with `!`) - rust-lang#108394 (Make `x doc --open` work on every book) - rust-lang#108427 (Recover from for-else and while-else) - rust-lang#108462 (Fix `VecDeque::append` capacity overflow for ZSTs) - rust-lang#108568 (Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs) - rust-lang#108604 (Add regression test for rust-lang#107280) - rust-lang#108605 (Add regression test for rust-lang#105821) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
I'm back. This time I tried concatenating non-literal
&'static str
s.Code
Why? Excellent question, next please.
Meta
rustc --version --verbose
:Error output
Backtrace
RUST_BACKTRACE=1
:RUST_BACKTRACE=full
The text was updated successfully, but these errors were encountered: