Skip to content

normalization ICE during codegen of trait objects with supertraits #56229

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
nikomatsakis opened this issue Nov 26, 2018 · 5 comments · Fixed by #78295
Closed

normalization ICE during codegen of trait objects with supertraits #56229

nikomatsakis opened this issue Nov 26, 2018 · 5 comments · Fixed by #78295
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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.

Comments

@nikomatsakis
Copy link
Contributor

The following example ICEs

impl Mirror for Even {
    type Other = Odd;
}

impl Mirror for Odd {
    type Other = Even;
}

trait Dyn<T: Mirror>: AsRef<<T as Mirror>::Other> { }

impl Dyn<Odd> for Even { }

impl AsRef<Even> for Even {
    fn as_ref(&self) -> &Even {
        self
    }
}

fn code<T: Mirror>(d: &dyn Dyn<T>) -> &T::Other {
    d.as_ref()
}

fn main() {
    println!("{:?}", code(&Even(22)));
}

yields

athena. rustc +nightly ~/tmp/as-ref-bug.rs
error: internal compiler error: src/librustc/traits/codegen/mod.rs:68: Encountered error `Unimplemented` selecting `Binder(<dyn Dyn<Odd> as std::convert::AsRef<Even>>)` during codegen

thread 'main' panicked at 'Box<Any>', src/librustc_errors/lib.rs:600:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


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.32.0-nightly (6acbb5b65 2018-11-25) running on x86_64-unknown-linux-gnu

(Same is true on stable.)

@nikomatsakis nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-trait-system Area: Trait system labels Nov 26, 2018
@arielb1
Copy link
Contributor

arielb1 commented Nov 27, 2018

That's because the ObjectCandidate code is not normalizing the upcast trait refs.

Should we wait for Chalk for the fix?

@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Aug 6, 2019
@kuviman
Copy link

kuviman commented Aug 21, 2019

Hitting this error, any updates?

@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

Triage: no longer ICEs.

@Centril Centril added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Mar 10, 2020
@JohnTitor
Copy link
Member

It's still an ICE, note that we should build/run the snippet to check it (playground).

@JohnTitor JohnTitor removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Mar 13, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 13, 2020
@JohnTitor
Copy link
Member

Triage: It's no longer ICE with the latest nightly, I think it's fixed by #77720.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 23, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 26, 2020
@bors bors closed this as completed in 75bbd80 Oct 26, 2020
@fmease fmease added A-trait-system Area: Trait system and removed A-trait-system Area: Trait system labels Dec 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants