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: Fix invalid suggestions on ambiguous intra doc links #108699

Conversation

GuillaumeGomez
Copy link
Member

Fixes #108653.

r? @notriddle

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 3, 2023
@GuillaumeGomez GuillaumeGomez force-pushed the fix-invalid-suggestion-ambiguous-intra-doc branch from 24483e9 to 1588d7d Compare March 3, 2023 14:07
@GuillaumeGomez GuillaumeGomez force-pushed the fix-invalid-suggestion-ambiguous-intra-doc branch from 1588d7d to a830d71 Compare March 3, 2023 15:21
@notriddle
Copy link
Contributor

notriddle commented Mar 3, 2023

This doesn't seem correct. Try running the below test case:

// This is ensuring that the UI output for associated items works when it's being documented
// from another item.

#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]

pub trait Trait {
    type Trait;
    const Trait: usize;
}

/// [`Trait`]
//~^ ERROR
/// [`Trait::Trait`]
//~^ ERROR
pub const Trait: usize = 0;
error: `Trait` is both a trait and a constant
  --> $DIR/issue-108653-3.rs:12:7
   |
LL | /// [`Trait`]
   |       ^^^^^ ambiguous link
   |
note: the lint level is defined here
  --> $DIR/issue-108653-3.rs:4:9
   |
LL | #![deny(rustdoc::broken_intra_doc_links)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to link to the trait, prefix with `trait@`
   |
LL | /// [`trait@Trait`]
   |       ++++++
help: to link to the constant, prefix with `const@`
   |
LL | /// [`const@Trait`]
   |       ++++++

error: `Trait::Trait` is both a trait and a trait
  --> $DIR/issue-108653-3.rs:14:7
   |
LL | /// [`Trait::Trait`]
   |       ^^^^^^^^^^^^ ambiguous link
   |
help: to link to the trait, prefix with `trait@`
   |
LL | /// [`trait@Trait::Trait`]
   |       ++++++
help: to link to the trait, prefix with `trait@`
   |
LL | /// [`trait@Trait::Trait`]
   |       ++++++

error: aborting due to 2 previous errors

Copy link
Contributor

@notriddle notriddle left a comment

Choose a reason for hiding this comment

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

Add above test case to test suite, and fix buggy check for item kind.

@GuillaumeGomez GuillaumeGomez force-pushed the fix-invalid-suggestion-ambiguous-intra-doc branch from a830d71 to 8247b93 Compare March 3, 2023 21:49
@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Mar 3, 2023

I was relying too much on the item on which the intra-doc link was. Big mistake. So instead, I now directly look at the Res candidate and start from there directly.

I also added your test, thanks for it!

@notriddle
Copy link
Contributor

Still falls over, this time in a case that was constructed to not actually have duplicates (so scanning for duplicates does the wrong thing).

#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]

pub trait Trait {
    type Trait;
}

/// [`Struct::Trait`]
//~^ ERROR
pub struct Struct;

impl Trait for Struct {
    type Trait = Struct;
}

impl Struct {
    pub const Trait: usize = 0;
}
error: `Struct::Trait` is and an associated constant
error: `Struct::Trait` is and an associated constant
  --> $DIR/issue-108653-3.rs:11:7
   |
LL | /// [`Struct::Trait`]
   |       ^^^^^^^^^^^^^ ambiguous link
   |
note: the lint level is defined here
  --> $DIR/issue-108653-3.rs:4:9
   |
LL | #![deny(rustdoc::broken_intra_doc_links)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to link to the associated constant, prefix with `const@`
   |
LL | /// [`const@Struct::Trait`]
   |       ++++++

error: aborting due to previous error

@GuillaumeGomez GuillaumeGomez force-pushed the fix-invalid-suggestion-ambiguous-intra-doc branch from 8247b93 to ff4352e Compare March 6, 2023 14:47
@GuillaumeGomez
Copy link
Member Author

The problem was that I was stopping the "discovery" when I found one or more match in one location, preventing us to go through all of them. I removed this limitation, fixing this bug and added a new test.

@notriddle
Copy link
Contributor

There's also a few corner cases involving primitives:

#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]

/// [`u32::MAX`]
//~^ ERROR
pub mod u32 {
    pub trait MAX {}
}
error: `u32::MAX` is both a trait and a builtin type
  --> $DIR/issue-108653-3.rs:4:7
   |
LL | /// [`u32::MAX`]
   |       ^^^^^^^^ ambiguous link
   |
