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: failed to normalize std::option::Option<Alias(Projection ... #122044

Closed
matthiaskrgr opened this issue Mar 5, 2024 · 2 comments · Fixed by #126620
Closed

ICE: failed to normalize std::option::Option<Alias(Projection ... #122044

matthiaskrgr opened this issue Mar 5, 2024 · 2 comments · Fixed by #126620
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

use std::hint::black_box;

trait Func {
    type Ret: Id;
}

trait Id {
    type Assoc;
}
impl Id for u32 {}
impl Id for u32 {}

impl<F: FnOnce() -> R, R: Id> Func for F {
    type Ret = R;
}

fn bar() -> impl Copy + Id {
    0u32
}

struct Foo<T: Func> {
    _func: T,
    value: Option<<<T as Func>::Ret as Id>::Assoc>,
}

fn main() {
    let mut fn_def = black_box(Foo {
        _func: bar,
        value: None,
    });
    let fn_ptr = black_box(Foo {
        _func: bar as fn() -> _,
        value: None,
    });

    fn_def.value = fn_ptr.value;
}

original:

use std::hint::black_box;

trait Func {
    type Ret: Id;
}

trait Id {
    type Assoc;
}
impl Id for u32 {
    type Assoc = u32;
}
impl Id for u32 {
    type Assoc = i32;
}

impl<F: FnOnce() -> R, R: Id> Func for F {
    type Ret = R;
}

#[inline(always)]
fn bar() -> impl Copy + Id {
    0u32
}

struct Foo<T: Func> {
    _func: T,
    value: Option<<<T as Func>::Ret as Id>::Assoc>,
}

fn main() {
    let mut fn_def = black_box(Foo {
        _func: bar,
        value: None,
    });
    let fn_ptr = black_box(Foo {
        _func: bar as fn() -> _,
        value: None,
    });
    
    fn_def.value = fn_ptr.value;
    black_box(Foo {
        _func: bar,
        value: None,
    });
}

Version information

rustc 1.78.0-nightly (c7beecf3e 2024-03-05)
binary: rustc
commit-hash: c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e
commit-date: 2024-03-05
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0119]: conflicting implementations of trait `Id` for type `u32`
  --> /tmp/icemaker_global_tempdir.Vcuzw2RFrTGI/rustc_testrunner_tmpdir_reporting.l4vSpjX9SkGn/mvce.rs:11:1
   |
10 | impl Id for u32 {}
   | --------------- first implementation here
11 | impl Id for u32 {}
   | ^^^^^^^^^^^^^^^ conflicting implementation for `u32`

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:187:90: Failed to normalize std::option::Option<Alias(Projection, AliasTy { args: [Alias(Projection, AliasTy { args: [Binder(fn() -> u32, [])], def_id: DefId(0:5 ~ mvce[edfe]::Func::Ret) })], def_id: DefId(0:7 ~ mvce[edfe]::Id::Assoc) })>, maybe try to call `try_normalize_erasing_regions` instead

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
   0:     0x7f454338c754 - std::backtrace_rs::backtrace::libunwind::trace::hb3ca6a58ed9e0cab
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f454338c754 - std::backtrace_rs::backtrace::trace_unsynchronized::h327ee65d2c5d0ca7
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f454338c754 - std::sys_common::backtrace::_print_fmt::h8a71adbcae5a9442
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f454338c754 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5069361c3741e3bd
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f45433ddb2c - core::fmt::rt::Argument::fmt::hc76ed39d719dd67d
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/core/src/fmt/rt.rs:142:9
   5:     0x7f45433ddb2c - core::fmt::write_internal::h7c84a75384687dd4
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/core/src/fmt/mod.rs:1126:17
   6:     0x7f4543381167 - core::fmt::write::h269ee61a459584fc
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/core/src/fmt/mod.rs:1108:67
   7:     0x7f4543381167 - std::io::Write::write_fmt::h8eeafb0d3c9d6dcf
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/io/mod.rs:1846:15
   8:     0x7f454338c504 - std::sys_common::backtrace::_print::h9ab859621d08b838
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/sys_common/backtrace.rs:47:5
   9:     0x7f454338c504 - std::sys_common::backtrace::print::h276f59edd5cafd51
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/sys_common/backtrace.rs:34:9
  10:     0x7f454338f10b - std::panicking::default_hook::{{closure}}::hb04a76c354ad4ca2
  11:     0x7f454338ee67 - std::panicking::default_hook::h13aec473440bd413
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/panicking.rs:292:9
  12:     0x7f45462804cc - std[8dbd9ad68df9295b]::panicking::update_hook::<alloc[3b906e9cacb41ed6]::boxed::Box<rustc_driver_impl[46903fbbfbd2d4f2]::install_ice_hook::{closure#0}>>::{closure#0}
  13:     0x7f454338f822 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb8d4d85a716e33a7
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/alloc/src/boxed.rs:2030:9
  14:     0x7f454338f822 - std::panicking::rust_panic_with_hook::hd5a905865100487a
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/panicking.rs:783:13
  15:     0x7f45462ac9a4 - std[8dbd9ad68df9295b]::panicking::begin_panic::<rustc_errors[3b280157a1a56311]::ExplicitBug>::{closure#0}
  16:     0x7f45462a98c6 - std[8dbd9ad68df9295b]::sys_common::backtrace::__rust_end_short_backtrace::<std[8dbd9ad68df9295b]::panicking::begin_panic<rustc_errors[3b280157a1a56311]::ExplicitBug>::{closure#0}, !>
  17:     0x7f45462a95a6 - std[8dbd9ad68df9295b]::panicking::begin_panic::<rustc_errors[3b280157a1a56311]::ExplicitBug>
  18:     0x7f45462b6131 - <rustc_errors[3b280157a1a56311]::diagnostic::BugAbort as rustc_errors[3b280157a1a56311]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  19:     0x7f454668e10c - <rustc_errors[3b280157a1a56311]::DiagCtxt>::bug::<alloc[3b906e9cacb41ed6]::string::String>
  20:     0x7f454673257b - rustc_middle[ab69c4f92afbdebe]::util::bug::opt_span_bug_fmt::<rustc_span[1f98bb2c9ae0a849]::span_encoding::Span>::{closure#0}
  21:     0x7f454671568a - rustc_middle[ab69c4f92afbdebe]::ty::context::tls::with_opt::<rustc_middle[ab69c4f92afbdebe]::util::bug::opt_span_bug_fmt<rustc_span[1f98bb2c9ae0a849]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  22:     0x7f4546715508 - rustc_middle[ab69c4f92afbdebe]::ty::context::tls::with_context_opt::<rustc_middle[ab69c4f92afbdebe]::ty::context::tls::with_opt<rustc_middle[ab69c4f92afbdebe]::util::bug::opt_span_bug_fmt<rustc_span[1f98bb2c9ae0a849]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  23:     0x7f4544c529d0 - rustc_middle[ab69c4f92afbdebe]::util::bug::bug_fmt
  24:     0x7f454795e731 - <rustc_middle[ab69c4f92afbdebe]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[5a0133e54bb7004d]::fold::TypeFolder<rustc_middle[ab69c4f92afbdebe]::ty::context::TyCtxt>>::fold_ty
  25:     0x7f4547a359d7 - <rustc_mir_dataflow[4dca6c6bfb913a17]::elaborate_drops::DropCtxt<rustc_mir_transform[df1dd399e1c2956f]::elaborate_drops::Elaborator>>::elaborate_drop
  26:     0x7f454478434c - <rustc_mir_transform[df1dd399e1c2956f]::elaborate_drops::ElaborateDrops as rustc_middle[ab69c4f92afbdebe]::mir::MirPass>::run_pass
  27:     0x7f454761400f - rustc_mir_transform[df1dd399e1c2956f]::pass_manager::run_passes_inner
  28:     0x7f4547d25bc6 - rustc_mir_transform[df1dd399e1c2956f]::mir_drops_elaborated_and_const_checked
  29:     0x7f4547d254e1 - rustc_query_impl[6d84502f9670cd53]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6d84502f9670cd53]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ab69c4f92afbdebe]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7f45477474b8 - rustc_query_system[2567e3f9f30a9009]::query::plumbing::try_execute_query::<rustc_query_impl[6d84502f9670cd53]::DynamicConfig<rustc_query_system[2567e3f9f30a9009]::query::caches::VecCache<rustc_span[1f98bb2c9ae0a849]::def_id::LocalDefId, rustc_middle[ab69c4f92afbdebe]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[6d84502f9670cd53]::plumbing::QueryCtxt, false>
  31:     0x7f4547746d8c - rustc_query_impl[6d84502f9670cd53]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f45482e893a - rustc_interface[4f9ebc0114c1dc52]::passes::analysis
  33:     0x7f45482e8119 - rustc_query_impl[6d84502f9670cd53]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6d84502f9670cd53]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ab69c4f92afbdebe]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f4548317b25 - rustc_query_system[2567e3f9f30a9009]::query::plumbing::try_execute_query::<rustc_query_impl[6d84502f9670cd53]::DynamicConfig<rustc_query_system[2567e3f9f30a9009]::query::caches::SingleCache<rustc_middle[ab69c4f92afbdebe]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[6d84502f9670cd53]::plumbing::QueryCtxt, false>
  35:     0x7f4548317889 - rustc_query_impl[6d84502f9670cd53]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f4548326842 - rustc_interface[4f9ebc0114c1dc52]::interface::run_compiler::<core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>, rustc_driver_impl[46903fbbfbd2d4f2]::run_compiler::{closure#0}>::{closure#0}
  37:     0x7f45485f0446 - std[8dbd9ad68df9295b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4f9ebc0114c1dc52]::util::run_in_thread_with_globals<rustc_interface[4f9ebc0114c1dc52]::util::run_in_thread_pool_with_globals<rustc_interface[4f9ebc0114c1dc52]::interface::run_compiler<core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>, rustc_driver_impl[46903fbbfbd2d4f2]::run_compiler::{closure#0}>::{closure#0}, core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>>::{closure#0}, core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>>
  38:     0x7f45485f0272 - <<std[8dbd9ad68df9295b]::thread::Builder>::spawn_unchecked_<rustc_interface[4f9ebc0114c1dc52]::util::run_in_thread_with_globals<rustc_interface[4f9ebc0114c1dc52]::util::run_in_thread_pool_with_globals<rustc_interface[4f9ebc0114c1dc52]::interface::run_compiler<core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>, rustc_driver_impl[46903fbbfbd2d4f2]::run_compiler::{closure#0}>::{closure#0}, core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>>::{closure#0}, core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8c889010effea61c]::result::Result<(), rustc_span[1f98bb2c9ae0a849]::ErrorGuaranteed>>::{closure#1} as core[8c889010effea61c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f4543398f85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h24c0cfbfedc1fa18
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/alloc/src/boxed.rs:2016:9
  40:     0x7f4543398f85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4b4e456aeb7e2c2b
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/alloc/src/boxed.rs:2016:9
  41:     0x7f4543398f85 - std::sys::pal::unix::thread::Thread::new::thread_start::hd6ad0feb9d6b2058
                               at /rustc/c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7f454318055a - <unknown>
  43:     0x7f45431fda3c - <unknown>
  44:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.78.0-nightly (c7beecf3e 2024-03-05) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0119`.

@matthiaskrgr matthiaskrgr 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. C-bug Category: This is a bug. labels Mar 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 5, 2024
@matthiaskrgr
Copy link
Member Author

Regressed in #120847 cc @oli-obk

@matthiaskrgr
Copy link
Member Author

on beta:

error[E0119]: conflicting implementations of trait `Id` for type `u32`
  --> /tmp/im/6D5DCD6BEEA9C6F8503D479EDB2B94D2C111E432766CB91E1C9E18F452DF092D.rs:13:1
   |
10 | impl Id for u32 {
   | --------------- first implementation here
...
13 | impl Id for u32 {
   | ^^^^^^^^^^^^^^^ conflicting implementation for `u32`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0119`.

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 11, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 19, 2024
Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 19, 2024
Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 19, 2024
Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
@bors bors closed this as completed in e7be356 Jun 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 20, 2024
Rollup merge of rust-lang#126620 - oli-obk:taint_errors, r=fee1-dead

Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes rust-lang#122044
fixes rust-lang#123255
fixes rust-lang#123276
fixes rust-lang#125799
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

3 participants