Skip to content

ICE: rustdoc crash computing layouts in const generics #88468

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
barrowsys opened this issue Aug 29, 2021 · 2 comments · Fixed by #91678
Closed

ICE: rustdoc crash computing layouts in const generics #88468

barrowsys opened this issue Aug 29, 2021 · 2 comments · Fixed by #91678
Labels
C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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

@barrowsys
Copy link

barrowsys commented Aug 29, 2021

Code

#![allow(incomplete_features)]
#![feature(const_generics)]
#![feature(const_evaluatable_checked)]

pub struct Assert<const COND: bool>();
pub trait IsTrue {}
impl IsTrue for Assert<true> {}

pub trait IsNotZST {}
impl<T> IsNotZST for T where Assert<{ std::mem::size_of::<T>() > 0 }>: IsTrue {}

/* Not necessary to cause error
pub struct AnyVec<T, const BITS: u32>
where
    T: IsNotZST,
{
    _marker: std::marker::PhantomData<T>,
}
*/

/* Does not cause error
pub struct AnyVec<T, const BITS: u32>
where
    Assert<{ std::mem::size_of::<T>() > 0 }>: IsTrue
{
    _marker: std::marker::PhantomData<T>,
}
*/

Meta

features:

  • const_generics
  • const_evaluatable_checked
rustc 1.56.0-nightly (0035d9dce 2021-08-16)
binary: rustc
commit-hash: 0035d9dcecee49d1f7349932bfa52c05a6f83641
commit-date: 2021-08-16
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Error output

cargo doc

error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:2174:17: `is_trivially_sized` applied to unexpected type: ^0

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1115:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: Unrecognized option: 'crate-version'

error: could not document `rustdoc_err`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_err src/lib.rs -o /tmp/tmp.ul886HIeYd/rustdoc_err/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/tmp/tmp.ul886HIeYd/rustdoc_err/target/debug/deps --crate-version 0.1.0` (exit status: 1)

running the rustdoc command manually without --crate-version

{"message":"compiler/rustc_middle/src/ty/sty.rs:2174:17: `is_trivially_sized` applied to unexpected type: ^0","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror: internal compiler error\u001b[0m\u001b[0m\u001b[1m: compiler/rustc_middle/src/ty/sty.rs:2174:17: `is_trivially_sized` applied to unexpected type: ^0\u001b[0m\n\n"}
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1115:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: 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-compiler&template=ice.md

note: rustc 1.56.0-nightly (0035d9dce 2021-08-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
#0 [layout_raw] computing layout of `*const ^0`
#1 [eval_to_allocation_raw] const-evaluating + checking `<impl at src/lib.rs:10:1: 10:81>::{constant#0}`
end of query stack
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to previous error\u001b[0m\n\n"}
Backtrace

backtrace from the rustdoc command (without --crate-version)

{"message":"compiler/rustc_middle/src/ty/sty.rs:2174:17: `is_trivially_sized` applied to unexpected type: ^0","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror: internal compiler error\u001b[0m\u001b[0m\u001b[1m: compiler/rustc_middle/src/ty/sty.rs:2174:17: `is_trivially_sized` applied to unexpected type: ^0\u001b[0m\n\n"}
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1115:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::ty::sty::<impl rustc_middle::ty::TyS>::is_trivially_sized
   8: rustc_middle::ty::util::<impl rustc_middle::ty::TyS>::is_sized
   9: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_raw_uncached
  10: rustc_middle::ty::layout::layout_raw
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_raw
  13: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::query::TyCtxtAt> as rustc_target::abi::LayoutOf>::layout_of
  14: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  15: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  16: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  17: rustc_query_system::query::plumbing::get_query_impl
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_allocation_raw
  19: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  20: rustc_query_system::query::plumbing::get_query_impl
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  22: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  23: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  24: rustc_infer::infer::InferCtxt::const_eval_resolve
  25: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicate_recursively::{{closure}}::{{closure}}
  26: rustc_data_structures::stack::ensure_sufficient_stack
  27: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicate_recursively
  28: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicates_recursively
  29: rustc_infer::infer::InferCtxt::probe
  30: rustc_trait_selection::traits::select::SelectionContext::evaluate_candidate
  31: rustc_trait_selection::traits::select::SelectionContext::evaluate_stack
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_anon_task
  33: rustc_trait_selection::traits::select::SelectionContext::evaluate_trait_predicate_recursively
  34: rustc_data_structures::stack::ensure_sufficient_stack
  35: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicate_recursively
  36: rustc_infer::infer::InferCtxt::probe
  37: rustc_trait_selection::traits::select::SelectionContext::evaluate_root_obligation
  38: rustc_infer::infer::InferCtxtBuilder::enter_with_canonical
  39: rustc_traits::evaluate_obligation::evaluate_obligation
  40: rustc_query_system::query::plumbing::get_query_impl
  41: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::evaluate_obligation
  42: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  43: rustc_infer::infer::InferCtxtBuilder::enter
  44: rustdoc::clean::blanket_impl::BlanketImplFinder::get_blanket_impls
  45: rustdoc::clean::utils::get_auto_trait_and_blanket_impls
  46: rustdoc::passes::collect_trait_impls::collect_trait_impls
  47: rustdoc::core::run_global_ctxt
  48: rustc_interface::passes::QueryContext::enter
  49: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  50: rustc_span::with_source_map
  51: rustc_interface::interface::create_compiler_and_run
  52: rustdoc::main_options
  53: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: 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-compiler&template=ice.md

note: rustc 1.56.0-nightly (0035d9dce 2021-08-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
#0 [layout_raw] computing layout of `*const ^0`
#1 [eval_to_allocation_raw] const-evaluating + checking `<impl at src/lib.rs:10:1: 10:81>::{constant#0}`
#2 [eval_to_const_value_raw] simplifying constant for the type system `<impl at src/lib.rs:10:1: 10:81>::{constant#0}`
#3 [evaluate_obligation] evaluating trait selection obligation `Assert<{ std::mem::size_of::<T>() > 0 }>: IsTrue`
end of query stack
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to previous error\u001b[0m\n\n"}

@barrowsys barrowsys 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 29, 2021
@jyn514 jyn514 added F-generic_const_exprs `#![feature(generic_const_exprs)]` F-const_generics `#![feature(const_generics)]` requires-nightly This issue requires a nightly compiler in some way. labels Aug 30, 2021
@camelid camelid added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 30, 2021
@barrowsys
Copy link
Author

ICE still occurs on rustc 1.57.0-nightly (a8f2463c6 2021-10-09) with feature flags changed to

#![feature(adt_const_params)]
#![feature(generic_const_exprs)]

@PatchMixolydic
Copy link
Contributor

PatchMixolydic commented Nov 4, 2021

With a bit of modification, this ICE happens on rustc 1.58.0-nightly (baba6687d 2021-11-03) when running cargo build rather than rustdoc (playground):

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

struct Assert<const COND: bool>;
trait IsTrue {}
impl IsTrue for Assert<true> {}

trait IsNotZst {}

impl<T> IsNotZst for T
where
    Assert<{ std::mem::size_of::<T>() > 0 }>: IsTrue,
{}

fn assert_not_zero_sized<T: IsNotZst>(_: T) {}

fn main() {
    assert_not_zero_sized(vec![1, 2, 3]);
}

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Nov 8, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 9, 2021
…al, r=jackh726

Add tests fixed by rust-lang#90023

The following issues were fixed by rust-lang#90023

Fixes rust-lang#79674
Fixes rust-lang#83765
Fixes rust-lang#86033
Fixes rust-lang#90318
Fixes rust-lang#88468

The following issues were duplicates of rust-lang#90654

Fixes rust-lang#86850
Fixes rust-lang#89022

r? `@jackh726`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 10, 2021
…al, r=jackh726

Add tests fixed by rust-lang#90023

The following issues were fixed by rust-lang#90023

Fixes rust-lang#79674
Fixes rust-lang#83765
Fixes rust-lang#86033
Fixes rust-lang#90318
Fixes rust-lang#88468

The following issues were duplicates of rust-lang#90654

Fixes rust-lang#86850
Fixes rust-lang#89022

r? ``@jackh726``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 10, 2021
…al, r=jackh726

Add tests fixed by rust-lang#90023

The following issues were fixed by rust-lang#90023

Fixes rust-lang#79674
Fixes rust-lang#83765
Fixes rust-lang#86033
Fixes rust-lang#90318
Fixes rust-lang#88468

The following issues were duplicates of rust-lang#90654

Fixes rust-lang#86850
Fixes rust-lang#89022

r? ```@jackh726```
@bors bors closed this as completed in d6e9417 Dec 11, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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.

5 participants