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: failed to normalize #107872

Open
matthiaskrgr opened this issue Feb 10, 2023 · 8 comments
Open

rustdoc: failed to normalize #107872

matthiaskrgr opened this issue Feb 10, 2023 · 8 comments
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

./tests/ui/union/projection-as-union-type-error.rs

#![crate_type = "lib"]

pub trait Identity {
    type Identity;
}

pub type Foo = u8;

pub union Bar {
    a:  <Foo as Identity>::Identity, //~ ERROR
    b: u8,
}

Meta

rustc --version --verbose:

Regression in #106938

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:198:90: Failed to normalize <u8 as Identity>::Identity, maybe try to call `try_normalize_erasing_regions` instead

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/compiler/rustc_errors/src/lib.rs:1644:9
stack backtrace:
   0:     0x7f5a7c76a56a - std::backtrace_rs::backtrace::libunwind::trace::h96288e3e31cede0c
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f5a7c76a56a - std::backtrace_rs::backtrace::trace_unsynchronized::h136276fcc921ebd2
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5a7c76a56a - std::sys_common::backtrace::_print_fmt::hed1407344e09c3c5
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f5a7c76a56a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hef11c1a0e2ccbd67
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5a7c7caa3e - core::fmt::write::h9d34c1ab82e0e30d
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f5a7c75ab35 - std::io::Write::write_fmt::h583f259fb2d64e4c
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/io/mod.rs:1684:15
   6:     0x7f5a7c76a335 - std::sys_common::backtrace::_print::h384b5154a89856a1
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f5a7c76a335 - std::sys_common::backtrace::print::he3caeede32862700
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f5a7c76d0ff - std::panicking::default_hook::{{closure}}::hb37cdcd49b812817
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/panicking.rs:267:22
   9:     0x7f5a7c76ce3b - std::panicking::default_hook::h89fa77719af1b8c7
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/panicking.rs:286:9
  10:     0x7f5a7fa84824 - rustc_driver_impl[996a7fa2764f51ac]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f5a7c76d93a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcdabce48acce76a1
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/alloc/src/boxed.rs:2002:9
  12:     0x7f5a7c76d93a - std::panicking::rust_panic_with_hook::h420ef2d822c4b069
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/panicking.rs:692:13
  13:     0x7f5a800051c1 - std[cd98010995c1c111]::panicking::begin_panic::<rustc_errors[aee54022d4af98b8]::ExplicitBug>::{closure#0}
  14:     0x7f5a800050d6 - std[cd98010995c1c111]::sys_common::backtrace::__rust_end_short_backtrace::<std[cd98010995c1c111]::panicking::begin_panic<rustc_errors[aee54022d4af98b8]::ExplicitBug>::{closure#0}, !>
  15:     0x7f5a7ff87a96 - std[cd98010995c1c111]::panicking::begin_panic::<rustc_errors[aee54022d4af98b8]::ExplicitBug>
  16:     0x7f5a800224b6 - std[cd98010995c1c111]::panic::panic_any::<rustc_errors[aee54022d4af98b8]::ExplicitBug>
  17:     0x7f5a80020686 - <rustc_errors[aee54022d4af98b8]::HandlerInner>::bug::<&alloc[d5203ca4bbacc4a0]::string::String>
  18:     0x7f5a80020360 - <rustc_errors[aee54022d4af98b8]::Handler>::bug::<&alloc[d5203ca4bbacc4a0]::string::String>
  19:     0x7f5a8003f38b - rustc_middle[dd44835e384dc8fc]::util::bug::opt_span_bug_fmt::<rustc_span[c7747b3aedb35767]::span_encoding::Span>::{closure#0}
  20:     0x7f5a8003e64a - rustc_middle[dd44835e384dc8fc]::ty::context::tls::with_opt::<rustc_middle[dd44835e384dc8fc]::util::bug::opt_span_bug_fmt<rustc_span[c7747b3aedb35767]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f5a8003e616 - rustc_middle[dd44835e384dc8fc]::ty::context::tls::with_context_opt::<rustc_middle[dd44835e384dc8fc]::ty::context::tls::with_opt<rustc_middle[dd44835e384dc8fc]::util::bug::opt_span_bug_fmt<rustc_span[c7747b3aedb35767]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f5a8003f2d6 - rustc_middle[dd44835e384dc8fc]::util::bug::opt_span_bug_fmt::<rustc_span[c7747b3aedb35767]::span_encoding::Span>
  23:     0x7f5a7ddc9b43 - rustc_middle[dd44835e384dc8fc]::util::bug::bug_fmt
  24:     0x7f5a7dc5e1f1 - <rustc_middle[dd44835e384dc8fc]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle[dd44835e384dc8fc]::ty::fold::TypeFolder>::fold_ty
  25:     0x7f5a7e46478a - rustc_hir_analysis[fafe05592f4b0540]::check::check::check_mod_item_types
  26:     0x7f5a7efbe711 - rustc_query_system[1e3d87d6bb1db1ab]::query::plumbing::try_execute_query::<rustc_query_impl[f65b45c65392aba7]::queries::check_mod_item_types, rustc_query_impl[f65b45c65392aba7]::plumbing::QueryCtxt>
  27:     0x7f5a7f41c9ad - <rustc_query_impl[f65b45c65392aba7]::Queries as rustc_middle[dd44835e384dc8fc]::ty::query::QueryEngine>::check_mod_item_types
  28:     0x55b7efad374a - <rustc_middle[dd44835e384dc8fc]::hir::map::Map>::for_each_module::<rustdoc[78efbd2992aca86b]::core::run_global_ctxt::{closure#0}::{closure#0}>
  29:     0x55b7efcc14c2 - <rustc_session[8b3af3d4e67ba61e]::session::Session>::time::<(), rustdoc[78efbd2992aca86b]::core::run_global_ctxt::{closure#0}>
  30:     0x55b7efd0bdc6 - rustdoc[78efbd2992aca86b]::core::run_global_ctxt
  31:     0x55b7efcc078c - <rustc_session[8b3af3d4e67ba61e]::session::Session>::time::<(rustdoc[78efbd2992aca86b]::clean::types::Crate, rustdoc[78efbd2992aca86b]::config::RenderOptions, rustdoc[78efbd2992aca86b]::formats::cache::Cache), rustdoc[78efbd2992aca86b]::main_args::{closure#1}::{closure#0}::{closure#1}::{closure#0}>
  32:     0x55b7efbfceaf - <rustc_interface[82796a5553273f34]::passes::QueryContext>::enter::<rustdoc[78efbd2992aca86b]::main_args::{closure#1}::{closure#0}::{closure#1}, core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>>
  33:     0x55b7efb71f07 - <rustc_interface[82796a5553273f34]::interface::Compiler>::enter::<rustdoc[78efbd2992aca86b]::main_args::{closure#1}::{closure#0}, core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>>
  34:     0x55b7efc15d69 - std[cd98010995c1c111]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[82796a5553273f34]::util::run_in_thread_pool_with_globals<rustc_interface[82796a5553273f34]::interface::run_compiler<core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>, rustdoc[78efbd2992aca86b]::main_args::{closure#1}>::{closure#0}, core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>>
  35:     0x55b7efd81b4d - <<std[cd98010995c1c111]::thread::Builder>::spawn_unchecked_<rustc_interface[82796a5553273f34]::util::run_in_thread_pool_with_globals<rustc_interface[82796a5553273f34]::interface::run_compiler<core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>, rustdoc[78efbd2992aca86b]::main_args::{closure#1}>::{closure#0}, core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c2ed83ad2149f92c]::result::Result<(), rustc_errors[aee54022d4af98b8]::ErrorGuaranteed>>::{closure#1} as core[c2ed83ad2149f92c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7f5a7c777933 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h125a8995d683d283
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/alloc/src/boxed.rs:1988:9
  37:     0x7f5a7c777933 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc8d7e704b7a14a23
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/alloc/src/boxed.rs:1988:9
  38:     0x7f5a7c777933 - std::sys::unix::thread::Thread::new::thread_start::hc8f4f2c9b0ce4632
                               at /rustc/8996ea93b6e554148c4286e62b613f12a3ee505c/library/std/src/sys/unix/thread.rs:108:17
  39:     0x7f5a7c5088fd - <unknown>
  40:     0x7f5a7c58ad20 - <unknown>
  41:                0x0 - <unknown>

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.69.0-nightly (8996ea93b 2023-02-09) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_item_types] checking item types in top-level module
end of query stack
error: aborting due to previous error

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Feb 10, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 10, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Feb 10, 2023

Considering this errors with rustc, and rustdoc can only document rust code that actually compiles, I'd say this is in the same bucket as the other issues we have open about this, meaning "not a bug, just a papercut"?

@oli-obk oli-obk added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 10, 2023
@jyn514
Copy link
Member

jyn514 commented Feb 10, 2023

rustdoc can only document rust code that actually compiles

this is not true

https://doc.rust-lang.org/beta/rustdoc/advanced-features.html#interactions-between-platform-specific-docs

@oli-obk
Copy link
Contributor

oli-obk commented Feb 10, 2023

I can only document code that compiles, ignoring method bodies. This specific test has no method bodies, so does it fall under that rule?

@jyn514
Copy link
Member

jyn514 commented Feb 10, 2023

That seems possible, but you should test to make sure. Rustdoc's logic around this is extremely janky and indirect.

@matthiaskrgr
Copy link
Member Author

What is the benefit of documenting code that does not compile?

@jyn514
Copy link
Member

jyn514 commented Feb 11, 2023

I can't keep having this argument. Please read the documentation.

@jyn514
Copy link
Member

jyn514 commented Feb 13, 2023

cc #79496 (comment)

@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 17, 2023
@fmease
Copy link
Member

fmease commented Apr 30, 2024

Triage: No longer ICEs. Might need regression test, not sure.

Current compiler output:

error[E0277]: the trait bound `u8: Identity` is not satisfied
  --> r.rs:10:9
   |
10 |     a:  <Foo as Identity>::Identity, //~ ERROR
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Identity` is not implemented for `u8`
   |
help: this trait has no implementations, consider adding one
  --> r.rs:3:1
   |
3  | pub trait Identity {
   | ^^^^^^^^^^^^^^^^^^

@fmease fmease added the E-needs-test Call for participation: Writing correctness tests. label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants