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

Combining default impl with associated type projections leads to delay_span_bug ICE #110171

Closed
CAD97 opened this issue Apr 11, 2023 · 3 comments · Fixed by #110434
Closed

Combining default impl with associated type projections leads to delay_span_bug ICE #110171

CAD97 opened this issue Apr 11, 2023 · 3 comments · Fixed by #110434
Assignees
Labels
C-bug Category: This is a bug. F-specialization `#![feature(specialization)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features 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

@CAD97
Copy link
Contributor

CAD97 commented Apr 11, 2023

Code

[playground] (requires release mode)

#![no_std]
#![feature(specialization)]
#![allow(incomplete_features)]

pub unsafe trait Storage {
    type Handle;
}

pub unsafe trait MultipleStorage: Storage {}

default unsafe impl<S> Storage for S
where
    S: MultipleStorage,
{
}

// the tuple (or any compound type) is required to get an ICE
pub fn ice<S: Storage>(boxed: (S::Handle,)) -> (S::Handle,) {
    boxed
}

Meta

rustc --version: 1.70.0-nightly (2023-04-02 3a8a131)

rustc 1.70.0-nightly (3a8a131e9 2023-04-02)
binary: rustc
commit-hash: 3a8a131e9509c478ece1c58fe0ea2d49463d2300
commit-date: 2023-04-02
host: x86_64-pc-windows-msvc
release: 1.70.0-nightly
LLVM version: 16.0.0

Error output

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

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at    (snip)
Backtrace

  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_middle::ty::context::TyCtxt>::ty_error_misc
             3: rustc_trait_selection::traits::project::normalize_projection_type
             4: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
             5: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
             6: rustc_trait_selection::traits::project::normalize_with_depth_to::<rustc_middle::ty::Predicate>
             7: <rustc_trait_selection::traits::select::SelectionContext>::impl_or_trait_obligations
             8: <rustc_trait_selection::traits::select::SelectionContext>::confirm_candidate
             9: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_stack
            10: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively
            11: rustc_traits::evaluate_obligation::evaluate_obligation
            12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::evaluate_obligation, rustc_query_impl::plumbing::QueryCtxt>
            13: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
            14: rustc_ty_utils::common_traits::is_item_raw
            15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::is_freeze_raw, rustc_query_impl::plumbing::QueryCtxt>
            16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::is_freeze_raw
            17: <rustc_middle::ty::Ty>::is_freeze
            18: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
            19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::deduced_param_attrs, rustc_query_impl::plumbing::QueryCtxt>
            20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::deduced_param_attrs
            21: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
            22: rustc_metadata::rmeta::encoder::encode_metadata_impl
            23: rustc_data_structures::sync::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
            24: rustc_metadata::rmeta::encoder::encode_metadata
            25: rustc_metadata::fs::encode_and_write_metadata
            26: rustc_interface::passes::start_codegen
            27: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
            28: <rustc_interface::queries::Queries>::ongoing_codegen
            29: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
            30: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            31: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_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>>
            32: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_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}
            33: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/3a8a131e9509c478ece1c58fe0ea2d49463d2300/library/alloc/src/boxed.rs:1976:9
            34: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/3a8a131e9509c478ece1c58fe0ea2d49463d2300/library/alloc/src/boxed.rs:1976:9
            35: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/3a8a131e9509c478ece1c58fe0ea2d49463d2300/library/std/src/sys/unix/thread.rs:108:17
            36: start_thread
            37: clone

@rustbot labels modify +F-specialization +requires-nightly +requires-incomplete-features

@CAD97 CAD97 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 Apr 11, 2023
@compiler-errors
Copy link
Member

I understand how this ICE can come about, but I frankly cannot reproduce this. @CAD97, can you help out?

@CAD97
Copy link
Contributor Author

CAD97 commented Apr 16, 2023

Ah, I apparently forgot to list that the ICE requires build --release; building without optimizations doesn't ICE. Reproduces on playground.

@CAD97
Copy link
Contributor Author

CAD97 commented Apr 16, 2023

@rustbot label +F-specialization +requires-nightly +requires-incomplete-features

@rustbot rustbot added F-specialization `#![feature(specialization)]` requires-incomplete-features requires-nightly This issue requires a nightly compiler in some way. labels Apr 16, 2023
@compiler-errors compiler-errors self-assigned this Apr 16, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 17, 2023
…i-obk

Check freeze with right param-env in `deduced_param_attrs`

We're checking if a trait (`Freeze`) holds in a polymorphic function, but not using that function's own (reveal-all) param-env. This causes us to try to eagerly normalize a specializable projection type that has no default value, which causes an ICE.

Fixes rust-lang#110171
@bors bors closed this as completed in a76b157 Apr 17, 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. F-specialization `#![feature(specialization)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features 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

Successfully merging a pull request may close this issue.

3 participants