Repository navigation
ICE !ty.needs_infer() && !ty.has_placeholders() from boxing closure of type dyn for<'a> _ #57843
Description
Activity
- addedI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on Jan 22, 2019 Happens on 1.33.0-beta.3 (!) and 1.33.0-nightly (4c2be9c 2019-01-22), but not on stable.
The ICE does not occur, if you change the line to
struct Foo(Box<dyn ClonableFn<bool>>);Was introduced with nightly-2019-01-04, so somewhere between ec19464...c0bbc39
Based on the commits I guess @nikomatsakis should be able to say something about it
- addedA-type-systemArea: Type systemArea: Type systemP-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
on Jan 24, 2019 triage. Confirm P-high. Assigning to self for initial investigation.
I have confirmed that this was injected by #55517
(We've been asserting
!ty.needs_infer()or some variant thereof in the writeback method for years. I'm yet not sure what changed in #55517 to disrupt that invariant; its possible that something is triggering the assertion that previously did not. Or we might be writing-back a type that in the past we did not write-back...)Also, something potentially of note: #50197 changed the definition of
needs_infer, but was careful to preserve the meaning of the aforementioned assertion by expanding it to!ty.needs_infer() && !ty.has_placeholders()(or, at that time,!ty.has_skol()). This seems like a good (conservative) decision, but it may have interacted in some manner with the changes in #55517.- In particular, the type in question that is triggering the assertion has
has_placeholders(): true.
- In particular, the type in question that is triggering the assertion has
@nick-fischer I don't know if this is of interest to you, but I did find that if you use this slightly different variant with an explicit type on the closure parameter, the code compiles (play):
trait ClonableFn<T> { fn clone(&self) -> Box<dyn Fn(T)>; } impl<T, F: 'static> ClonableFn<T> for F where F: Fn(T) + Clone { fn clone(&self) -> Box<dyn Fn(T)> { Box::new(self.clone()) } } struct Foo(Box<dyn for<'a> ClonableFn<&'a bool>>); fn main() { Foo(Box::new(|_: &bool| ())); // ~~~~~~~ this is what changed }
Interesting ... Thank you!
- changed the title
[-]Compiler crash[/-][+]ICE `!ty.needs_infer() && !ty.has_placeholders()` from box of closure with dyn for<'a> type.[/+]on Jan 31, 2019 - changed the title
[-]ICE `!ty.needs_infer() && !ty.has_placeholders()` from box of closure with dyn for<'a> type.[/-][+]ICE `!ty.needs_infer() && !ty.has_placeholders()` from boxing closure of type dyn for<'a> _[/+]on Jan 31, 2019
While experimenting with clonable closures (and encountering like a thousand
one type is more general than the othererrors), I eventually discovered a scenario which crashes rustc.I tried this code (play:
I expected to see this happen: Actually, I am not sure ... Anyways, I guess I expected to see rustc surviving the input ...
Meta
rustc --version --verbose:rustc 1.33.0-nightly (c0bbc39 2019-01-03)
binary: rustc
commit-hash: c0bbc39
commit-date: 2019-01-03
host: x86_64-unknown-linux-gnu
release: 1.33.0-nightly
LLVM version: 8.0
Backtrace: