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: broken MIR with type_alias_impl_trait #116332

Closed
kawadakk opened this issue Oct 2, 2023 · 1 comment · Fixed by #116415
Closed

ICE: broken MIR with type_alias_impl_trait #116332

kawadakk opened this issue Oct 2, 2023 · 1 comment · Fixed by #116415
Labels
C-bug Category: This is a bug. 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

@kawadakk
Copy link
Contributor

kawadakk commented Oct 2, 2023

Code

rustc src/lib.rs -Copt-level=2

#![feature(type_alias_impl_trait)]
#![crate_type = "lib"]

pub trait Tr {
    fn get(&self) -> u32;
}

impl Tr for (u32,) {
    #[inline]
    fn get(&self) -> u32 { self.0 }
}

pub fn tr1() -> impl Tr {
    (32,)
}

pub fn tr2() -> impl Tr {
    struct Inner {
        x: X,
    }
    
    type X = impl Tr;
    
    impl Tr for Inner {
        fn get(&self) -> u32 {
            self.x.get()
        }
    }

    Inner {
        x: tr1(),
    }
}

(Playground)

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (e0d7ed1f4 2023-10-01)
binary: rustc
commit-hash: e0d7ed1f453fb54578cc96dfea859b0e7be15016
commit-date: 2023-10-01
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.2

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(DefId(0:13 ~ lib[4350]::tr2::{impl#0}::get)) (after phase change to runtime-optimized) at bb0[1]:
                                Alias(Opaque, AliasTy { args: [], def_id: DefId(0:18 ~ lib[4350]::tr2::X::{opaque#0}) }) does not have fields
  --> src/lib.rs:10:28
   |
10 |     fn get(&self) -> u32 { self.0 }
   |                            ^^^^^^
   |
Backtrace

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(DefId(0:13 ~ lib[4350]::tr2::{impl#0}::get)) (after phase change to runtime-optimized) at bb0[1]:
                                Alias(Opaque, AliasTy { args: [], def_id: DefId(0:18 ~ lib[4350]::tr2::X::{opaque#0}) }) does not have fields
  --> src/lib.rs:10:28
   |
10 |     fn get(&self) -> u32 { self.0 }
   |                            ^^^^^^
   |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:94:25
         0: <rustc_errors::HandlerInner>::emit_diagnostic
         1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         2: <rustc_const_eval::transform::validate::CfgChecker>::fail::<alloc::string::String>
         3: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
         4: rustc_mir_transform::pass_manager::run_passes_inner
         5: rustc_mir_transform::optimized_mir
         6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         8: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
         9: <rustc_middle::ty::context::TyCtxt>::instance_mir
        10: rustc_monomorphize::collector::collect_items_rec::{closure#0}
        11: rustc_monomorphize::collector::collect_items_rec
        12: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        14: <rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        16: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        17: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        18: rustc_interface::passes::start_codegen
        19: <rustc_interface::queries::Queries>::ongoing_codegen
        20: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Resu
lt<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        21: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span
::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        22: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2007:9
        23: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2007:9
        24: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/sys/unix/thread.rs:108:17
        25: start_thread
        26: __clone3
  --> src/lib.rs:10:28
   |
10 |     fn get(&self) -> u32 { self.0 }
   |                            ^^^^^^

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: please attach the file at `/tmp/ice/rustc-ice-2023-10-02T07:44:08.697812242Z-3453279.txt` to your bug report

note: compiler flags: -C opt-level=2

query stack during panic:
end of query stack

rustc-ice-*.txt

delayed span bug: broken MIR in Item(DefId(0:13 ~ lib[4350]::tr2::{impl#0}::get)) (after phase change to runtime-optimized) at bb0[1]:
Alias(Opaque, AliasTy { args: [], def_id: DefId(0:18 ~ lib[4350]::tr2::X::{opaque#0}) }) does not have fields
   0: <rustc_errors::HandlerInner>::emit_diagnostic
   1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   2: <rustc_const_eval::transform::validate::CfgChecker>::fail::<alloc::string::String>
   3: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
   4: rustc_mir_transform::pass_manager::run_passes_inner
   5: rustc_mir_transform::optimized_mir
   6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
   7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
   8: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
   9: <rustc_middle::ty::context::TyCtxt>::instance_mir
  10: rustc_monomorphize::collector::collect_items_rec::{closure#0}
  11: rustc_monomorphize::collector::collect_items_rec
  12: rustc_monomorphize::partitioning::collect_and_partition_mono_items
  13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
  14: <rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
  15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
  16: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  17: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  18: rustc_interface::passes::start_codegen
  19: <rustc_interface::queries::Queries>::ongoing_codegen
  20: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(),
 rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  21: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::Erro
rGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2007:9
  23: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2007:9
  24: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/sys/unix/thread.rs:108:17
  25: start_thread
  26: __clone3



rustc version: 1.75.0-nightly (e0d7ed1f4 2023-10-01)
platform: x86_64-unknown-linux-gnu

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

#115759 cc @oli-obk

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 5, 2023
Move subtyper below reveal_all and change reveal_all

In previous attempt rust-lang#116378 we tried to handle `Opaque` in few different places, but this isn't necessary, after moving subtyper below reveal_all and calling `super_place` on reveal_all, issues cease to exist.

r? `@oli-obk`

Fixes rust-lang#116332
Fixes rust-lang#116265
Fixes rust-lang#116383
Fixes rust-lang#116333
@bors bors closed this as completed in 08cc742 Oct 5, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 5, 2023
Rollup merge of rust-lang#116415 - ouz-a:move_subtyper, r=oli-obk

Move subtyper below reveal_all and change reveal_all

In previous attempt rust-lang#116378 we tried to handle `Opaque` in few different places, but this isn't necessary, after moving subtyper below reveal_all and calling `super_place` on reveal_all, issues cease to exist.

r? ``@oli-obk``

Fixes rust-lang#116332
Fixes rust-lang#116265
Fixes rust-lang#116383
Fixes rust-lang#116333
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 5, 2023
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
4 participants