Closed DutchGhost closed 2 years ago
Reduced:
enum Bug<S> {
Var = {
let x: S = 0;
0
},
}
ICE most likely occurs in:
I cannot seem to reproduce this without an AnonConst
, so cc @varkor.
Reduced even more:
#![feature(type_ascription)]
enum Bug<S> {
Var = 0: S,
}
(Please include all 3 variants thus far in a regression test.)
I looked into this briefly and found that on this line:
...that self
has the value:
Generics { parent: None, parent_count: 0, params: [], param_def_id_to_index: {}, has_self: false, has_late_bound_regions: None }
Digging a bit deeper, the generics appear to be empty because of the following lines:
I can confirm that adding #![feature(const_generics)]
makes this code compile, so I suspect that this is blocked on #43408.
What would be the consequences of always returning the DefId?
What would be the consequences of always returning the DefId?
It causes query cycle errors at the moment.
Discussed at T-compiler meeting. Due to all the known examples being compile-time errors, the ICE here does not seem so strong a hazard as to warrant weekly visits during triage.
(Certainly failing more gracefully would be great. But its not something we're going to e.g. block a release on.)
Downgrading priority to P-medium.
Some relevant examples. This gives an (incorrect) error on stable that S: Sized
does not hold:
use std::marker::PhantomData;
use std::mem::{self, MaybeUninit};
struct Bug<S> {
A: [(); {
let x: Option<S> = None;
0
}],
}
This ICEs on stable:
use std::marker::PhantomData;
use std::mem::{self, MaybeUninit};
struct Bug<S> {
A: [(); {
let x: Option<Box<S>> = None;
0
}],
}
Is there a reason why we can't just disallow type parameters from appearing within constants during resolve, like we do for type parameters from outer functions? Obviously const generics/lazy normization willl loosen this rule.
@skinny121 good point, I imagine that might work.
Another variant on this bug:
struct Bug<S:?Sized> {
A: [(); {
let x: Option<Box<Self>> = None;
0
}],
B: S
}
Triage: The two examples that Centril posted (https://github.com/rust-lang/rust/issues/67945#issuecomment-571251334 and https://github.com/rust-lang/rust/issues/67945#issuecomment-571252306) are no longer ICEs in the latest nightly. Possibly related to #70825?
Maybe we should just add tests then?
Maybe we should just add tests then?
Sounds good! I'll do later.
Another variant (though likely the same):
use std::mem::MaybeUninit;
struct Bug<S> {
A: [(); {
let x: S = MaybeUninit::uninit();
let b = &*(&x as *const _ as *const S);
0
}],
}
This gives a different to the original, despite being essentially the same code.
Triage: All the snippets including the original are no longer ICE with the latest nightly: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=fc90d68f3fd2b8958e7365870eee6202
The following ICE's on nightly and beta:
Backtrace:
``` thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/da3629b05f8f1b425a738bfe9fe9aedd47c5417a/src/libcore/slice/mod.rs:2791:10 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88 1: backtrace::backtrace::trace_unsynchronized at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:77 3: