Skip to content

ICE when generating docs with generic_const_exprs feature #92859

Closed
@jimpo

Description

@jimpo

With the experimental generic_const_exprs feature (#76560), there's a compiler issue that surfaces during documentation generation but not a regular build. In the code example below, cargo build produces an unhelpful error message.

Code

#![feature(generic_const_exprs)]

pub trait Foo: Sized {
	const WIDTH: usize;

	fn arrayify(self) -> [Self; Self::WIDTH];
}

impl<T: Sized> Foo for T {
	const WIDTH: usize = 1;

	fn arrayify(self) -> [Self; Self::WIDTH] {
		[self]
	}
}

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (1bd4fdc94 2022-01-12)

Error output

The error on running cargo +nightly doc is:

error: internal compiler error: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as std::marker::Sized>, polarity:Positive), []), depth=1),Unimplemented)]` resolving bounds after type-checking
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:125:24
Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1bd4fdc943513e1004f498bbf289279c9784fc6f/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/1bd4fdc943513e1004f498bbf289279c9784fc6f/library/core/src/panicking.rs:110:14
   2: core::panicking::panic_display::<&str>
   3: <rustc_errors::HandlerInner>::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   6: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   8: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustdoc::main_options::{closure#0}>::{closure#1}>
   9: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustdoc::main_options::{closure#0}>
  10: rustdoc::main_options
  11: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustdoc::main_args::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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