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

rustdoc: ICE: synthetic blanket impls: no errors encountered even though span_delayed_bug issued #119792

Closed
spearman opened this issue Jan 10, 2024 · 4 comments · Fixed by #125909
Labels
A-synthetic-impls Area: Synthetic impls, used by rustdoc to document auto traits and traits with blanket impls C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@spearman
Copy link

spearman commented Jan 10, 2024

This only happens with rust doc.

Crate builds and runs tests successfully on current master: https://gitlab.com/spearman/math-utils-rs/-/commit/9a16929f40de8a21815cae85d889bca8edf28ae2

ICE occurs with $ cargo doc --no-deps

Code

The backtrace doesn't seem to point to any specific code in the crate.

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (190f4c961 2024-01-09)
binary: rustc
commit-hash: 190f4c96116a3b59b7de4881cfec544be0246d84
commit-date: 2024-01-09
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Error output

Backtrace

$ cargo doc --no-deps
 Documenting math-utils v0.0.13 (/home/spearman/rs/local/utils-math)
error: internal compiler error: no errors encountered even though `span_delayed_bug` issued

error: internal compiler error: Impl DefId(0:4614 ~ math_utils[6851]::types::{impl#286}) was matchable against Obligation(predicate=Binder { value: TraitPredicate(<types::AngleWrapped<_> as std::ops::Rem<_>>, polarity:Positive), bound_vars: [] }, depth=2) but now is not
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/select/mod.rs:2429:45
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxt>::emit_diagnostic
             2: <rustc_errors::DiagCtxt>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
             3: <rustc_trait_selection::traits::select::SelectionContext>::poly_select
             4: rustc_trait_selection::traits::project::opt_normalize_projection_type
             5: rustc_trait_selection::traits::project::poly_project_and_unify_type
             6: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate
             7: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
             8: <rustc_trait_selection::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>
             9: rustc_traits::evaluate_obligation::evaluate_obligation
            10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 2]>>
            11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_type_ir::canonical::Canonical<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>>, rustc_middle::query::erase::Erased<[u8; 2]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            12: rustc_query_impl::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
            13: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
            14: rustdoc::clean::utils::get_auto_trait_and_blanket_impls
            15: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
            16: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
            17: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
            18: rustdoc::passes::collect_trait_impls::collect_trait_impls
            19: rustdoc::core::run_global_ctxt
            20: rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}
            21: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}
            22: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            23: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{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}
            24: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/190f4c96116a3b59b7de4881cfec544be0246d84/library/alloc/src/boxed.rs:2016:9
            25: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/190f4c96116a3b59b7de4881cfec544be0246d84/library/alloc/src/boxed.rs:2016:9
            26: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/190f4c96116a3b59b7de4881cfec544be0246d84/library/std/src/sys/unix/thread.rs:108:17
            27: start_thread
            28: __GI___clone3
          

error: internal compiler error: Impl DefId(0:4713 ~ math_utils[6851]::types::{impl#313}) was matchable against Obligation(predicate=Binder { value: TraitPredicate(<types::AngleWrappedSigned<_> as std::ops::Rem<_>>, polarity:Positive), bound_vars: [] }, depth=2) but now is not
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/select/mod.rs:2429:45
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxt>::emit_diagnostic
             2: <rustc_errors::DiagCtxt>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
             3: <rustc_trait_selection::traits::select::SelectionContext>::poly_select
             4: rustc_trait_selection::traits::project::opt_normalize_projection_type
             5: rustc_trait_selection::traits::project::poly_project_and_unify_type
             6: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate
             7: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
             8: <rustc_trait_selection::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>
             9: rustc_traits::evaluate_obligation::evaluate_obligation
            10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 2]>>
            11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_type_ir::canonical::Canonical<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>>, rustc_middle::query::erase::Erased<[u8; 2]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            12: rustc_query_impl::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
            13: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
            14: rustdoc::clean::utils::get_auto_trait_and_blanket_impls
            15: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
            16: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
            17: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
            18: rustdoc::passes::collect_trait_impls::collect_trait_impls
            19: rustdoc::core::run_global_ctxt
            20: rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}
            21: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}
            22: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            23: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{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}
            24: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/190f4c96116a3b59b7de4881cfec544be0246d84/library/alloc/src/boxed.rs:2016:9
            25: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/190f4c96116a3b59b7de4881cfec544be0246d84/library/alloc/src/boxed.rs:2016:9
            26: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/190f4c96116a3b59b7de4881cfec544be0246d84/library/std/src/sys/unix/thread.rs:108:17
            27: start_thread
            28: __GI___clone3
          

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: please attach the file at `/home/spearman/rs/local/utils-math/rustc-ice-2024-01-10T01_15_36-693223.txt` to your bug report

note: compiler flags: --crate-type lib

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

query stack during panic:
end of query stack
error: could not document `math-utils`

Caused by:
  process didn't exit successfully: `/home/spearman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustdoc --edition=2021 --crate-type lib --crate-name math_utils src/lib.rs -o /home/spearman/rs/local/utils-math/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=199 -C metadata=1228b3c84efd442c -L dependency=/home/spearman/rs/local/utils-math/target/debug/deps --extern cordic=/home/spearman/rs/local/utils-math/target/debug/deps/libcordic-38a1c6708d30398f.rmeta --extern derive_more=/home/spearman/rs/local/utils-math/target/debug/deps/libderive_more-350f12f6eba7e9a6.so --extern either=/home/spearman/rs/local/utils-math/target/debug/deps/libeither-360ce3c4f1737f87.rmeta --extern fixed=/home/spearman/rs/local/utils-math/target/debug/deps/libfixed-e8718b679acab2b3.rmeta --extern fixed_sqrt=/home/spearman/rs/local/utils-math/target/debug/deps/libfixed_sqrt-6fc148de1837bfe5.rmeta --extern rand=/home/spearman/rs/local/utils-math/target/debug/deps/librand-dff2f50eb8111482.rmeta --extern strum=/home/spearman/rs/local/utils-math/target/debug/deps/libstrum-ee1653a868fa76dc.rmeta --extern vek=/home/spearman/rs/local/utils-math/target/debug/deps/libvek-da2680a69e1fa61a.rmeta --crate-version 0.0.13` (exit status: 101)

@spearman spearman 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 Jan 10, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 10, 2024
@spearman spearman changed the title ICE: no errors encountered even though span_delayed_bug issued (rustdoc) ICE: no errors encountered even though span_delayed_bug issued Jan 10, 2024
@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-synthetic-impls Area: Synthetic impls, used by rustdoc to document auto traits and traits with blanket impls E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 10, 2024
@5225225
Copy link
Contributor

5225225 commented Jan 18, 2024

I've been poking at this for a bit, and haven't really gotten a full MCVE (it still depends on num-traits (version 0.2.17) being in the dependency tree), but it's definitely much simpler.

extern crate num_traits;

pub(crate) struct Rad<S>(S);
pub(crate) struct AngleWrapped<S>(S);

impl<S> std::ops::Add for AngleWrapped<S> {
    type Output = ();

    fn add(self, other: Self) -> Self::Output {
        loop {}
    }
}

impl<S> std::ops::Add<Rad<S>> for AngleWrapped<S> {
    type Output = ();

    fn add(self, angle: Rad<S>) -> Self::Output {
        loop {}
    }
}

impl<S> std::ops::Sub for AngleWrapped<S> {
    type Output = ();

    fn sub(self, other: Self) -> Self::Output {
        loop {}
    }
}

impl<S> std::ops::Sub<Rad<S>> for AngleWrapped<S> {
    type Output = ();

    fn sub(self, angle: Rad<S>) -> Self::Output {
        loop {}
    }
}

impl<S> std::ops::Mul<S> for AngleWrapped<S> {
    type Output = ();

    fn mul(self, scalar: S) -> Self::Output {
        loop {}
    }
}

impl<S> std::ops::Div for AngleWrapped<S> {
    type Output = ();

    fn div(self, other: Self) -> Self::Output {
        loop {}
    }
}

impl<S> std::ops::Rem for AngleWrapped<S> {
    type Output = ();

    fn rem(self, other: Self) -> Self::Output {
        loop {}
    }
}

@5225225
Copy link
Contributor

5225225 commented Jan 18, 2024

Also, bisected this and got

searched nightlies: from nightly-2023-12-14 to nightly-2023-12-15
regressed nightly: nightly-2023-12-15
searched commit range: eeff92a...de686cb
regressed commit: d23e1a6

bisected with cargo-bisect-rustc v0.6.7

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2023-12-14 --end=2023-12-15 --preserve -- doc 

Looks like #117749 ?

@Luk-ESC
Copy link
Contributor

Luk-ESC commented Feb 3, 2024

Minimized to:

struct Wrapper<T>(T);

trait Div<Rhs> {}
trait Mul<Rhs> {
    type Output;
}

impl<T> Mul<T> for Wrapper<T> {
    type Output = ();
}

impl<T> Div<Self> for Wrapper<T> {}

pub trait NumOps<Rhs> {}

impl<T, Rhs> NumOps<Rhs> for T where T: Mul<Rhs, Output = ()> + Div<Rhs> {}

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Feb 28, 2024
@fmease fmease added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 30, 2024
@fmease
Copy link
Member

fmease commented Apr 30, 2024

#119792 (comment)

Triage: I can no longer reproduce this. Can be closed once a regression test has been added.

@fmease fmease changed the title (rustdoc) ICE: no errors encountered even though span_delayed_bug issued rustdoc: ICE: synthetic blanket impls: no errors encountered even though span_delayed_bug issued Jun 3, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 3, 2024
…ket-impls, r=GuillaumeGomez

rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes rust-lang#119792 (also passes in rust-lang#125907 in case you were wondering).

r? rustdoc
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 3, 2024
…ket-impls, r=GuillaumeGomez

rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes rust-lang#119792 (also passes in rust-lang#125907 in case you were wondering).

r? rustdoc
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 3, 2024
…ket-impls, r=GuillaumeGomez

rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes rust-lang#119792 (also passes in rust-lang#125907 in case you were wondering).

r? rustdoc
Noratrieb added a commit to Noratrieb/rust that referenced this issue Jun 4, 2024
…ket-impls, r=GuillaumeGomez

rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes rust-lang#119792 (also passes in rust-lang#125907 in case you were wondering).

r? rustdoc
Noratrieb added a commit to Noratrieb/rust that referenced this issue Jun 4, 2024
…ket-impls, r=GuillaumeGomez

rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes rust-lang#119792 (also passes in rust-lang#125907 in case you were wondering).

r? rustdoc
@bors bors closed this as completed in 6abb7fb Jun 4, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 4, 2024
Rollup merge of rust-lang#125909 - fmease:rustdoc-add-test-synth-blanket-impls, r=GuillaumeGomez

rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes rust-lang#119792 (also passes in rust-lang#125907 in case you were wondering).

r? rustdoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-synthetic-impls Area: Synthetic impls, used by rustdoc to document auto traits and traits with blanket impls C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants