Skip to content

ICE while compiling doctests with generic_const_exprs due to failed normalization #94287

Closed
@tspiteri

Description

@tspiteri

Code

#![feature(generic_const_exprs)]

use core::str::FromStr;

pub struct If<const CONDITION: bool>;
pub trait True {}
impl True for If<true> {}

/**
```rust
use fcg4::FixedI32;
use core::str::FromStr;
let _ = <FixedI32<16>>::from_str("");
```
*/
pub struct FixedI32<const FRAC: u32>;

impl<const FRAC: u32> FromStr for FixedI32<FRAC>
where
    If<{ FRAC <= 32 }>: True,
{
    type Err = ();
    fn from_str(_s: &str) -> Result<Self, Self::Err> {
        unimplemented!()
    }
}

Meta

rustc +nightly --version --verbose:

rustc 1.61.0-nightly (68369a041 2022-02-22)
binary: rustc
commit-hash: 68369a041cea809a87e5bd80701da90e0e0a4799
commit-date: 2022-02-22
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

   Compiling fcg4 v0.1.0 (/home/trevor/try/fcg4)
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/lib.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

warning: `fcg4` (lib) generated 1 warning
warning: `fcg4` (lib test) generated 1 warning (1 duplicate)
    Finished test [unoptimized + debuginfo] target(s) in 0.51s
     Running unittests (target/debug/deps/fcg4-a4a2d1392befbdc2)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests fcg4
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /home/trevor/try/fcg4/src/lib.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

warning: 1 warning emitted


running 1 test
test src/lib.rs - FixedI32 (line 9) ... FAILED

failures:

---- src/lib.rs - FixedI32 (line 9) stdout ----
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:179:90: Failed to normalize std::result::Result<fcg4::FixedI32<FRAC>, <fcg4::FixedI32<FRAC> as std::str::FromStr>::Err>, maybe try to call `try_normalize_erasing_regions` instead

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1160:9
stack backtrace:
   0:     0x7f20a0fb5c4c - std::backtrace_rs::backtrace::libunwind::trace::hd70f18a67bf1064d
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f20a0fb5c4c - std::backtrace_rs::backtrace::trace_unsynchronized::hed700f39aaa9560e
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f20a0fb5c4c - std::sys_common::backtrace::_print_fmt::h05ffc8c800d3fd6e
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f20a0fb5c4c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc3335dc9ac9ea141
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f20a101569c - core::fmt::write::h8ba7e47d56fb9287
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f20a0fa5dc8 - std::io::Write::write_fmt::hcc4602e4a7d8cb4e
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/io/mod.rs:1657:15
   6:     0x7f20a0fb9c17 - std::sys_common::backtrace::_print::hfefb27db9027fc13
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f20a0fb9c17 - std::sys_common::backtrace::print::h3b5c5f5af201c47a
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f20a0fb9c17 - std::panicking::default_hook::{{closure}}::h9364b8e096329e42
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:295:22
   9:     0x7f20a0fb98cf - std::panicking::default_hook::hbb3fd2f25c08d7b9
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:314:9
  10:     0x7f20a174d1f1 - rustc_driver[f891c625c383a9d9]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f20a0fba4e6 - std::panicking::rust_panic_with_hook::hb8806bff47a676e3
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:702:17
  12:     0x7f20a281e7d1 - std[ae485eafb9945fc4]::panicking::begin_panic::<rustc_errors[46ae601afbef80b]::ExplicitBug>::{closure#0}
  13:     0x7f20a281e736 - std[ae485eafb9945fc4]::sys_common::backtrace::__rust_end_short_backtrace::<std[ae485eafb9945fc4]::panicking::begin_panic<rustc_errors[46ae601afbef80b]::ExplicitBug>::{closure#0}, !>
  14:     0x7f20a2824c3f - std[ae485eafb9945fc4]::panicking::begin_panic::<rustc_errors[46ae601afbef80b]::ExplicitBug>
  15:     0x7f20a2831d2d - std[ae485eafb9945fc4]::panic::panic_any::<rustc_errors[46ae601afbef80b]::ExplicitBug>
  16:     0x7f20a2830fb7 - <rustc_errors[46ae601afbef80b]::HandlerInner>::bug
  17:     0x7f20a2830ab0 - <rustc_errors[46ae601afbef80b]::Handler>::bug
  18:     0x7f20a26ac9e1 - rustc_middle[af08c1827787b92b]::ty::context::tls::with_opt::<rustc_middle[af08c1827787b92b]::util::bug::opt_span_bug_fmt<rustc_span[ed66fbb5b325921d]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7f20a26acc10 - rustc_middle[af08c1827787b92b]::util::bug::opt_span_bug_fmt::<rustc_span[ed66fbb5b325921d]::span_encoding::Span>
  20:     0x7f20a26acb86 - rustc_middle[af08c1827787b92b]::util::bug::bug_fmt
  21:     0x7f20a345323e - <rustc_middle[af08c1827787b92b]::ty::Ty as rustc_middle[af08c1827787b92b]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[af08c1827787b92b]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder>
  22:     0x7f20a34dd6a3 - <&rustc_middle[af08c1827787b92b]::ty::list::List<rustc_middle[af08c1827787b92b]::ty::Ty> as rustc_middle[af08c1827787b92b]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[af08c1827787b92b]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder>
  23:     0x7f20a34afedc - <rustc_middle[af08c1827787b92b]::ty::instance::Instance>::fn_sig_for_fn_abi
  24:     0x7f20a34cc3fa - rustc_middle[af08c1827787b92b]::ty::layout::fn_abi_of_instance
  25:     0x7f20a2fff654 - rustc_query_system[2ff4193db23014b8]::query::plumbing::try_execute_query::<rustc_query_impl[ee134f3220c51e19]::plumbing::QueryCtxt, rustc_query_system[2ff4193db23014b8]::query::caches::DefaultCache<rustc_middle[af08c1827787b92b]::ty::ParamEnvAnd<(rustc_middle[af08c1827787b92b]::ty::instance::Instance, &rustc_middle[af08c1827787b92b]::ty::list::List<rustc_middle[af08c1827787b92b]::ty::Ty>)>, core[480e1a3512c30a12]::result::Result<&rustc_target[c1e1aa64239babc1]::abi::call::FnAbi<rustc_middle[af08c1827787b92b]::ty::Ty>, rustc_middle[af08c1827787b92b]::ty::layout::FnAbiError>>>
  26:     0x7f20a306541d - <rustc_query_impl[ee134f3220c51e19]::Queries as rustc_middle[af08c1827787b92b]::ty::query::QueryEngine>::fn_abi_of_instance
  27:     0x7f20a299a8d2 - <rustc_codegen_llvm[7aaec6d572baadb8]::context::CodegenCx as rustc_codegen_ssa[5aff939f5d3f7d2]::traits::declare::PreDefineMethods>::predefine_fn
  28:     0x7f20a298e8e0 - rustc_codegen_llvm[7aaec6d572baadb8]::base::compile_codegen_unit::module_codegen
  29:     0x7f20a36046fe - rustc_codegen_llvm[7aaec6d572baadb8]::base::compile_codegen_unit
  30:     0x7f20a362d26c - rustc_codegen_ssa[5aff939f5d3f7d2]::base::codegen_crate::<rustc_codegen_llvm[7aaec6d572baadb8]::LlvmCodegenBackend>
  31:     0x7f20a35f138a - <rustc_codegen_llvm[7aaec6d572baadb8]::LlvmCodegenBackend as rustc_codegen_ssa[5aff939f5d3f7d2]::traits::backend::CodegenBackend>::codegen_crate
  32:     0x7f20a35e28b7 - <rustc_session[a72f812e583e62a4]::session::Session>::time::<alloc[8d22a39036d29e39]::boxed::Box<dyn core[480e1a3512c30a12]::any::Any>, rustc_interface[cc74a9e713f7bc13]::passes::start_codegen::{closure#0}>
  33:     0x7f20a35c9ec6 - <rustc_interface[cc74a9e713f7bc13]::passes::QueryContext>::enter::<<rustc_interface[cc74a9e713f7bc13]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[480e1a3512c30a12]::result::Result<alloc[8d22a39036d29e39]::boxed::Box<dyn core[480e1a3512c30a12]::any::Any>, rustc_errors[46ae601afbef80b]::ErrorReported>>
  34:     0x7f20a35c051f - <rustc_interface[cc74a9e713f7bc13]::queries::Queries>::ongoing_codegen
  35:     0x7f20a359970d - <rustc_interface[cc74a9e713f7bc13]::interface::Compiler>::enter::<rustc_driver[f891c625c383a9d9]::run_compiler::{closure#1}::{closure#2}, core[480e1a3512c30a12]::result::Result<core[480e1a3512c30a12]::option::Option<rustc_interface[cc74a9e713f7bc13]::queries::Linker>, rustc_errors[46ae601afbef80b]::ErrorReported>>
  36:     0x7f20a359b8c6 - rustc_span[ed66fbb5b325921d]::with_source_map::<core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>, rustc_interface[cc74a9e713f7bc13]::interface::create_compiler_and_run<core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>, rustc_driver[f891c625c383a9d9]::run_compiler::{closure#1}>::{closure#1}>
  37:     0x7f20a35990e1 - rustc_interface[cc74a9e713f7bc13]::interface::create_compiler_and_run::<core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>, rustc_driver[f891c625c383a9d9]::run_compiler::{closure#1}>
  38:     0x7f20a3585062 - <scoped_tls[6914edc14b910d16]::ScopedKey<rustc_span[ed66fbb5b325921d]::SessionGlobals>>::set::<rustc_interface[cc74a9e713f7bc13]::interface::run_compiler<core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>, rustc_driver[f891c625c383a9d9]::run_compiler::{closure#1}>::{closure#0}, core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>>
  39:     0x7f20a358491d - std[ae485eafb9945fc4]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[cc74a9e713f7bc13]::util::run_in_thread_pool_with_globals<rustc_interface[cc74a9e713f7bc13]::interface::run_compiler<core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>, rustc_driver[f891c625c383a9d9]::run_compiler::{closure#1}>::{closure#0}, core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>>::{closure#0}, core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>>
  40:     0x7f20a3583119 - <<std[ae485eafb9945fc4]::thread::Builder>::spawn_unchecked_<rustc_interface[cc74a9e713f7bc13]::util::run_in_thread_pool_with_globals<rustc_interface[cc74a9e713f7bc13]::interface::run_compiler<core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>, rustc_driver[f891c625c383a9d9]::run_compiler::{closure#1}>::{closure#0}, core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>>::{closure#0}, core[480e1a3512c30a12]::result::Result<(), rustc_errors[46ae601afbef80b]::ErrorReported>>::{closure#1} as core[480e1a3512c30a12]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f20a0fc6043 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h78e3a4498542e3c1
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/alloc/src/boxed.rs:1854:9
  42:     0x7f20a0fc6043 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h350da154130e2756
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/alloc/src/boxed.rs:1854:9
  43:     0x7f20a0fc6043 - std::sys::unix::thread::Thread::new::thread_start::h918df3b0ffbb0232
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys/unix/thread.rs:108:17
  44:     0x7f20a0d7cb1a - start_thread
  45:     0x7f20a0e01650 - __clone3
  46:                0x0 - <unknown>

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.61.0-nightly (68369a041 2022-02-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C codegen-units=1 -C embed-bitcode=no

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `<fcg4::FixedI32<16_u32> as core::str::traits::FromStr>::from_str`
end of query stack
error: aborting due to previous error

Couldn't compile the test.

failures:
    src/lib.rs - FixedI32 (line 9)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

error: test failed, to rerun pass '--doc'

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.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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions