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

use ObligationCtxt not QueryNormalizer in rustdoc's normalization #108503

Closed

Conversation

BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented Feb 26, 2023

QueryNormalizer doesn't handle not-well-formed projections or ambiguity so should not be used by rustdoc as rustdoc happens on code that is not well formed. This PR replaces the usage of QueryNormalizer with ObligationCtxt::normalize which is designed to work on not-wf code while not being in typeck. This also removes two uses of actually_rustdoc from the compiler which seems good to me.

I am somewhat confused as to the "point" of QueryNormalizer, it intends to be "the main way of normalizing" in the future and yet ICEs when encountering not wf types or when normalization is ambiguous which seems very incompatible with its stated goal since that makes it only suitable for using after typeck?

@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2023

r? @notriddle

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. labels Feb 26, 2023
@jyn514
Copy link
Member

jyn514 commented Feb 26, 2023

r? types

@rustbot rustbot assigned jackh726 and unassigned notriddle Feb 26, 2023
@GuillaumeGomez
Copy link
Member

Let's re-roll. r? types

@rustbot rustbot assigned oli-obk and unassigned jackh726 Mar 25, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2023

r=me after rebase

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 27, 2023
@jyn514
Copy link
Member

jyn514 commented Mar 30, 2023

I am somewhat confused as to the "point" of QueryNormalizer, it intends to be "the main way of normalizing" in the future and yet ICEs when encountering not wf types or when normalization is ambiguous which seems very incompatible with its stated goal since that makes it only suitable for using after typeck?

@oli-obk do you know what's going on here? or who we should ask?

@BoxyUwU BoxyUwU force-pushed the rustdog_dont_use_querynormalizer branch from a2868c5 to 390246c Compare March 30, 2023 11:41
@oli-obk
Copy link
Contributor

oli-obk commented Mar 30, 2023

@oli-obk do you know what's going on here? or who we should ask?

I believe we just never finished the work. The docs (modulo a wrong double negation) explicitly say that this can only be used for unambiguous normalizations and wf types

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Mar 31, 2023

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Mar 31, 2023

📌 Commit d0c308c has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 31, 2023
@bors
Copy link
Contributor

bors commented Mar 31, 2023

⌛ Testing commit d0c308c with merge a14c185f4330588cd23391993cb86940913a391d...

@bors
Copy link
Contributor

bors commented Mar 31, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 31, 2023
@notriddle
Copy link
Contributor

@bors retry

LLVM build failed

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2023
@matthiaskrgr
Copy link
Member

@bors r-
#109998 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 6, 2023
@bors
Copy link
Contributor

bors commented Jul 30, 2023

☔ The latest upstream changes (presumably #114264) made this pull request unmergeable. Please resolve the merge conflicts.

@fmease
Copy link
Member

fmease commented Sep 5, 2023

Locally I've rebased the commits and run ./x doc compiler which used to cause the failure in the try build, am I understanding this right (the logs aren't available anymore)? This time, it worked flawlessly. Maybe some rustdoc PR fixed this issue coincidentally (one that got rid of a Binder::dummy and correctly rebound bound vars).

@BoxyUwU Would you be willing to bring this PR up to speed and retry it? I'm just gonna use your commits in the meantime to experiment with some stuff that likely depends on this PR.

@fmease
Copy link
Member

fmease commented Sep 5, 2023

Fyi, your PR seems to fix #112242. If you could add a regression test for it, that would be awesome! :)

@BoxyUwU BoxyUwU force-pushed the rustdog_dont_use_querynormalizer branch from d0c308c to 2ccfd04 Compare September 21, 2023 18:09
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@fmease
Copy link
Member

fmease commented Sep 21, 2023

@bors r=oli-obk,fmease

@bors
Copy link
Contributor

bors commented Sep 21, 2023

📌 Commit 1543e6b has been approved by oli-obk,fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 21, 2023
@bors
Copy link
Contributor

bors commented Sep 22, 2023

⌛ Testing commit 1543e6b with merge 1c91285...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 22, 2023
…izer, r=oli-obk,fmease

use `ObligationCtxt` not `QueryNormalizer` in rustdoc's `normalization`

`QueryNormalizer` doesn't handle not-well-formed projections or ambiguity so should not be used by rustdoc as rustdoc happens on code that is not well formed. This PR replaces the usage of `QueryNormalizer` with `ObligationCtxt::normalize` which is designed to work on not-wf code while not being in typeck. This also removes two uses of `actually_rustdoc` from the compiler which seems good to me.

I am somewhat confused as to the "point" of `QueryNormalizer`, it intends to be "the main way of normalizing" in the future and yet ICEs when encountering not wf types or when normalization is ambiguous which seems very incompatible with its stated goal since that makes it only suitable for using after typeck?
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 Documenting rustc_parse v0.0.0 (/checkout/compiler/rustc_parse)
 Documenting rustc_attr v0.0.0 (/checkout/compiler/rustc_attr)
 Documenting rustc_query_system v0.0.0 (/checkout/compiler/rustc_query_system)
thread 'rustc' panicked at /checkout/compiler/rustc_trait_selection/src/traits/project.rs:484:9:
Normalizing Binder { value: &ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(29:6758 ~ rustc_ast[651b]::attr::filter_by_name::'_), '_) }) rustc_ast::Attribute, bound_vars: [] } without wrapping in a `Binder`
   0:     0xffff78dd869c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h55ef4c9c69390aa7
   1:     0xffff78e3cb34 - core::fmt::write::hbc2796ff4da97cb5
   2:     0xffff78dcd444 - std::io::Write::write_fmt::hac1e748c18b63596
   3:     0xffff78dd84d0 - std::sys_common::backtrace::print::hcb7b8d22bdccc841
   3:     0xffff78dd84d0 - std::sys_common::backtrace::print::hcb7b8d22bdccc841
   4:     0xffff78ddb4f8 - std::panicking::default_hook::{{closure}}::h0cd2e1b918ce4fed
   5:     0xffff78ddb23c - std::panicking::default_hook::he0f5cb76df1c3b31
   6:     0xffff79fee400 - <alloc[583d21a06ac2b97c]::boxed::Box<rustc_driver_impl[7c90f1d98e905b4f]::install_ice_hook::{closure#0}> as core[9cd63082b953a274]::ops::function::Fn<(&dyn for<'a, 'b> core[9cd63082b953a274]::ops::function::Fn<(&'a core[9cd63082b953a274]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[9cd63082b953a274]::marker::Send + core[9cd63082b953a274]::marker::Sync, &core[9cd63082b953a274]::panic::panic_info::PanicInfo)>>::call
   8:     0xffff78ddba4c - std::panicking::begin_panic_handler::{{closure}}::h22dbdf10f414a04e
   9:     0xffff78dd8c28 - std::sys_common::backtrace::__rust_end_short_backtrace::h606b636c849076c0
  10:     0xffff78ddb774 - rust_begin_unwind
  11:     0xffff78d9ac00 - core::panicking::panic_fmt::ha961d16324797541
  11:     0xffff78d9ac00 - core::panicking::panic_fmt::ha961d16324797541
  12:     0xaaaabccce13c - rustc_trait_selection[9f284babfa4dce13]::traits::project::normalize_with_depth_to::<rustc_middle[30156f4742ca7176]::ty::sty::Binder<rustc_middle[30156f4742ca7176]::ty::Ty>>::{closure#0}
  13:     0xaaaabcccb374 - <rustc_infer[fcb521e6ae537e7b]::infer::at::At as rustc_trait_selection[9f284babfa4dce13]::traits::project::NormalizeExt>::normalize::<rustc_middle[30156f4742ca7176]::ty::sty::Binder<rustc_middle[30156f4742ca7176]::ty::Ty>>
  14:     0xaaaabcd9aeb0 - <rustc_trait_selection[9f284babfa4dce13]::traits::engine::ObligationCtxt>::normalize::<rustc_middle[30156f4742ca7176]::ty::sty::Binder<rustc_middle[30156f4742ca7176]::ty::Ty>>
  15:     0xaaaabcbff840 - rustdoc[a01ebc44ce092bbb]::clean::normalize
  16:     0xaaaabcc0aa88 - rustdoc[a01ebc44ce092bbb]::clean::clean_middle_ty
  17:     0xaaaabcbf7adc - rustdoc[a01ebc44ce092bbb]::clean::clean_middle_term
  18:     0xaaaabcbed38c - <&mut rustdoc[a01ebc44ce092bbb]::clean::clean_middle_opaque_bounds::{closure#0} as core[9cd63082b953a274]::ops::function::FnMut<(&rustc_middle[30156f4742ca7176]::ty::Clause,)>>::call_mut
  19:     0xaaaabce13a58 - <alloc[583d21a06ac2b97c]::vec::Vec<rustdoc[a01ebc44ce092bbb]::clean::types::GenericBound> as alloc[583d21a06ac2b97c]::vec::spec_from_iter::SpecFromIter<rustdoc[a01ebc44ce092bbb]::clean::types::GenericBound, core[9cd63082b953a274]::iter::adapters::filter_map::FilterMap<core[9cd63082b953a274]::slice::iter::Iter<rustc_middle[30156f4742ca7176]::ty::Clause>, rustdoc[a01ebc44ce092bbb]::clean::clean_middle_opaque_bounds::{closure#0}>>>::from_iter
  20:     0xaaaabcbfff1c - rustdoc[a01ebc44ce092bbb]::clean::clean_middle_opaque_bounds
  21:     0xaaaabcc0c020 - rustdoc[a01ebc44ce092bbb]::clean::clean_middle_ty
  22:     0xaaaabcbfc310 - rustdoc[a01ebc44ce092bbb]::clean::clean_fn_decl_from_did_and_sig
  23:     0xaaaabce8ebdc - rustdoc[a01ebc44ce092bbb]::clean::utils::enter_impl_trait::<rustdoc[a01ebc44ce092bbb]::clean::inline::build_external_function::{closure#1}, (rustdoc[a01ebc44ce092bbb]::clean::types::Generics, rustdoc[a01ebc44ce092bbb]::clean::types::FnDecl)>
  24:     0xaaaabcc734d0 - rustdoc[a01ebc44ce092bbb]::clean::inline::build_external_function
  25:     0xaaaabcc7227c - rustdoc[a01ebc44ce092bbb]::clean::inline::try_inline
  26:     0xaaaabcc762b4 - rustdoc[a01ebc44ce092bbb]::clean::inline::build_module_items
  27:     0xaaaabcc7277c - rustdoc[a01ebc44ce092bbb]::clean::inline::try_inline_glob
  28:     0xaaaabcc029f8 - rustdoc[a01ebc44ce092bbb]::clean::clean_use_statement_inner
  29:     0xaaaabcc021fc - rustdoc[a01ebc44ce092bbb]::clean::clean_use_statement
  30:     0xaaaabce0c148 - <alloc[583d21a06ac2b97c]::vec::Vec<rustdoc[a01ebc44ce092bbb]::clean::types::Item> as alloc[583d21a06ac2b97c]::vec::spec_extend::SpecExtend<rustdoc[a01ebc44ce092bbb]::clean::types::Item, core[9cd63082b953a274]::iter::adapters::flatten::FlatMap<indexmap[e18f5b8e46029fbd]::map::iter::Values<(rustc_span[c74d91620864bd]::def_id::LocalDefId, core[9cd63082b953a274]::option::Option<rustc_span[c74d91620864bd]::symbol::Symbol>), (&rustc_hir[3813dcfa2877473]::hir::Item, core[9cd63082b953a274]::option::Option<rustc_span[c74d91620864bd]::symbol::Symbol>, core[9cd63082b953a274]::option::Option<rustc_span[c74d91620864bd]::def_id::LocalDefId>)>, alloc[583d21a06ac2b97c]::vec::Vec<rustdoc[a01ebc44ce092bbb]::clean::types::Item>, rustdoc[a01ebc44ce092bbb]::clean::clean_doc_module::{closure#4}>>>::spec_extend
  31:     0xaaaabcbf5e3c - rustdoc[a01ebc44ce092bbb]::clean::clean_doc_module
  32:     0xaaaabce8a9dc - rustdoc[a01ebc44ce092bbb]::clean::utils::krate
  33:     0xaaaabcc80694 - <rustc_session[a6776faef8fb59bf]::session::Session>::time::<rustdoc[a01ebc44ce092bbb]::clean::types::Crate, rustdoc[a01ebc44ce092bbb]::core::run_global_ctxt::{closure#5}>
  34:     0xaaaabce93204 - rustdoc[a01ebc44ce092bbb]::core::run_global_ctxt
  35:     0xaaaabcc80b84 - <rustc_session[a6776faef8fb59bf]::session::Session>::time::<(rustdoc[a01ebc44ce092bbb]::clean::types::Crate, rustdoc[a01ebc44ce092bbb]::config::RenderOptions, rustdoc[a01ebc44ce092bbb]::formats::cache::Cache), rustdoc[a01ebc44ce092bbb]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  36:     0xaaaabcbd8c10 - <rustc_middle[30156f4742ca7176]::ty::context::GlobalCtxt>::enter::<rustdoc[a01ebc44ce092bbb]::main_args::{closure#1}::{closure#0}::{closure#0}, core[9cd63082b953a274]::result::Result<(), rustc_span[c74d91620864bd]::ErrorGuaranteed>>
  37:     0xaaaabcbb9ed0 - std[c671eddf87a4a636]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[da7564494a8a9719]::util::run_in_thread_with_globals<rustc_interface[da7564494a8a9719]::interface::run_compiler<core[9cd63082b953a274]::result::Result<(), rustc_span[c74d91620864bd]::ErrorGuaranteed>, rustdoc[a01ebc44ce092bbb]::main_args::{closure#1}>::{closure#0}, core[9cd63082b953a274]::result::Result<(), rustc_span[c74d91620864bd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9cd63082b953a274]::result::Result<(), rustc_span[c74d91620864bd]::ErrorGuaranteed>>
  38:     0xaaaabcbbc9fc - <<std[c671eddf87a4a636]::thread::Builder>::spawn_unchecked_<rustc_interface[da7564494a8a9719]::util::run_in_thread_with_globals<rustc_interface[da7564494a8a9719]::interface::run_compiler<core[9cd63082b953a274]::result::Result<(), rustc_span[c74d91620864bd]::ErrorGuaranteed>, rustdoc[a01ebc44ce092bbb]::main_args::{closure#1}>::{closure#0}, core[9cd63082b953a274]::result::Result<(), rustc_span[c74d91620864bd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9cd63082b953a274]::result::Result<(), rustc_span[c74d91620864bd]::ErrorGuaranteed>>::{closure#1} as core[9cd63082b953a274]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0xffff78bbd5c8 - <unknown>
  41:     0xffff78c25d1c - <unknown>
  42:                0x0 - <unknown>


error: 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-rustdoc&template=ice.md

warning: the ICE couldn't be written to `/checkout/rustc-ice-2023-09-22T05:06:45.81400313Z-275568.txt`: Read-only file system (os error 30)

note: rustc 1.74.0-nightly (1c9128568 2023-09-22) running on aarch64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z unstable-options -C symbol-mangling-version=v0 -Z unstable-options -Z unstable-options -Z normalize-docs -Z crate-attr=warn(rust_2018_idioms) -Z force-unstable-if-unmarked -Z unstable-options
note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
end of query stack
error: could not document `rustc_attr`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --edition=2021 --crate-type lib --crate-name rustc_attr compiler/rustc_attr/src/lib.rs --target aarch64-unknown-linux-gnu -o /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/doc -Zunstable-options --check-cfg 'values(feature)' --check-cfg 'names()' --check-cfg 'values()' --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat -C metadata=af93f1c9bdf3debe -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps --extern rustc_ast=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_ast-cd0a175d637fe13f.rmeta --extern rustc_ast_pretty=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_ast_pretty-d9f444e6f966f5c4.rmeta --extern rustc_data_structures=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_data_structures-b8d47697b4e0010f.rmeta --extern rustc_errors=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_errors-494ab1e783964426.rmeta --extern rustc_feature=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_feature-4310908a15a756f7.rmeta --extern rustc_fluent_macro=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/librustc_fluent_macro-615f82b04877befb.so --extern rustc_lexer=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_lexer-49b372848e26e99e.rmeta --extern rustc_macros=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/librustc_macros-3667f00c761d6515.so --extern rustc_serialize=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_serialize-c6df24e2bc18c0c5.rmeta --extern rustc_session=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_session-97b4980ef8c2310d.rmeta --extern rustc_span=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_span-16dac86fb3e74f86.rmeta --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options '--check-cfg=values(bootstrap)' '--check-cfg=values(parallel_compiler)' '--check-cfg=values(target_os,"hurd")' '--check-cfg=values(no_btreemap_remove_entry)' '--check-cfg=values(crossbeam_loom)' '--check-cfg=values(span_locations)' '--check-cfg=values(rustix_use_libc)' '--check-cfg=values(emulate_second_only_system)' '--check-cfg=values(windows_raw_dylib)' -Dwarnings '-Wrustdoc::invalid_codeblock_attributes' --crate-version '1.74.0-nightly (1c9128568 2023-09-22)' --document-private-items '-Arustdoc::private-intra-doc-links' --enable-index-page -Zunstable-options -Znormalize-docs --show-type-layout --generate-link-to-definition '-Zcrate-attr=warn(rust_2018_idioms)' --extern-html-root-url 'ena=https://docs.rs/ena/latest/'` (exit status: 101)
[RUSTC-TIMING] rustc_attr test:false 0.735
[RUSTC-TIMING] rustc_query_system test:false 1.518
[RUSTC-TIMING] rustc_parse test:false 5.386
Build completed unsuccessfully in 0:36:48

@bors
Copy link
Contributor

bors commented Sep 22, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 22, 2023
@fmease
Copy link
Member

fmease commented Sep 22, 2023

Ah, now I can see that it happens with stage2→stage3, not with stage1→stage2. Let me investigate this ICE…

@ehuss
Copy link
Contributor

ehuss commented Sep 23, 2023

@bors r-

synchronizing the queue

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 23, 2023
@bors
Copy link
Contributor

bors commented Oct 26, 2023

☔ The latest upstream changes (presumably #117193) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC
Copy link
Member

@BoxyUwU any updates on the CI failure?

@BoxyUwU BoxyUwU closed this Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 this pull request may close these issues.