Skip to content
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

ICE with (hopefully) illegal CoerceUnsized impl #68013

Closed
nikomatsakis opened this issue Jan 8, 2020 · 2 comments
Closed

ICE with (hopefully) illegal CoerceUnsized impl #68013

nikomatsakis opened this issue Jan 8, 2020 · 2 comments
Labels
C-bug Category: This is a bug. F-coerce_unsized The `CoerceUnsized` trait glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jan 8, 2020

I was experimenting with CoerceUnsized and I encountered an ICE with this example:

#[derive(Clone)]
struct Redirectable<'a, T: ?Sized> {
    data: Rc<Cell<&'a T>>
}

impl<U, T: CoerceUnsized<U>> CoerceUnsized<Redirectable<'_, U>> for Redirectable<'_, T> {}

This is hopefully an illegal CoerceUnsized impl, as it would permit us to do illegal mutation (see the full playground link above for the context). Possible duplicate of #44861.

Note that the ICE requires a feature gate.

@nikomatsakis nikomatsakis added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-coerce_unsized The `CoerceUnsized` trait labels Jan 8, 2020
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Jan 8, 2020
@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Jan 8, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 15, 2020
@eddyb
Copy link
Member

eddyb commented Mar 22, 2020

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `&mut T: std::marker::Unsize`
#1 [coerce_unsized_info] processing `<Redirectable<'_, T> as std::ops::CoerceUnsized<Redirectable<'_, U>>>`
#2 [coherent_trait] coherence checking all impls of trait `std::ops::CoerceUnsized`
#3 [analysis] running analysis passes on this crate
end of query stack

Judging by this, I'd say this isn't that scary, since it ICEs while trying to check the validity of the CoerceUnsized impl.

But also, &T never implements Unsize, so this could never compile even if the checking was buggy, is Rc<Cell<&T>> the intended example, or is that one too many indirections?

@Alexendoo
Copy link
Member

Fixed by #72194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-coerce_unsized The `CoerceUnsized` trait glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants