Skip to content

ICE: no errors encountered even though delay_span_bug issued, expected ReFree to map to ReEarlyBound #108580

Description

@jswrenn

Code

(Playground)

#![feature(associated_type_bounds, return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

trait Iterator {
    type Item;
}

trait IntoIterator {
    fn into_iterator(&self) -> impl Iterator<Item:> + '_;
}

struct IntoIterFn<F, I>
{
    f: F,
    _marker: core::marker::PhantomData<I>,
}

impl<F, I> IntoIterator for IntoIterFn<F, I>
where
    F: Fn() -> I,
    I: Iterator,
{
    fn into_iterator(&self) -> impl Iterator<Item: '_> {
        (self.f)()
    }
}

Meta

Version:

rustc 1.69.0-nightly (7281249a1 2023-02-27)

Error output

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

error: internal compiler error: expected ReFree to map to ReEarlyBound
  --> src/lib.rs:23:32
   |
23 |     fn into_iterator(&self) -> impl Iterator<Item: '_> {
   |                                ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
              1: <rustc_session::session::Session>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
              2: rustc_hir_analysis::check::compare_impl_item::collect_return_position_impl_trait_in_trait_tys::{closure#0}::{closure#2}
              3: rustc_middle::ty::util::fold_list::<rustc_middle::ty::fold::RegionFolder, rustc_middle::ty::subst::GenericArg, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with<rustc_middle::ty::fold::RegionFolder>::{closure#0}>
              4: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_middle::ty::fold::RegionFolder>
              5: <rustc_middle::ty::context::TyCtxt>::fold_regions::<rustc_middle::ty::Ty, rustc_hir_analysis::check::compare_impl_item::collect_return_position_impl_trait_in_trait_tys::{closure#0}::{closure#2}>
              6: rustc_hir_analysis::check::compare_impl_item::collect_return_position_impl_trait_in_trait_tys
              7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::collect_return_position_impl_trait_in_trait_tys, rustc_query_impl::plumbing::QueryCtxt>
              8: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_return_position_impl_trait_in_trait_tys
              9: <rustc_middle::ty::context::TyCtxt>::bound_return_position_impl_trait_in_trait_tys
             10: rustc_trait_selection::traits::project::opt_normalize_projection_type
             11: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
             12: <&rustc_middle::ty::list::List<rustc_middle::ty::Ty> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection::traits::project::AssocTypeNormalizer>
             13: <rustc_infer::infer::at::At as rustc_trait_selection::traits::project::NormalizeExt>::normalize::<rustc_middle::ty::sty::FnSig>
             14: rustc_hir_analysis::check::compare_impl_item::compare_method_predicate_entailment
             15: rustc_hir_analysis::check::compare_impl_item::compare_impl_method
             16: rustc_hir_analysis::check::check::check_impl_items_against_trait
             17: rustc_hir_analysis::check::check::check_mod_item_types
             18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
             19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
             20: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#6}>
             21: rustc_hir_analysis::check_crate
             22: rustc_interface::passes::analysis
             23: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
             24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
             25: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             26: rustc_span::with_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}>
             27: 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>>
             28: <<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}
             29: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/alloc/src/boxed.rs:1988:9
             30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/alloc/src/boxed.rs:1988:9
             31: std::sys::unix::thread::Thread::new::thread_start
                        at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys/unix/thread.rs:108:17
             32: start_thread
             33: clone
           

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.69.0-nightly (7281249a1 2023-02-27) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack

Activity

  1. added
    C-bugCategory: This is a bug.
    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.
    on Feb 28, 2023
  2. compiler-errors commented on Feb 28, 2023

    @compiler-errors
    Contributor

    This is also not related to associated type bounds:

    #![feature(return_position_impl_trait_in_trait)]
    
    trait Foo {
        fn bar(&self) -> impl Iterator<Item = impl Sized> + '_;
    }
    
    impl Foo for () {
        fn bar(&self) -> impl Iterator + '_ {
            vec![()].into_iter()
        }
    }

    This was fixed by #105255, which was subsequently reverted in #106759. The fix here is to make opaque types inherit their parent's generics, which can probably be done if #106729 lands.

  3. added a commit that references this issue on Jul 1, 2023
  4. added a commit that references this issue on Jul 1, 2023
  5. compiler-errors commented on Jul 6, 2023

    @compiler-errors
    Contributor

    Triage: This no longer iCEs, now it errors with the following message

    error: return type captures more lifetimes than trait definition
     --> src/lib.rs:8:22
      |
    8 |     fn bar(&self) -> impl Iterator + '_ {
      |            -         ^^^^^^^^^^^^^^^^^^
      |            |
      |            this lifetime was captured
      |
    note: hidden type must only reference lifetimes captured by this impl trait
     --> src/lib.rs:4:43
      |
    4 |     fn bar(&self) -> impl Iterator<Item = impl Sized> + '_;
      |                                           ^^^^^^^^^^
      = note: hidden type inferred to be `<impl Iterator + '_ as Iterator>::Item`
    
  6. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Jul 8, 2023
  7. removed their assignment
    on Jul 31, 2023
  8. added a commit that references this issue on Mar 25, 2024
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.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]`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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions