-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityHigh priorityT-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
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.
#![allow(dead_code)]
trait HasAssocType {
type Inner;
}
impl HasAssocType for () {
type Inner = ();
}
trait Tr<I, T>: Fn(I) -> Option<T> {}
impl<I, T, Q: Fn(I) -> Option<T>> Tr<I, T> for Q {}
fn f<T: HasAssocType>() -> impl Tr<T, T::Inner> {
|_| None
}
fn g<T, Y>(f: impl Tr<T, Y>) -> impl Tr<T, Y> {
f
}
fn h() {
g(f())(());
}
~ $ rustc --edition 2018 mir-ice.rs --test
error: internal compiler error: broken MIR in DefId(0:32 ~ mir_ice[317d]::h[0]) (Terminator { source_info: SourceInfo { span: mir-ice.rs:23:5: 23:11, scope: scope[0] }, kind: _3 = const g::<(), <() as HasAssocType>::Inner, impl Tr<(), <() as HasAssocType>::Inner>>(move _4) -> [return: bb3, unwind: bb4] }): call dest mismatch (impl Tr<(), <() as HasAssocType>::Inner> <- impl Tr<(), ()>): NoSolution
--> mir-ice.rs:22:1
|
22 | / fn h() {
23 | | g(f())(());
24 | | }
| |_^
error: internal compiler error: broken MIR in DefId(0:32 ~ mir_ice[317d]::h[0]) (_2 = &_3): bad assignment (&impl Tr<(), ()> = &impl Tr<(), <() as HasAssocType>::Inner>): NoSolution
--> mir-ice.rs:23:5
|
23 | g(f())(());
| ^^^^^^
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:362:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
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.37.0-nightly (1d9981f04 2019-06-20) running on x86_64-unknown-linux-gnu
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityHigh priorityT-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.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-][MIR] [ICE] Associated types, traits, closures; oh my, an ICE.[/-][+][MIR] [ICE] Associated types, impl traits and closures; oh my, an ICE.[/+]Centril commentedon Jul 31, 2019
Slight reduction:
nagisa commentedon Aug 1, 2019
Marking P-high. The fact that
miri
works and a regular compile does not suggests a missing call tonormalize()
somewhere, which would be fairly easy to fix once it is found.WildCryptoFox commentedon Aug 1, 2019
@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
#![type_length_limit = "N"]
to as suggested after a few iterations 12,792,521 and the builds are getting unusually slow. A common factor for these issues is thatcargo miri test
always works. Does the compiler not like combinators?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
map
return functions. (snippet of IRCv3 message-tags extension)[-][MIR] [ICE] Associated types, impl traits and closures; oh my, an ICE.[/-][+]Associated types, impl traits and closures; oh my, an ICE.[/+]30 remaining items
pnkfelix commentedon Oct 29, 2019
Just to clarify: it looks to me like the bug exposed from the original
omnom
crate (linked above) is exercised by runningcargo test
, not justcargo build
(which runs successfully for me).(And, as previously mentioned, you currently need to
clean
or otherwise remove the incremental compilation state, in between calls; otherwise you will fall into #65401pnkfelix commentedon Oct 29, 2019
I went ahead and filed #65934 to track that bug independently of this one.
pnkfelix commentedon Oct 31, 2019
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
eddyb commentedon Oct 31, 2019
@pnkfelix I don't understand, #63154 (comment) is just that.
Or do you mean a minimal test while still using the library? (IME, that's also tricky, not all combinators can trigger an ICE)
Rollup merge of rust-lang#65470 - traxys:fix_65401, r=michaelwoerister
pnkfelix commentedon Nov 2, 2019
@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
eddyb commentedon Nov 2, 2019
Yeah, all the code snippets from @WildCryptoFox (including the original testcase of this issue) are derived from the
omnom
crate.pnkfelix commentedon Nov 14, 2019
Okay so based on @eddyb's feedback it sounds like we have our MCVE
pnkfelix commentedon Nov 14, 2019
since we have our MCVE (and it seems to approximately match the test I added in PR #65099), and I have independently filed #65934, we can reclose this as fixed.