note: the lint level is defined here
  --> $DIR/issue-108653-3.rs:1:9
   |
LL | #![deny(rustdoc::broken_intra_doc_links)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to link to the trait, prefix with `trait@`
   |
LL | /// [`trait@u32::MAX`]
   |       ++++++
help: to link to the builtin type, prefix with `prim@`
   |
LL | /// [`prim@u32::MAX`]
   |       +++++

error: aborting due to previous error
#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]

/// [`u32::MAX`]
//~^ ERROR
pub mod u32 {
    pub use std::primitive::u32 as MAX;
}
---- [ui] tests/rustdoc-ui/intra-doc/issue-108653-3.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: "/var/tmp/rust-build/x86_64-unknown-linux-gnu/stage1/bin/rustdoc" "/home/michael/Development/rust/tests/rustdoc-ui/intra-doc/issue-108653-3.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "-o" "/var/tmp/rust-build/x86_64-unknown-linux-gnu/test/rustdoc-ui/intra-doc/issue-108653-3" "-Cdebuginfo=0" "-Lnative=/var/tmp/rust-build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/var/tmp/rust-build/x86_64-unknown-linux-gnu/test/rustdoc-ui/intra-doc/issue-108653-3/auxiliary"
stdout: none
--- stderr -------------------------------
thread 'rustc' panicked at 'DefId(1:11857 ~ std[b2d9]::prim_u32) does not have a "type_of"', compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:204:1
stack backtrace:
   0:     0x7f1579504849 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h78f6bced1ab9b952
   1:     0x7f1579578a3e - core::fmt::write::h5341206de545b898
   2:     0x7f15794c56b5 - std::io::Write::write_fmt::hbeb8ef999f3c7868
   3:     0x7f1579504605 - std::sys_common::backtrace::print::h0da51f2725c33842
   4:     0x7f15794cd55f - std::panicking::default_hook::{{closure}}::h619e143597771e26
   5:     0x7f15794cd21c - std::panicking::default_hook::h91aabafbf64f1a6b
   6:     0x7f1579e80ad5 - rustc_driver_impl[1dcb38fcc6e7e77c]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:     0x7f15794cdf2d - std::panicking::rust_panic_with_hook::h3a745a637417bf43
   8:     0x7f1579505a89 - std::panicking::begin_panic_handler::{{closure}}::h5d490f47745c1d00
   9:     0x7f157950498c - std::sys_common::backtrace::__rust_end_short_backtrace::hb67f613a530a3f9b
  10:     0x7f15794cda92 - rust_begin_unwind
  11:     0x7f15794a8de3 - core::panicking::panic_fmt::h497dcee45bc95959
  12:     0x7f157bec7a70 - rustc_metadata[bb7e47e5e4c187ff]::rmeta::decoder::cstore_impl::provide_extern::type_of::{closure#2}
  13:     0x7f157bec7972 - rustc_metadata[bb7e47e5e4c187ff]::rmeta::decoder::cstore_impl::provide_extern::type_of
  14:     0x7f157baeb791 - rustc_query_system[b7c2d4a4947a6b57]::query::plumbing::try_execute_query::<rustc_query_impl[8b60fe27614f6a9d]::queries::type_of, rustc_query_impl[8b60fe27614f6a9d]::plumbing::QueryCtxt>
  15:     0x7f157b8a86f5 - <rustc_query_impl[8b60fe27614f6a9d]::Queries as rustc_middle[8f8cc58a38a08b32]::ty::query::QueryEngine>::type_of
  16:     0x558567bdec96 - rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::ambiguity_error
  17:     0x558567bd9d90 - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_item
  18:     0x558567be272a - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_inner_recur
  19:     0x558567bdb1db - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_item
  20:     0x558567bd2f4f - rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::collect_intra_doc_links
  21:     0x558567be483e - <rustc_session[5867f2a876facb7]::session::Session>::time::<rustdoc[3f0501292528f1e0]::clean::types::Crate, rustdoc[3f0501292528f1e0]::core::run_global_ctxt::{closure#7}>
  22:     0x558567c7fe67 - rustdoc[3f0501292528f1e0]::core::run_global_ctxt
  23:     0x558567be4ac9 - <rustc_session[5867f2a876facb7]::session::Session>::time::<(rustdoc[3f0501292528f1e0]::clean::types::Crate, rustdoc[3f0501292528f1e0]::config::RenderOptions, rustdoc[3f0501292528f1e0]::formats::cache::Cache), rustdoc[3f0501292528f1e0]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  24:     0x558567deaa6d - rustc_span[4085bd95152d41da]::with_source_map::<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  25:     0x558567b21684 - <scoped_tls[b966ac58386d5624]::ScopedKey<rustc_span[4085bd95152d41da]::SessionGlobals>>::set::<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>
  26:     0x558567bacf50 - std[b5fab123d48d12b9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[258a4538246304e0]::util::run_in_thread_pool_with_globals<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>
  27:     0x558567c9d88d - <<std[b5fab123d48d12b9]::thread::Builder>::spawn_unchecked_<rustc_interface[258a4538246304e0]::util::run_in_thread_pool_with_globals<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#1} as core[eec4a6d8192687cb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7f157950cf93 - std::sys::unix::thread::Thread::new::thread_start::h6a3611c28007b704
  29:     0x7f157920412d - start_thread
  30:     0x7f1579285bc0 - clone3
  31:                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-compiler&template=ice.md

note: rustc 1.70.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -C codegen-units=1 -Z ui-testing -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z deduplicate-diagnostics=no -C strip=debuginfo -C debuginfo=0

query stack during panic:
#0 [type_of] computing type of `std::prim_u32`
end of query stack
------------------------------------------
#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]

pub trait Trait {
    type MAX;
}

/// [`u32::MAX`]
//~^ ERROR
impl Trait for u32 {
    type MAX = u32;
}
---- [ui] tests/rustdoc-ui/intra-doc/issue-108653-3.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: "/var/tmp/rust-build/x86_64-unknown-linux-gnu/stage1/bin/rustdoc" "/home/michael/Development/rust/tests/rustdoc-ui/intra-doc/issue-108653-3.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "-o" "/var/tmp/rust-build/x86_64-unknown-linux-gnu/test/rustdoc-ui/intra-doc/issue-108653-3" "-Cdebuginfo=0" "-Lnative=/var/tmp/rust-build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/var/tmp/rust-build/x86_64-unknown-linux-gnu/test/rustdoc-ui/intra-doc/issue-108653-3/auxiliary"
stdout: none
--- stderr -------------------------------
thread 'rustc' panicked at 'DefId(1:11857 ~ std[b2d9]::prim_u32) does not have a "type_of"', compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:204:1
stack backtrace:
   0:     0x7fb6b2904849 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h78f6bced1ab9b952
   1:     0x7fb6b2978a3e - core::fmt::write::h5341206de545b898
   2:     0x7fb6b28c56b5 - std::io::Write::write_fmt::hbeb8ef999f3c7868
   3:     0x7fb6b2904605 - std::sys_common::backtrace::print::h0da51f2725c33842
   4:     0x7fb6b28cd55f - std::panicking::default_hook::{{closure}}::h619e143597771e26
   5:     0x7fb6b28cd21c - std::panicking::default_hook::h91aabafbf64f1a6b
   6:     0x7fb6b3280ad5 - rustc_driver_impl[1dcb38fcc6e7e77c]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:     0x7fb6b28cdf2d - std::panicking::rust_panic_with_hook::h3a745a637417bf43
   8:     0x7fb6b2905a89 - std::panicking::begin_panic_handler::{{closure}}::h5d490f47745c1d00
   9:     0x7fb6b290498c - std::sys_common::backtrace::__rust_end_short_backtrace::hb67f613a530a3f9b
  10:     0x7fb6b28cda92 - rust_begin_unwind
  11:     0x7fb6b28a8de3 - core::panicking::panic_fmt::h497dcee45bc95959
  12:     0x7fb6b52c7a70 - rustc_metadata[bb7e47e5e4c187ff]::rmeta::decoder::cstore_impl::provide_extern::type_of::{closure#2}
  13:     0x7fb6b52c7972 - rustc_metadata[bb7e47e5e4c187ff]::rmeta::decoder::cstore_impl::provide_extern::type_of
  14:     0x7fb6b4eeb791 - rustc_query_system[b7c2d4a4947a6b57]::query::plumbing::try_execute_query::<rustc_query_impl[8b60fe27614f6a9d]::queries::type_of, rustc_query_impl[8b60fe27614f6a9d]::plumbing::QueryCtxt>
  15:     0x7fb6b4ca86f5 - <rustc_query_impl[8b60fe27614f6a9d]::Queries as rustc_middle[8f8cc58a38a08b32]::ty::query::QueryEngine>::type_of
  16:     0x558029214c96 - rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::ambiguity_error
  17:     0x55802920fd90 - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_item
  18:     0x55802921872a - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_inner_recur
  19:     0x5580292111db - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_item
  20:     0x558029208f4f - rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::collect_intra_doc_links
  21:     0x55802921a83e - <rustc_session[5867f2a876facb7]::session::Session>::time::<rustdoc[3f0501292528f1e0]::clean::types::Crate, rustdoc[3f0501292528f1e0]::core::run_global_ctxt::{closure#7}>
  22:     0x5580292b5e67 - rustdoc[3f0501292528f1e0]::core::run_global_ctxt
  23:     0x55802921aac9 - <rustc_session[5867f2a876facb7]::session::Session>::time::<(rustdoc[3f0501292528f1e0]::clean::types::Crate, rustdoc[3f0501292528f1e0]::config::RenderOptions, rustdoc[3f0501292528f1e0]::formats::cache::Cache), rustdoc[3f0501292528f1e0]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  24:     0x558029420a6d - rustc_span[4085bd95152d41da]::with_source_map::<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  25:     0x558029157684 - <scoped_tls[b966ac58386d5624]::ScopedKey<rustc_span[4085bd95152d41da]::SessionGlobals>>::set::<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>
  26:     0x5580291e2f50 - std[b5fab123d48d12b9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[258a4538246304e0]::util::run_in_thread_pool_with_globals<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>
  27:     0x5580292d388d - <<std[b5fab123d48d12b9]::thread::Builder>::spawn_unchecked_<rustc_interface[258a4538246304e0]::util::run_in_thread_pool_with_globals<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#1} as core[eec4a6d8192687cb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7fb6b290cf93 - std::sys::unix::thread::Thread::new::thread_start::h6a3611c28007b704
  29:     0x7fb6b26e412d - start_thread
  30:     0x7fb6b2765bc0 - clone3
  31:                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-compiler&template=ice.md

note: rustc 1.70.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -C codegen-units=1 -Z ui-testing -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z deduplicate-diagnostics=no -C strip=debuginfo -C debuginfo=0

query stack during panic:
#0 [type_of] computing type of `std::prim_u32`
end of query stack
------------------------------------------
#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]

/// [`u32::MAX`]
//~^ ERROR
pub trait T {
    type MAX;
}

impl T for u32 {
    type MAX = ();
}
---- [ui] tests/rustdoc-ui/intra-doc/issue-108653-3.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: "/var/tmp/rust-build/x86_64-unknown-linux-gnu/stage1/bin/rustdoc" "/home/michael/Development/rust/tests/rustdoc-ui/intra-doc/issue-108653-3.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "-o" "/var/tmp/rust-build/x86_64-unknown-linux-gnu/test/rustdoc-ui/intra-doc/issue-108653-3" "-Cdebuginfo=0" "-Lnative=/var/tmp/rust-build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/var/tmp/rust-build/x86_64-unknown-linux-gnu/test/rustdoc-ui/intra-doc/issue-108653-3/auxiliary"
stdout: none
--- stderr -------------------------------
thread 'rustc' panicked at 'DefId(1:11857 ~ std[b2d9]::prim_u32) does not have a "type_of"', compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:204:1
stack backtrace:
   0:     0x7f238cf04849 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h78f6bced1ab9b952
   1:     0x7f238cf78a3e - core::fmt::write::h5341206de545b898
   2:     0x7f238cec56b5 - std::io::Write::write_fmt::hbeb8ef999f3c7868
   3:     0x7f238cf04605 - std::sys_common::backtrace::print::h0da51f2725c33842
   4:     0x7f238cecd55f - std::panicking::default_hook::{{closure}}::h619e143597771e26
   5:     0x7f238cecd21c - std::panicking::default_hook::h91aabafbf64f1a6b
   6:     0x7f238d880ad5 - rustc_driver_impl[1dcb38fcc6e7e77c]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:     0x7f238cecdf2d - std::panicking::rust_panic_with_hook::h3a745a637417bf43
   8:     0x7f238cf05a89 - std::panicking::begin_panic_handler::{{closure}}::h5d490f47745c1d00
   9:     0x7f238cf0498c - std::sys_common::backtrace::__rust_end_short_backtrace::hb67f613a530a3f9b
  10:     0x7f238cecda92 - rust_begin_unwind
  11:     0x7f238cea8de3 - core::panicking::panic_fmt::h497dcee45bc95959
  12:     0x7f238f8c7a70 - rustc_metadata[bb7e47e5e4c187ff]::rmeta::decoder::cstore_impl::provide_extern::type_of::{closure#2}
  13:     0x7f238f8c7972 - rustc_metadata[bb7e47e5e4c187ff]::rmeta::decoder::cstore_impl::provide_extern::type_of
  14:     0x7f238f4eb791 - rustc_query_system[b7c2d4a4947a6b57]::query::plumbing::try_execute_query::<rustc_query_impl[8b60fe27614f6a9d]::queries::type_of, rustc_query_impl[8b60fe27614f6a9d]::plumbing::QueryCtxt>
  15:     0x7f238f2a86f5 - <rustc_query_impl[8b60fe27614f6a9d]::Queries as rustc_middle[8f8cc58a38a08b32]::ty::query::QueryEngine>::type_of
  16:     0x5564e34a0c96 - rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::ambiguity_error
  17:     0x5564e349bd90 - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_item
  18:     0x5564e34a472a - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_inner_recur
  19:     0x5564e349d1db - <rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::LinkCollector as rustdoc[3f0501292528f1e0]::visit::DocVisitor>::visit_item
  20:     0x5564e3494f4f - rustdoc[3f0501292528f1e0]::passes::collect_intra_doc_links::collect_intra_doc_links
  21:     0x5564e34a683e - <rustc_session[5867f2a876facb7]::session::Session>::time::<rustdoc[3f0501292528f1e0]::clean::types::Crate, rustdoc[3f0501292528f1e0]::core::run_global_ctxt::{closure#7}>
  22:     0x5564e3541e67 - rustdoc[3f0501292528f1e0]::core::run_global_ctxt
  23:     0x5564e34a6ac9 - <rustc_session[5867f2a876facb7]::session::Session>::time::<(rustdoc[3f0501292528f1e0]::clean::types::Crate, rustdoc[3f0501292528f1e0]::config::RenderOptions, rustdoc[3f0501292528f1e0]::formats::cache::Cache), rustdoc[3f0501292528f1e0]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  24:     0x5564e36aca6d - rustc_span[4085bd95152d41da]::with_source_map::<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  25:     0x5564e33e3684 - <scoped_tls[b966ac58386d5624]::ScopedKey<rustc_span[4085bd95152d41da]::SessionGlobals>>::set::<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>
  26:     0x5564e346ef50 - std[b5fab123d48d12b9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[258a4538246304e0]::util::run_in_thread_pool_with_globals<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>
  27:     0x5564e355f88d - <<std[b5fab123d48d12b9]::thread::Builder>::spawn_unchecked_<rustc_interface[258a4538246304e0]::util::run_in_thread_pool_with_globals<rustc_interface[258a4538246304e0]::interface::run_compiler<core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>, rustdoc[3f0501292528f1e0]::main_args::{closure#1}>::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[eec4a6d8192687cb]::result::Result<(), rustc_span[4085bd95152d41da]::ErrorGuaranteed>>::{closure#1} as core[eec4a6d8192687cb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7f238cf0cf93 - std::sys::unix::thread::Thread::new::thread_start::h6a3611c28007b704
  29:     0x7f238cce412d - start_thread
  30:     0x7f238cd65bc0 - clone3
  31:                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-compiler&template=ice.md

note: rustc 1.70.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -C codegen-units=1 -Z ui-testing -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z deduplicate-diagnostics=no -C strip=debuginfo -C debuginfo=0

query stack during panic:
#0 [type_of] computing type of `std::prim_u32`
end of query stack
------------------------------------------

@jyn514
Copy link
Member

jyn514 commented Mar 6, 2023

Why is this rewriting so much of the resolution code? Don't we already do the majority of this work elsewhere in the pass?

@GuillaumeGomez
Copy link
Member Author

Why is this rewriting so much of the resolution code? Don't we already do the majority of this work elsewhere in the pass?

We could indeed store directly the information we get from the resolve method. That could make the code a lot simpler, thanks for the suggestion!

@notriddle notriddle 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 9, 2023
@GuillaumeGomez
Copy link
Member Author

I'll close this one in favour of #109104.

@GuillaumeGomez GuillaumeGomez deleted the fix-invalid-suggestion-ambiguous-intra-doc branch March 15, 2023 09:39
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-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.

[rustdoc] Misleading error message for ambiguous link to associated type/const
4 participants