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 auto trait impls: unexpected result when selecting […] involving const in super trait bounds & item bounds #107715

Closed
donkeyteethUX opened this issue Feb 6, 2023 · 6 comments · Fixed by #123348
Labels
A-auto-traits Area: auto traits (`auto trait Send`) 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

@donkeyteethUX
Copy link

Problem

Minimal example

pub const N: usize = 1;

pub struct MapType<K: Supertrait<V>, V> {
    _array: K::Array,
}

pub trait Subtrait: Supertrait<[u8; N]> {}

pub trait Supertrait<V> {
    type Array: AnotherTrait<V>;
}

pub trait AnotherTrait<V> {
    const LENGTH: usize;
}

pub struct Container<S: Subtrait> {
    _x: MapType<S, [u8; N]>,
}

What I expected: cargo doc works.
What happens:

thread 'rustc' panicked at 'Unexpected result when selecting Container<S> Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [S, [u8; 1]], item_def_id: DefId(0:12 ~ panic[490c]::Supertrait::Array) }, Term::Ty(_)), []), depth=2)', compiler/rustc_trait_selection/src/traits/auto_trait.rs:750:33
stack backtrace:
   0:     0x7f1849b6c9a0 - std::backtrace_rs::backtrace::libunwind::trace::he615646ea344481f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f1849b6c9a0 - std::backtrace_rs::backtrace::trace_unsynchronized::h6ea8eaac68705b9c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1849b6c9a0 - std::sys_common::backtrace::_print_fmt::h7ac486a935ce0bf7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f1849b6c9a0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b5a095d3db2e28f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f1849bc898e - core::fmt::write::h445545b92224a1cd
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f1849b5cb15 - std::io::Write::write_fmt::h55a43474c6520b00
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/io/mod.rs:1682:15
   6:     0x7f1849b6c765 - std::sys_common::backtrace::_print::h65d20526fdb736b0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f1849b6c765 - std::sys_common::backtrace::print::h6555fbe12a1cc41b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f1849b6f56f - std::panicking::default_hook::{{closure}}::hbdf58083140e7ac6
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:267:22
   9:     0x7f1849b6f2aa - std::panicking::default_hook::haef8271c56b74d85
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:286:9
  10:     0x7f1849b6fd78 - std::panicking::rust_panic_with_hook::hfd45b6b6c12d9fa5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:688:13
  11:     0x7f1849b6fb17 - std::panicking::begin_panic_handler::{{closure}}::hf591e8609a75bd4b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:579:13
  12:     0x7f1849b6ce4c - std::sys_common::backtrace::__rust_end_short_backtrace::h81899558795e4ff7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f1849b6f832 - rust_begin_unwind
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
  14:     0x7f1849bc5373 - core::panicking::panic_fmt::h4235fa9b4675b332
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
  15:     0x7f184d8733ea - <rustc_trait_selection[5aec47e3fc81d5cc]::traits::auto_trait::AutoTraitFinder>::evaluate_predicates
  16:     0x5652762e9602 - <rustc_trait_selection[5aec47e3fc81d5cc]::traits::auto_trait::AutoTraitFinder>::find_auto_trait_generics::<rustdoc[85586d594f3d7f89]::clean::types::Generics, <rustdoc[85586d594f3d7f89]::clean::auto_trait::AutoTraitFinder>::generate_for_trait::{closure#0}>
  17:     0x5652761e01d3 - <rustdoc[85586d594f3d7f89]::clean::auto_trait::AutoTraitFinder>::generate_for_trait
  18:     0x565276195391 - <alloc[d987cf4402e5b40a]::vec::Vec<rustdoc[85586d594f3d7f89]::clean::types::Item> as alloc[d987cf4402e5b40a]::vec::spec_from_iter::SpecFromIter<rustdoc[85586d594f3d7f89]::clean::types::Item, core[b97a30f8df81432d]::iter::adapters::filter_map::FilterMap<alloc[d987cf4402e5b40a]::vec::into_iter::IntoIter<rustc_span[14998722174c1bca]::def_id::DefId>, <rustdoc[85586d594f3d7f89]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls::{closure#0}>>>::from_iter
  19:     0x5652761e0f0f - <rustdoc[85586d594f3d7f89]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls
  20:     0x56527613a501 - rustdoc[85586d594f3d7f89]::clean::utils::get_auto_trait_and_blanket_impls
  21:     0x56527626b0d8 - <rustdoc[85586d594f3d7f89]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[85586d594f3d7f89]::visit::DocVisitor>::visit_item
  22:     0x56527626b21a - <rustdoc[85586d594f3d7f89]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[85586d594f3d7f89]::visit::DocVisitor>::visit_item
  23:     0x5652762683d5 - rustdoc[85586d594f3d7f89]::passes::collect_trait_impls::collect_trait_impls
  24:     0x5652762351fd - <rustc_session[87e5e219eb43521c]::session::Session>::time::<rustdoc[85586d594f3d7f89]::clean::types::Crate, rustdoc[85586d594f3d7f89]::core::run_global_ctxt::{closure#7}>
  25:     0x56527604c78c - rustdoc[85586d594f3d7f89]::core::run_global_ctxt
  26:     0x565276236e0b - <rustc_interface[ee1a3f92e887e004]::passes::QueryContext>::enter::<rustdoc[85586d594f3d7f89]::main_args::{closure#1}::{closure#0}::{closure#1}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  27:     0x5652761a6fa4 - <rustc_interface[ee1a3f92e887e004]::interface::Compiler>::enter::<rustdoc[85586d594f3d7f89]::main_args::{closure#1}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  28:     0x56527602aa33 - std[bbad73ae434e23e5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustdoc[85586d594f3d7f89]::main_args::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  29:     0x5652763065ea - <<std[bbad73ae434e23e5]::thread::Builder>::spawn_unchecked_<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustdoc[85586d594f3d7f89]::main_args::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#1} as core[b97a30f8df81432d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7f1849b79843 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4273f95ec44459b3
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  31:     0x7f1849b79843 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70f28fa4ddc269e5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  32:     0x7f1849b79843 - std::sys::unix::thread::Thread::new::thread_start::h85a9c16b988e2bd0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys/unix/thread.rs:108:17
  33:     0x7f1849894b43 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  34:     0x7f1849926a00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  35:                0x0 - <unknown>

Steps

cargo doc (check & build work)

Possible Solution(s)

No response

Notes

No response

Version

rustc 1.66.0 (69f9c33d7 2022-12-12)
binary: rustc
commit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943
commit-date: 2022-12-12
host: x86_64-unknown-linux-gnu
release: 1.66.0
LLVM version: 15.0.2
@donkeyteethUX donkeyteethUX added the C-bug Category: This is a bug. label Feb 6, 2023
@ehuss ehuss transferred this issue from rust-lang/cargo Feb 6, 2023
@ehuss
Copy link
Contributor

ehuss commented Feb 6, 2023

Thanks for the report! I have transferred this to rust-lang/rust as that is where rustdoc issues are tracked.

@ehuss ehuss added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Feb 6, 2023
@GuillaumeGomez
Copy link
Member

Seems to be a compiler bug. Adding the relevant tag.

@GuillaumeGomez GuillaumeGomez added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Feb 7, 2023
@donkeyteethUX
Copy link
Author

Although the MCVE looks a bit esoteric, it actually comes from using EnumMap in an fairly straightforward way. I wouldn't be surprised if others have/will run into this.

@megakorre
Copy link
Contributor

megakorre commented Feb 20, 2023

Ran cargo-bisect-rustc on this and found it regressed in d49e7e7
The PR (#103279) states it's a revert of a previous commit. So maybe it was broken before the commit that needed reverting.

searched nightlies: from nightly-2022-10-23 to nightly-2023-02-20
regressed nightly: nightly-2022-10-27
searched commit range: https://github.com/rust-lang/rust/compare/bed4ad65bf7a1cef39e3d66b3670189581b3b073...1898c34e923bad763e723c68dd9f23a09f9eb0fc
regressed commit: https://github.com/rust-lang/rust/commit/d49e7e7fa13479c11a3733824c78e280e391288b

@fmease

This comment was marked as resolved.

@fmease
Copy link
Member

fmease commented Mar 31, 2024

I can no longer reproduce this issue.

@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 Mar 31, 2024
@fmease fmease changed the title Cargo doc triggers rustc ICE rustdoc: ICE: synthetic auto trait impls: unexpected result when selecting […] involving const generics, super trait bounds & item bounds Mar 31, 2024
@fmease fmease changed the title rustdoc: ICE: synthetic auto trait impls: unexpected result when selecting […] involving const generics, super trait bounds & item bounds rustdoc: ICE: synthetic auto trait impls: unexpected result when selecting […] involving const in super trait bounds & item bounds Apr 2, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 2, 2024
…sts, r=GuillaumeGomez

rustdoc: add a couple of regression tests

Fixes rust-lang#114657.
Fixes rust-lang#112828.
Fixes rust-lang#112242.
Fixes rust-lang#107715.

r? rustdoc
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 2, 2024
…tests, r=GuillaumeGomez

rustdoc: add a couple of regression tests

Fixes rust-lang#114657.
Fixes rust-lang#112828.
Fixes rust-lang#107715.

r? rustdoc
@bors bors closed this as completed in 464f264 Apr 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 2, 2024
Rollup merge of rust-lang#123348 - fmease:add-synth-auto-trait-impls-tests, r=GuillaumeGomez

rustdoc: add a couple of regression tests

Fixes rust-lang#114657.
Fixes rust-lang#112828.
Fixes rust-lang#107715.

r? rustdoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-auto-traits Area: auto traits (`auto trait Send`) 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
6 participants