Skip to content

rustdoc: ICE: synthetic auto trait impls: unexpected result when selecting […] involving unsatisfied bounds, projections and super trait bounds #114657

Closed

Description

@iquerejeta

Code

This is the least I've managed to reduce the code:

pub trait Foo {
    type FooType;
}

pub trait Bar<const A: usize>: Foo<FooType = <Self as Bar<A>>::BarType> {
    type BarType;
}

pub(crate) const B: usize = 5;

pub trait Tec: Bar<B> {}

pub struct Structure<C: Tec> {
    _field: C::BarType,
}

Meta

rustc --version --verbose:

rustc 1.71.1 (eb26296b5 2023-08-03)
binary: rustc
commit-hash: eb26296b556cef10fb713a38f3d16b9886080f26
commit-date: 2023-08-03
host: aarch64-apple-darwin
release: 1.71.1
LLVM version: 16.0.5

With nightly version

rustc 1.73.0-nightly (f88a8b71c 2023-08-08)
binary: rustc
commit-hash: f88a8b71cebb730cbd5058c45ebcae1d4d9be377
commit-date: 2023-08-08
host: aarch64-apple-darwin
release: 1.73.0-nightly
LLVM version: 17.0.0

the compiler asks me to change the Structure as follows:

pub struct Structure<C: Tec + Bar<5>> {
    _field: <C as Bar<B>>::BarType,
}

and now the error no longer occurs.

Error output

After running the cargo doc command, I get the following:

thread 'rustc' panicked at 'Unexpected result when selecting Structure<C> Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [C, Const { ty: usize, kind: Leaf(0x0000000000000005) }], def_id: DefId(0:7 ~ rust_sodium[23d3]::Bar::BarType) }, Term::Ty(_)), []), depth=2)', compiler/rustc_trait_selection/src/traits/auto_trait.rs:756:33
stack backtrace:
   0:        0x10627acc0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb75be2413dd8ceb3
   1:        0x1062c9a64 - core::fmt::write::h95d50546e769656f
   2:        0x106270e2c - std::io::Write::write_fmt::hce019ca594763835
   3:        0x10627ab14 - std::sys_common::backtrace::print::hae7307dcada41b2a
   4:        0x10627d578 - std::panicking::default_hook::{{closure}}::h30c41986d637ef23
   5:        0x10627d380 - std::panicking::default_hook::h81d03189ef2e7e78
   6:        0x10e72ff98 - rustc_driver_impl[21827c9a287a9f15]::install_ice_hook::{closure#0}
   7:        0x10627dc2c - std::panicking::rust_panic_with_hook::he8360f4d28da55fc
   8:        0x10627da0c - std::panicking::begin_panic_handler::{{closure}}::he9e07d605072520f
   9:        0x10627b0a0 - std::sys_common::backtrace::__rust_end_short_backtrace::he03bf52f9c1eb73a
  10:        0x10627d780 - _rust_begin_unwind
  11:        0x1062f49e0 - core::panicking::panic_fmt::ha5f5ca2311fff2ad
  12:        0x1122eba90 - <rustc_trait_selection[96b496d6d05954f1]::traits::auto_trait::AutoTraitFinder>::evaluate_predicates
  13:        0x1051c41f4 - <rustc_trait_selection[96b496d6d05954f1]::traits::auto_trait::AutoTraitFinder>::find_auto_trait_generics::<rustdoc[426ea5acc7761888]::clean::types::Generics, <rustdoc[426ea5acc7761888]::clean::auto_trait::AutoTraitFinder>::generate_for_trait::{closure#0}>
  14:        0x1050cc2a8 - <rustdoc[426ea5acc7761888]::clean::auto_trait::AutoTraitFinder>::generate_for_trait
  15:        0x105122808 - <alloc[e0f95eb21a34f6a8]::vec::Vec<rustdoc[426ea5acc7761888]::clean::types::Item> as alloc[e0f95eb21a34f6a8]::vec::spec_from_iter::SpecFromIter<rustdoc[426ea5acc7761888]::clean::types::Item, core[6a5f4426c52daa32]::iter::adapters::filter_map::FilterMap<alloc[e0f95eb21a34f6a8]::vec::into_iter::IntoIter<rustc_span[2eda851f0959417e]::def_id::DefId>, <rustdoc[426ea5acc7761888]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls::{closure#0}>>>::from_iter
  16:        0x1050cc86c - <rustdoc[426ea5acc7761888]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls
  17:        0x10507d76c - rustdoc[426ea5acc7761888]::clean::utils::get_auto_trait_and_blanket_impls
  18:        0x1051fb170 - <rustdoc[426ea5acc7761888]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[426ea5acc7761888]::visit::DocVisitor>::visit_item
  19:        0x1051fb240 - <rustdoc[426ea5acc7761888]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[426ea5acc7761888]::visit::DocVisitor>::visit_item
  20:        0x1051fbd34 - <rustdoc[426ea5acc7761888]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[426ea5acc7761888]::visit::DocVisitor>::visit_crate
  21:        0x105091a30 - <rustc_session[1039b6c2e3771dcd]::session::Session>::time::<alloc[e0f95eb21a34f6a8]::vec::Vec<rustdoc[426ea5acc7761888]::clean::types::Item>, rustdoc[426ea5acc7761888]::passes::collect_trait_impls::collect_trait_impls::{closure#0}>
  22:        0x1051f94cc - rustdoc[426ea5acc7761888]::passes::collect_trait_impls::collect_trait_impls
  23:        0x105091d28 - <rustc_session[1039b6c2e3771dcd]::session::Session>::time::<rustdoc[426ea5acc7761888]::clean::types::Crate, rustdoc[426ea5acc7761888]::core::run_global_ctxt::{closure#7}>
  24:        0x1051a808c - rustdoc[426ea5acc7761888]::core::run_global_ctxt
  25:        0x105092064 - <rustc_session[1039b6c2e3771dcd]::session::Session>::time::<(rustdoc[426ea5acc7761888]::clean::types::Crate, rustdoc[426ea5acc7761888]::config::RenderOptions, rustdoc[426ea5acc7761888]::formats::cache::Cache), rustdoc[426ea5acc7761888]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  26:        0x10523c070 - <rustc_middle[a39402582bfd677]::ty::context::GlobalCtxt>::enter::<rustdoc[426ea5acc7761888]::main_args::{closure#1}::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  27:        0x10504f878 - <rustc_interface[df80c09a2aa6fb7f]::interface::Compiler>::enter::<rustdoc[426ea5acc7761888]::main_args::{closure#1}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  28:        0x105201938 - rustc_span[2eda851f0959417e]::set_source_map::<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustdoc[426ea5acc7761888]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  29:        0x104fd0214 - <scoped_tls[80ce123946cbe7a6]::ScopedKey<rustc_span[2eda851f0959417e]::SessionGlobals>>::set::<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustdoc[426ea5acc7761888]::main_args::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  30:        0x1050b901c - std[12e62f360352ccd]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustdoc[426ea5acc7761888]::main_args::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  31:        0x1051904c0 - <<std[12e62f360352ccd]::thread::Builder>::spawn_unchecked_<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustdoc[426ea5acc7761888]::main_args::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#1} as core[6a5f4426c52daa32]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:        0x106286640 - std::sys::unix::thread::Thread::new::thread_start::h06dea01d0985d944
  33:        0x196397fa8 - __pthread_joiner_wake

error: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.71.1 (eb26296b5 2023-08-03) running on aarch64-apple-darwin

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 `rust-sodium`

Caused by:
  process didn't exit successfully: `/Users/queremendi/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustdoc --edition=2018 --crate-type lib --crate-name rust_sodium src/lib.rs -o /Users/queremendi/iohk/CryptoLibs/rust-testing/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=244 -C metadata=cfbf9925d0133061 -L dependency=/Users/queremendi/iohk/CryptoLibs/rust-testing/target/debug/deps --crate-version 0.1.0` (exit status: 101)

Backtrace

Output seems the same

thread 'rustc' panicked at 'Unexpected result when selecting Structure<C> Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [C, Const { ty: usize, kind: Leaf(0x0000000000000005) }], def_id: DefId(0:7 ~ rust_sodium[23d3]::Bar::BarType) }, Term::Ty(_)), []), depth=2)', compiler/rustc_trait_selection/src/traits/auto_trait.rs:756:33
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <rustc_trait_selection::traits::auto_trait::AutoTraitFinder>::evaluate_predicates
   3: <rustc_trait_selection::traits::auto_trait::AutoTraitFinder>::find_auto_trait_generics::<rustdoc::clean::types::Generics, <rustdoc::clean::auto_trait::AutoTraitFinder>::generate_for_trait::{closure#0}>
   4: <rustdoc::clean::auto_trait::AutoTraitFinder>::generate_for_trait
   5: <alloc::vec::Vec<rustdoc::clean::types::Item> as alloc::vec::spec_from_iter::SpecFromIter<rustdoc::clean::types::Item, core::iter::adapters::filter_map::FilterMap<alloc::vec::into_iter::IntoIter<rustc_span::def_id::DefId>, <rustdoc::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls::{closure#0}>>>::from_iter
   6: <rustdoc::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls
   7: rustdoc::clean::utils::get_auto_trait_and_blanket_impls
   8: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
   9: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
  10: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_crate
  11: <rustc_session::session::Session>::time::<alloc::vec::Vec<rustdoc::clean::types::Item>, rustdoc::passes::collect_trait_impls::collect_trait_impls::{closure#0}>
  12: rustdoc::passes::collect_trait_impls::collect_trait_impls
  13: <rustc_session::session::Session>::time::<rustdoc::clean::types::Crate, rustdoc::core::run_global_ctxt::{closure#7}>
  14: rustdoc::core::run_global_ctxt
  15: <rustc_session::session::Session>::time::<(rustdoc::clean::types::Crate, rustdoc::config::RenderOptions, rustdoc::formats::cache::Cache), rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  16: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  17: <rustc_interface::interface::Compiler>::enter::<rustdoc::main_args::{closure#1}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  18: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}::{closure#0}>
  19: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.71.1 (eb26296b5 2023-08-03) running on aarch64-apple-darwin

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 `rust-sodium`

Caused by:
  process didn't exit successfully: `/Users/queremendi/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustdoc --edition=2018 --crate-type lib --crate-name rust_sodium src/lib.rs -o /Users/queremendi/iohk/CryptoLibs/rust-testing/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=244 -C metadata=cfbf9925d0133061 -L dependency=/Users/queremendi/iohk/CryptoLibs/rust-testing/target/debug/deps --crate-version 0.1.0` (exit status: 101)

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 Aug 9, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 9, 2023
  3. fmease commented on Aug 10, 2023

    @fmease
    Member

    Related if not duplicate of one of: #105199, #107715, #114097.

    @rustbot label -needs-triage T-rustdoc A-auto-traits A-synthetic-impls

  4. added
    A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)
    A-synthetic-implsArea: Synthetic impls, used by rustdoc to document auto traits and traits with blanket impls
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 10, 2023
  5. drahnr commented on Oct 8, 2023

    @drahnr
    Contributor

    I can't seem to reproduce the cargo doc ICE with

    pub trait Foo {
        type FooType;
    }
    
    pub trait Bar<const A: usize>: Foo<FooType = <Self as Bar<A>>::BarType> {
        type BarType;
    }
    
    pub(crate) const B: usize = 5;
    
    pub trait Tec: Bar<B> {}
    
    pub struct Structure<C: Tec + Bar<5>> {
        _field: <C as Bar<B>>::BarType,
    }

    and

    rustc 1.73.0 (cc66ad468 2023-10-03)

  6. fmease commented on Mar 31, 2024

    @fmease
    Member

    I can't seem to reproduce the […] ICE […]

    Me neither, seems to have been fixed. Potentially by err's “ParamEnv PR” or by one of the PRs that made rustdoc execute more of rustc's stages.

    Fixed: ICE → errors (unsatisfied bounds).

  7. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Mar 31, 2024
  8. changed the title [-]Compiler error when running cargo doc[/-] [+]rustdoc: synthetic auto trait impls: `unexpected result when selecting […]` involving unsatisfied bounds, projections and super trait bounds[/+] on Mar 31, 2024
  9. changed the title [-]rustdoc: synthetic auto trait impls: `unexpected result when selecting […]` involving unsatisfied bounds, projections and super trait bounds[/-] [+]rustdoc: ICE: synthetic auto trait impls: `unexpected result when selecting […]` involving unsatisfied bounds, projections and super trait bounds[/+] on Mar 31, 2024
  10. added a commit that references this issue on Apr 2, 2024
    f03ff3d
  11. added 2 commits that reference this issue on Apr 2, 2024
    3c90cfa
    464f264
  12. added a commit that references this issue on Apr 2, 2024
    4d28bdd
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

    A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)A-synthetic-implsArea: Synthetic impls, used by rustdoc to document auto traits and traits with blanket implsC-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.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.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions