Skip to content

ICE: Failed to normalize Alias(Projection, AliasTy .. #113272

Closed

Description

@matthiaskrgr

Code

trait Trait {
    type RefTarget;
}

impl Trait for () where Missing: Trait {}

struct Other {
    data: <() as Trait>::RefTarget,
}

fn main() {
    unsafe {
        std::mem::transmute::<Option<()>, Option<&Other>>(None);
    }
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (5bd28f5ea 2023-06-28)
binary: rustc
commit-hash: 5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0
commit-date: 2023-06-28
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

<output>
Backtrace

error[E0412]: cannot find type `Missing` in this scope
 --> treereduce.out:5:25
  |
5 | impl Trait for () where Missing: Trait {}
  |                         ^^^^^^^ not found in this scope

error[E0046]: not all trait items implemented, missing: `RefTarget`
 --> treereduce.out:5:1
  |
2 |     type RefTarget;
  |     -------------- `RefTarget` from trait
...
5 | impl Trait for () where Missing: Trait {}
  | ^^^^^^^^^^^^^^^^^ missing `RefTarget` in implementation

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:195:90: Failed to normalize <() as Trait>::RefTarget, maybe try to call `try_normalize_erasing_regions` instead

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/compiler/rustc_errors/src/lib.rs:1650:9
stack backtrace:
   0:     0x7f645761be31 - std::backtrace_rs::backtrace::libunwind::trace::h8bc3e596fd6e6181
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f645761be31 - std::backtrace_rs::backtrace::trace_unsynchronized::h9a0656fedca2f962
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f645761be31 - std::sys_common::backtrace::_print_fmt::h11ca79bc953fda0e
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f645761be31 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h23585af82c540d61
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f645767d5df - core::fmt::rt::Argument::fmt::h1e7f4bcecbee3fbb
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/fmt/rt.rs:138:9
   5:     0x7f645767d5df - core::fmt::write::h41633f265152b738
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f645760e967 - std::io::Write::write_fmt::hdf9fdeebf4391d4c
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/io/mod.rs:1714:15
   7:     0x7f645761bc45 - std::sys_common::backtrace::_print::h0761f433dadea582
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f645761bc45 - std::sys_common::backtrace::print::hffcd468cc9baf957
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f645761e9f3 - std::panicking::default_hook::{{closure}}::h70eb212f41458c90
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:269:22
  10:     0x7f645761e784 - std::panicking::default_hook::hf217f8886a1385fc
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:288:9
  11:     0x7f645642217b - <rustc_driver_impl[ea51492c730803db]::install_ice_hook::{closure#0} as core[6e72eb595340d7ba]::ops::function::FnOnce<(&core[6e72eb595340d7ba]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7f645761f21e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hdf84d12f536c7065
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2024:9
  13:     0x7f645761f21e - std::panicking::rust_panic_with_hook::h7901b0073bb3ed74
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:709:13
  14:     0x7f64568f6d91 - std[4a840e81aae3439]::panicking::begin_panic::<rustc_errors[74566eb9727f9d9c]::ExplicitBug>::{closure#0}
  15:     0x7f64568f5106 - std[4a840e81aae3439]::sys_common::backtrace::__rust_end_short_backtrace::<std[4a840e81aae3439]::panicking::begin_panic<rustc_errors[74566eb9727f9d9c]::ExplicitBug>::{closure#0}, !>
  16:     0x7f64568f4626 - std[4a840e81aae3439]::panicking::begin_panic::<rustc_errors[74566eb9727f9d9c]::ExplicitBug>
  17:     0x7f645696ae94 - <rustc_errors[74566eb9727f9d9c]::HandlerInner>::bug::<alloc[6fd48550c51b5745]::string::String>
  18:     0x7f645696ad16 - <rustc_errors[74566eb9727f9d9c]::Handler>::bug::<alloc[6fd48550c51b5745]::string::String>
  19:     0x7f64568f204c - rustc_middle[9f74ec5cb00a905a]::util::bug::opt_span_bug_fmt::<rustc_span[624dabdd61f2978b]::span_encoding::Span>::{closure#0}
  20:     0x7f64568f1f8a - rustc_middle[9f74ec5cb00a905a]::ty::context::tls::with_opt::<rustc_middle[9f74ec5cb00a905a]::util::bug::opt_span_bug_fmt<rustc_span[624dabdd61f2978b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f64568f1f5a - rustc_middle[9f74ec5cb00a905a]::ty::context::tls::with_context_opt::<rustc_middle[9f74ec5cb00a905a]::ty::context::tls::with_opt<rustc_middle[9f74ec5cb00a905a]::util::bug::opt_span_bug_fmt<rustc_span[624dabdd61f2978b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f645488cc4d - rustc_middle[9f74ec5cb00a905a]::util::bug::bug_fmt
  23:     0x7f64549cf295 - <rustc_middle[9f74ec5cb00a905a]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder>::normalize_generic_arg_after_erasing_regions
  24:     0x7f64549cef43 - <rustc_middle[9f74ec5cb00a905a]::ty::Ty as rustc_type_ir[2174c24ce5957ab4]::fold::TypeFoldable<rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt>>::fold_with::<rustc_middle[9f74ec5cb00a905a]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder>
  25:     0x7f6454c26fec - <rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt>::struct_tail_erasing_lifetimes
  26:     0x7f64554e6d15 - <rustc_middle[9f74ec5cb00a905a]::ty::layout::SizeSkeleton>::compute
  27:     0x7f645690e0c1 - <rustc_middle[9f74ec5cb00a905a]::ty::layout::SizeSkeleton>::compute::{closure#1}
  28:     0x7f64554e6fd7 - <rustc_middle[9f74ec5cb00a905a]::ty::layout::SizeSkeleton>::compute
  29:     0x7f64559e88f2 - <rustc_hir_typeck[510371791de31c85]::fn_ctxt::FnCtxt>::check_transmute
  30:     0x7f6454d17195 - rustc_hir_typeck[510371791de31c85]::typeck
  31:     0x7f64544533ee - rustc_query_impl[a5bf74a69bd3660]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5bf74a69bd3660]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7f64544533be - <rustc_query_impl[a5bf74a69bd3660]::query_impl::typeck::dynamic_query::{closure#2} as core[6e72eb595340d7ba]::ops::function::FnOnce<(rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt, rustc_span[624dabdd61f2978b]::def_id::LocalDefId)>>::call_once
  33:     0x7f645452891d - rustc_query_system[d65e888f3fe19f8d]::query::plumbing::try_execute_query::<rustc_query_impl[a5bf74a69bd3660]::DynamicConfig<rustc_query_system[d65e888f3fe19f8d]::query::caches::VecCache<rustc_span[624dabdd61f2978b]::def_id::LocalDefId, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a5bf74a69bd3660]::plumbing::QueryCtxt, false>
  34:     0x7f6455dce971 - rustc_query_impl[a5bf74a69bd3660]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f64545a5bad - rustc_query_impl[a5bf74a69bd3660]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5bf74a69bd3660]::query_impl::used_trait_imports::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 8usize]>>
  36:     0x7f64545a5b0e - <rustc_query_impl[a5bf74a69bd3660]::query_impl::used_trait_imports::dynamic_query::{closure#2} as core[6e72eb595340d7ba]::ops::function::FnOnce<(rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt, rustc_span[624dabdd61f2978b]::def_id::LocalDefId)>>::call_once
  37:     0x7f645452891d - rustc_query_system[d65e888f3fe19f8d]::query::plumbing::try_execute_query::<rustc_query_impl[a5bf74a69bd3660]::DynamicConfig<rustc_query_system[d65e888f3fe19f8d]::query::caches::VecCache<rustc_span[624dabdd61f2978b]::def_id::LocalDefId, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a5bf74a69bd3660]::plumbing::QueryCtxt, false>
  38:     0x7f6455daa741 - rustc_query_impl[a5bf74a69bd3660]::query_impl::used_trait_imports::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7f64558f4af0 - rustc_hir_analysis[5549e2304bca0734]::check_unused::check_crate
  40:     0x7f64558f1e31 - rustc_hir_analysis[5549e2304bca0734]::check_crate
  41:     0x7f64558ea91a - rustc_interface[b943f00ad50b5541]::passes::analysis
  42:     0x7f6455933aba - rustc_query_impl[a5bf74a69bd3660]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5bf74a69bd3660]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 1usize]>>
  43:     0x7f6455933aa9 - <rustc_query_impl[a5bf74a69bd3660]::query_impl::analysis::dynamic_query::{closure#2} as core[6e72eb595340d7ba]::ops::function::FnOnce<(rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt, ())>>::call_once
  44:     0x7f6455ab2da8 - rustc_query_system[d65e888f3fe19f8d]::query::plumbing::try_execute_query::<rustc_query_impl[a5bf74a69bd3660]::DynamicConfig<rustc_query_system[d65e888f3fe19f8d]::query::caches::SingleCache<rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a5bf74a69bd3660]::plumbing::QueryCtxt, false>
  45:     0x7f6455ab2b79 - rustc_query_impl[a5bf74a69bd3660]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f6455a86a55 - <rustc_middle[9f74ec5cb00a905a]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  47:     0x7f64556b9341 - <rustc_interface[b943f00ad50b5541]::interface::Compiler>::enter::<rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}::{closure#2}, core[6e72eb595340d7ba]::result::Result<core[6e72eb595340d7ba]::option::Option<rustc_interface[b943f00ad50b5541]::queries::Linker>, rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  48:     0x7f64556b4575 - rustc_span[624dabdd61f2978b]::set_source_map::<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  49:     0x7f64556b3996 - <scoped_tls[8088cff701f74b4a]::ScopedKey<rustc_span[624dabdd61f2978b]::SessionGlobals>>::set::<rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  50:     0x7f64556b2f46 - std[4a840e81aae3439]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b943f00ad50b5541]::util::run_in_thread_pool_with_globals<rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  51:     0x7f64556b2cee - <<std[4a840e81aae3439]::thread::Builder>::spawn_unchecked_<rustc_interface[b943f00ad50b5541]::util::run_in_thread_pool_with_globals<rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#1} as core[6e72eb595340d7ba]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  52:     0x7f6457629695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h61eb867555625a06
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2010:9
  53:     0x7f6457629695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb80c29f89b136b72
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2010:9
  54:     0x7f6457629695 - std::sys::unix::thread::Thread::new::thread_start::hf4205715d65b27a6
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys/unix/thread.rs:108:17
  55:     0x7f645309644b - <unknown>
  56:     0x7f6453119e40 - <unknown>
  57:                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.72.0-nightly (5bd28f5ea 2023-06-28) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [used_trait_imports] finding used_trait_imports `main`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0046, E0412.
For more information about an error, try `rustc --explain E0046`.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Jul 2, 2023
  2. matthiaskrgr commented on Jul 2, 2023

    @matthiaskrgr
    MemberAuthor

    Regression in nightly-2022-05-28

    found 8 bors merge commits in the specified range
      commit[0] 2022-05-26: Auto merge of #97434 - matthiaskrgr:rollup-7j3y16l, r=matthiaskrgr
      commit[1] 2022-05-26: Auto merge of #97386 - nnethercote:optimize-pos-adjustments, r=bjorn3
      commit[2] 2022-05-27: Auto merge of #96298 - petrochenkov:fromgen, r=estebank
      commit[3] 2022-05-27: Auto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors
      commit[4] 2022-05-27: Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb
      commit[5] 2022-05-27: Auto merge of #97442 - hafeoz:master, r=GuillaumeGomez
      commit[6] 2022-05-27: Auto merge of #96046 - oli-obk:const_typeck, r=cjgillot
      commit[7] 2022-05-27: Auto merge of #96790 - lqd:update_jemalloc, r=Mark-Simulacrum
    ERROR: no CI builds available between 490324f7b29d5f1a1e063a563045d790091ed639 and ebbcbfc236ced21d5e6a92269edb704692ff26b8 within last 167 days
    
  3. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Oct 23, 2023
  4. added a commit that references this issue on Nov 3, 2023
  5. matthiaskrgr commented on Feb 14, 2024

    @matthiaskrgr
    MemberAuthor

    This regressed again in #120847 cc @oli-obk

  6. removed
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Feb 14, 2024
  7. oli-obk commented on Feb 16, 2024

    @oli-obk
    Contributor
  8. changed the title [-]ICE: failed to normalize[/-] [+]ICE: `Failed to normalize Alias(Projection, AliasTy ..`[/+] on Apr 4, 2024
  9. matthiaskrgr commented on Apr 4, 2024

    @matthiaskrgr
    MemberAuthor

    The above code from the playground

    trait Trait {
        type RefTarget;
    }
    
    impl Trait for () where Missing: Trait {}
    
    struct Other {
        data: <() as Trait>::RefTarget,
    }
    
    const fn foo() {
        unsafe {
            std::mem::transmute::<Option<()>, Option<&Other>>(None);
        }
    }
    
    struct Foo {
        bar: [(); {
            foo();
            42
        }],
    }
    
    fn main() {}

    bisects to nightly-2019-07-14

    looking for regression commit between 2019-07-13 and 2019-07-14
    fetching (via remote github) commits from max(71f9384, 2019-07-11) to 69656fa
    ending github query because we found starting sha: 71f9384
    get_commits_between returning commits, len: 7
    commit[0] 2019-07-12: Auto merge of #61462 - GuillaumeGomez:fix-local-storage, r=Manishearth
    commit[1] 2019-07-12: Auto merge of #62635 - Centril:rollup-potvfnk, r=Centril
    commit[2] 2019-07-13: Auto merge of #62613 - lzutao:clippy-up, r=Manishearth
    commit[3] 2019-07-13: Auto merge of #61953 - Centril:shared-from-iter, r=RalfJung
    commit[4] 2019-07-13: Auto merge of #60266 - albins:polonius-liveness, r=nikomatsakis
    commit[5] 2019-07-13: Auto merge of #62468 - rust-lang:mutable-overloaded-operators, r=estebank
    commit[6] 2019-07-13: Auto merge of #62659 - Centril:rollup-90oz643, r=Centril

  10. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Apr 4, 2024
  11. apiraino commented on Apr 8, 2024

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-medium

  12. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Apr 8, 2024
  13. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on Apr 15, 2024
  14. added a commit that references this issue on May 8, 2024
    e997508
  15. added a commit that references this issue on May 8, 2024
    b30ff19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions