-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Associated types, impl traits ~and closures~; oh my, an ICE. #63154
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
Comments
Slight reduction: #![allow(dead_code)]
trait HasAssocType {
type Inner;
}
impl HasAssocType for () {
type Inner = ();
}
trait Tr<I, T>
where
Self: Fn(I),
{
}
impl<I, T, Q> Tr<I, T> for Q where Q: Fn(I) {}
fn f<T>() -> impl Tr<T, T::Inner>
where
T: HasAssocType,
{
|_| ()
}
fn g<T, Y, F>(f: F) -> impl Tr<T, Y>
where
F: Tr<T, Y>,
{
f
}
fn h() {
g(f())(());
} |
Marking P-high. The fact that |
@nagisa Not sure if it is related but I'm writing a parser combinator library (quite similar to nom 5.0), and when I'm not getting the error described above, I'm getting another with one of my test cases. This requires me to boost the I'm not ready to release this code yet and I haven't reduced the second issue like the first. Example depth of these combinators, can obviously get deeper. Along these lines. All functions but the second arguments to // snip
opt(tuple!(
tag("@"),
map(
take_while1(none_of(" ".chars())),
delimited(
tag(";"),
tuple!(
opt(tag("+")),
opt(tuple(host, tag("/"))),
take_while(alt2!(letter, number, tag("-"))),
opt(tuple(
tag("="),
take_while(none_of("\0\0xa\0x0d; ".chars()))
))
)
)
),
space
)),
// snip
|
HA. Okay this gets more weird. Moving
Oh and this one doesn't get to "just work" with miri.
|
Workaround. Passes the ICE and the type mismatch. Still requires fn f<T: HasAssocType<Inner = Y>, Y>() -> impl Tr<T, Y> { /* .. */ } |
@nagisa Using Without the workaround. The IRC test builds in 8.54s on the first pass (ICE) (summary) plus 2.8s on the second (no ICE). (summary). With the workaround. The test builds in 8.49s. (summary). The first and third both spend 61% of the time (5 seconds) on All other tests (much simpler) compile immediately. Edit: No idea why the first even built in the second pass as it should have failed with the type mismatch issue... shrugs |
triage: assigning to self for investigation. |
(haven't had a chance yet to look at this.) |
…nagisa MIR typeck needed more normalize Add some missing normalization calls (@nagisa [was right](#63154 (comment))). Fix #63154
Thanks @pnkfelix ! |
Context: I was helping @WildCryptoFox reduce a different (but similar) ICE from the same project and I started wondering how the reduction in this issue didn't trigger that ICE as well. Closures appear to be irrelevant, and I've reduced the testcase further to: trait Trait {
type Assoc;
}
impl Trait for () {
type Assoc = ();
}
trait Dummy<T> {}
impl<T, U> Dummy<T> for U {}
fn make<T: Trait>() -> impl Dummy<T::Assoc> {}
fn extract<T>(_: impl Dummy<T>) -> Option<T> {
None
}
pub fn ice() {
extract(make::<()>());
} In particular it appears that However, this is not the end of the story - attempting to reduce the testcase further results in other ICEs, not fixed by #65099. The smallest such change to the above snippet is: - impl<T, U> Dummy<T> for U {}
+ impl<T> Dummy<T> for () {} which results in this (spanless) ICE before and after #65099: error: internal compiler error: broken MIR in DefId(...::ice[0]) (NoSolution):
could not prove Binder(TraitPredicate(<impl Dummy<<() as Trait>::Assoc> as Dummy<()>>)) That ICE persists through further reduction, and this is my best so far: trait Trait {
type Assoc;
}
impl Trait for () {
type Assoc = ();
}
fn unit() -> impl Into<<() as Trait>::Assoc> {}
pub fn ice() {
Into::into(unit());
} This looks suspiciously simple, I'm surprised more people haven't hit it yet. |
question I might attempt to pose at the T-compiler meeting: In cases like this, is it best to reopen the same bug when you find a variant that tickles a similar ICE? Or are we better off opening a fresh ticket for the variant code? On the one hand, a proliferation of tickets is not fun. On the other hand, it becomes pretty difficult to track what an issue number represents when you have to interpret phrases like "fixes PR #NNN" as time-relative (i.e. was that phrase written before or after the bug was reopened with a new variant example)... |
I haven't had a chance to look at @eddyb 's new variant yet. I will try to find time to do so, either tomorrow or next week. |
@pnkfelix Part of the reason I feel like this issue should be reopened was because I started from the same codebase @WildCryptoFox got this issue's example from. OTOH, even if it's in the same area, I think it's technically a separate ICE, just one that got dropped accidentally from the first reduction, so I wouldn't mind a new issue either way. (And this time would be good to share the code that is triggering all of these ICEs) |
@eddyb Oh. The code isn't secret just not ready to publish given the ICE issues and poor compilation performance. https://gitlab.com/sio4/code/omnom The |
Just to clarify: it looks to me like the bug exposed from the original (And, as previously mentioned, you currently need to |
I went ahead and filed #65934 to track that bug independently of this one. |
marked with E-needs-mcve since it would be good to factor a minimal test out from the test suite of the omnom source crate |
@pnkfelix I don't understand, #63154 (comment) is just that. |
Don't hide ICEs from previous incremental compiles I think this fixes rust-lang#65401, the compiler does not fail to ICE after the first compilation, tested on the last snippet of [this comment](rust-lang#63154 (comment)). I am not very sure of the fix as I don't understand much of the structure of the compiler.
@eddyb ah sorry, at the time when you posted that comment, the source for omnon was not yet linked here, so I was unaware it had been derived from the test suite for that crate |
Yeah, all the code snippets from @WildCryptoFox (including the original testcase of this issue) are derived from the |
Okay so based on @eddyb's feedback it sounds like we have our MCVE |
While experimenting with some code I hit this ICE. Interestingly, when running
cargo test
a second time, it magically works - skipping the error. Also,cargo miri test
works fine too.I'm on a slightly older nightly because some rustup components are missing on the latest. https://play.rust-lang.org confirms the ICE in both its stable and nightly.
The text was updated successfully, but these errors were encountered: