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

error: internal compiler error: no errors encountered even though delay_span_bug issued #115033

Closed
lukin35 opened this issue Aug 20, 2023 · 6 comments · Fixed by #115039
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lukin35
Copy link

lukin35 commented Aug 20, 2023

can't compile linfa, please show me how to fix

Code

<code>

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (6ef7d16be 2023-08-19)
binary: rustc
commit-hash: 6ef7d16be0fb9d6ecf300c27990f4bff49d22d46
commit-date: 2023-08-19
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0

Error output

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

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

      error: internal compiler error: unresolved inference variable in outlives: ?4t
        --> /public/home/litz/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-4f7dbcce21e258a2/linfa-0.6.1/src/dataset/iter.rs:72:5
         |
      72 |     fn next(&mut self) -> Option<Self::Item> {
         |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
      note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:254:35
               0: <rustc_errors::HandlerInner>::emit_diagnostic
               1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
               2: <rustc_infer::infer::outlives::obligations::TypeOutlives<&rustc_infer::infer::InferCtxt>>::components_must_outlive
               3: <rustc_infer::infer::InferCtxt>::resolve_regions
               4: rustc_hir_analysis::check::compare_impl_item::compare_method_predicate_entailment
               5: rustc_hir_analysis::check::check::check_mod_item_types
               6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
               7: <rustc_query_impl::query_impl::check_mod_item_types::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalModDefId)>>::call_once
               8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
               9: rustc_query_impl::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
              10: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
              11: rustc_hir_analysis::check_crate
              12: rustc_interface::passes::analysis
              13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
              14: <rustc_query_impl::query_impl::analysis::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; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
              16: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
              17: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#6}>
              18: <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>>
              19: 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>>
              20: <<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}
              21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                         at /rustc/6ef7d16be0fb9d6ecf300c27990f4bff49d22d46/library/alloc/src/boxed.rs:2007:9
              22: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                         at /rustc/6ef7d16be0fb9d6ecf300c27990f4bff49d22d46/library/alloc/src/boxed.rs:2007:9
              23: std::sys::unix::thread::Thread::new::thread_start
                         at /rustc/6ef7d16be0fb9d6ecf300c27990f4bff49d22d46/library/std/src/sys/unix/thread.rs:108:17
              24: start_thread
              25: clone
        --> /public/home/litz/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-4f7dbcce21e258a2/linfa-0.6.1/src/dataset/iter.rs:72:5
         |
      72 |     fn next(&mut self) -> Option<Self::Item> {
         |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      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 `/public/home/litz/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-4f7dbcce21e258a2/linfa-0.6.1/rustc-ice-2023-08-20T17:30:52.267253091Z-814448.txt` to your bug report

      note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no

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

      query stack during panic:
      end of query stack
      error: could not compile `linfa` (lib)

@lukin35 lukin35 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 Aug 20, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 20, 2023
@lukin35
Copy link
Author

lukin35 commented Aug 20, 2023

@compiler-errors
Copy link
Member

compiler-errors commented Aug 20, 2023

@jackh726 this is due to #109356. It turns out that skipping over projection goals that we get back from wf::obligations leads to unconstrained infer vars. It's pretty difficult to create a minimal repro of this, though.

This isn't fixed by #114787 because the infer var is coming from within wf::obligations's own normalization.

@compiler-errors compiler-errors added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Aug 20, 2023
@jackh726
Copy link
Member

I'll take a look.

@jackh726
Copy link
Member

jackh726 commented Aug 20, 2023

Pretty rough, but here's an MCVE. Still can probably minimize a bit more:

use std::marker::PhantomData;

trait Data {
    type Elem;
}

struct DatasetBase<R, T> {
    pub records: R,
    pub targets: T,
}

trait Records: Sized {
    type Elem;
}

trait AsTargets {
    type Elem;
}

impl<F, S: Data<Elem = F>> Records for ArrayBase<S> {
    type Elem = F;
}

impl<R, T: AsTargets> AsTargets for DatasetBase<R, T> {
    type Elem = T::Elem;
}

struct DatasetIter<'a, R: Records, T> {
    dataset: T,
    phantom: PhantomData<&'a R::Elem>,
}

pub struct ArrayBase<S> {
    data: S,
}

impl<'a, F, D, T: AsTargets> Iterator for DatasetIter<'a, ArrayBase<D>, T>
where
    D: Data<Elem = F>,
{
    type Item = DatasetBase<F, T::Elem>;

    fn next(&mut self) -> Option<Self::Item> {
        panic!();
    }
}

(edit: updating as I minimize a bit more)

@jackh726 jackh726 added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Aug 20, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 20, 2023
@jackh726
Copy link
Member

Okay, here's the simplest MCVE I can make:

trait Data {
    type Elem;
}

impl<F, S: Data<Elem = F>> Data for ArrayBase<S> {
    type Elem = F;
}

struct DatasetIter<'a, R: Data> {
    data: &'a R::Elem,
}

pub struct ArrayBase<S> {
    data: S,
}

trait Trait {
    type Item;
    fn next() -> Option<Self::Item>;
}

impl<'a, D: Data> Trait for DatasetIter<'a, ArrayBase<D>> {
    type Item = ();

    fn next() -> Option<Self::Item> {
        None
    }
}

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high -needs-triage

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 21, 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) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

5 participants