Skip to content

panic documenting local juice repo #113896

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

Closed
smokytheangel0 opened this issue Jul 20, 2023 · 1 comment · Fixed by #113958
Closed

panic documenting local juice repo #113896

smokytheangel0 opened this issue Jul 20, 2023 · 1 comment · Fixed by #113958
Labels
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.

Comments

@smokytheangel0
Copy link

Code

in local git repo for crate juice

cargo doc --open --features=native --offline

Meta

rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

Error output

thread 'rustc' panicked at 'no resolution for "2" MacroNS DefId(0:181 ~ juice[5af2]::layers)', src/librustdoc/passes/collect_intra_doc_links.rs:400:32
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: <rustdoc::passes::collect_intra_doc_links::LinkCollector>::resolve_path
   3: <rustdoc::passes::collect_intra_doc_links::LinkCollector>::resolve
   4: <rustdoc::passes::collect_intra_doc_links::LinkCollector>::resolve_links
   5: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::visit::DocVisitor>::visit_inner_recur
   6: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::visit::DocVisitor>::visit_inner_recur
   7: rustdoc::passes::collect_intra_doc_links::collect_intra_doc_links
   8: <rustc_session::session::Session>::time::<rustdoc::clean::types::Crate, rustdoc::core::run_global_ctxt::{closure#8}>
   9: rustdoc::core::run_global_ctxt
  10: <rustc_session::session::Session>::time::<(rustdoc::clean::types::Crate, rustdoc::config::RenderOptions, rustdoc::formats::cache::Cache), rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  11: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  12: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}>
  13: <rustc_interface::interface::Compiler>::enter::<rustdoc::main_args::{closure#1}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  14: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}::{closure#0}>
  15: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 (90c541806 2023-05-31) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `juice` (lib doc) generated 42 warnings
error: could not document `juice`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name juice juice/src/lib.rs -o /home/******/Desktop/machine_learning/juice/target/doc --cfg 'feature="cuda"' --cfg 'feature="default"' --cfg 'feature="native"' --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=80 -C metadata=f90add49647a7ead -L dependency=/home/******/Desktop/machine_learning/juice/target/debug/deps --extern capnp=/home/******/Desktop/machine_learning/juice/target/debug/deps/libcapnp-2e4e87798fe7db83.rmeta --extern coaster=/home/******/Desktop/machine_learning/juice/target/debug/deps/libcoaster-ae3f4ede8d2cb20b.rmeta --extern coaster_blas=/home/******/Desktop/machine_learning/juice/target/debug/deps/libcoaster_blas-6114c7b30306b38c.rmeta --extern coaster_nn=/home/******/Desktop/machine_learning/juice/target/debug/deps/libcoaster_nn-23c55d2d5eb42c42.rmeta --extern log=/home/******/Desktop/machine_learning/juice/target/debug/deps/liblog-d526c2099c6b1a32.rmeta --extern num=/home/******/Desktop/machine_learning/juice/target/debug/deps/libnum-17154bdc49d31f6c.rmeta --extern rand=/home/******/Desktop/machine_learning/juice/target/debug/deps/librand-604775096d3703a0.rmeta --extern timeit=/home/******/Desktop/machine_learning/juice/target/debug/deps/libtimeit-0b6b2640a1d4bcdf.rmeta --crate-version 0.3.0` (exit status: 101)

Backtrace

<backtrace>

@smokytheangel0 smokytheangel0 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 Jul 20, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 20, 2023
@smokytheangel0
Copy link
Author

here is RUST_BACKTRACE=full

thread 'rustc' panicked at 'no resolution for "2" MacroNS DefId(0:181 ~ juice[5af2]::layers)', src/librustdoc/passes/collect_intra_doc_links.rs:400:32
stack backtrace:
   0:     0x7f7402e3ccca - std::backtrace_rs::backtrace::libunwind::trace::h9a6b80bbf328ba5d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7402e3ccca - std::backtrace_rs::backtrace::trace_unsynchronized::hd162ec543a11886b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7402e3ccca - std::sys_common::backtrace::_print_fmt::h78a5099be12f51a6
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7402e3ccca - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1c5390454d74f71
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7402ea10cf - core::fmt::write::h9ffde816c577717b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f7402e2f805 - std::io::Write::write_fmt::h88186074961638e4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x7f7402e3ca95 - std::sys_common::backtrace::_print::h184198273ed08d59
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7402e3ca95 - std::sys_common::backtrace::print::h1b4d8e7add699453
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7402e3f73e - std::panicking::default_hook::{{closure}}::h393bcea75423915a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x7f7402e3f4e5 - std::panicking::default_hook::h48c64f31d8b3fd03
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x7f74060fb995 - <rustc_driver_impl[fe6df70259db788d]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[da82827a87f140f9]::ops::function::FnOnce<(&core[da82827a87f140f9]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f7402e3ff34 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb9b860f5a1175bda
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
  12:     0x7f7402e3ff34 - std::panicking::rust_panic_with_hook::hafdc493a79370062
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:695:13
  13:     0x7f7402e3fca9 - std::panicking::begin_panic_handler::{{closure}}::h0a64bc82e36bedc7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:582:13
  14:     0x7f7402e3d136 - std::sys_common::backtrace::__rust_end_short_backtrace::hc203444fb7416a16
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f7402e3fa02 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  16:     0x7f7402e9d443 - core::panicking::panic_fmt::h0f6ef0178afce4f2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  17:     0x5644382a1557 - <rustdoc[d05d4d99bb075fe1]::passes::collect_intra_doc_links::LinkCollector>::resolve_path
  18:     0x5644382a16c8 - <rustdoc[d05d4d99bb075fe1]::passes::collect_intra_doc_links::LinkCollector>::resolve
  19:     0x5644382a6485 - <rustdoc[d05d4d99bb075fe1]::passes::collect_intra_doc_links::LinkCollector>::resolve_links
  20:     0x5644382aea20 - <rustdoc[d05d4d99bb075fe1]::passes::collect_intra_doc_links::LinkCollector as rustdoc[d05d4d99bb075fe1]::visit::DocVisitor>::visit_inner_recur
  21:     0x5644382aea08 - <rustdoc[d05d4d99bb075fe1]::passes::collect_intra_doc_links::LinkCollector as rustdoc[d05d4d99bb075fe1]::visit::DocVisitor>::visit_inner_recur
  22:     0x5644382a00bc - rustdoc[d05d4d99bb075fe1]::passes::collect_intra_doc_links::collect_intra_doc_links
  23:     0x564438455dc2 - <rustc_session[99ba0ed9c533f203]::session::Session>::time::<rustdoc[d05d4d99bb075fe1]::clean::types::Crate, rustdoc[d05d4d99bb075fe1]::core::run_global_ctxt::{closure#8}>
  24:     0x56443853f494 - rustdoc[d05d4d99bb075fe1]::core::run_global_ctxt
  25:     0x56443845603e - <rustc_session[99ba0ed9c533f203]::session::Session>::time::<(rustdoc[d05d4d99bb075fe1]::clean::types::Crate, rustdoc[d05d4d99bb075fe1]::config::RenderOptions, rustdoc[d05d4d99bb075fe1]::formats::cache::Cache), rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  26:     0x564438367ce8 - <std[b70fedfd8b77e9]::thread::local::LocalKey<core[da82827a87f140f9]::cell::Cell<*const ()>>>::with::<rustc_middle[a487dff4633a86d0]::ty::context::tls::enter_context<<rustc_middle[a487dff4633a86d0]::ty::context::GlobalCtxt>::enter<rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}::{closure#0}::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>
  27:     0x5644384c561b - <rustc_interface[7aa24cde61830128]::queries::QueryResult<&rustc_middle[a487dff4633a86d0]::ty::context::GlobalCtxt>>::enter::<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}::{closure#0}::{closure#0}>
  28:     0x56443831909e - <rustc_interface[7aa24cde61830128]::interface::Compiler>::enter::<rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>
  29:     0x5644384a1dcb - rustc_span[2f805118d893a80f]::set_source_map::<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustc_interface[7aa24cde61830128]::interface::run_compiler<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  30:     0x564438397bb3 - <scoped_tls[5a12cb46d771591f]::ScopedKey<rustc_span[2f805118d893a80f]::SessionGlobals>>::set::<rustc_interface[7aa24cde61830128]::interface::run_compiler<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}>::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>
  31:     0x56443827f5f9 - std[b70fedfd8b77e9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7aa24cde61830128]::util::run_in_thread_pool_with_globals<rustc_interface[7aa24cde61830128]::interface::run_compiler<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}>::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>
  32:     0x564438528e7d - <<std[b70fedfd8b77e9]::thread::Builder>::spawn_unchecked_<rustc_interface[7aa24cde61830128]::util::run_in_thread_pool_with_globals<rustc_interface[7aa24cde61830128]::interface::run_compiler<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustdoc[d05d4d99bb075fe1]::main_args::{closure#1}>::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#1} as core[da82827a87f140f9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f7402e4a3b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha1f2224656a778fb
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  34:     0x7f7402e4a3b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haa29ed9703f354b7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  35:     0x7f7402e4a3b5 - std::sys::unix::thread::Thread::new::thread_start::h33b6dae3e3692197
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys/unix/thread.rs:108:17
  36:     0x7f7402a74b43 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  37:     0x7f7402b06a00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  38:                0x0 - <unknown>

@bors bors closed this as completed in beef07f Jul 25, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jul 26, 2023
…henkov

fix intra-doc links on nested `use` and `extern crate` items

This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example:
```rust
/// Re-export [`fmt`] and [`io`].
pub use std::{fmt, io}; // "nested" use = use with braces

/// Re-export [`std`].
pub extern crate std;
```

Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`.

<details>

During AST->HIR lowering, nested `use` items are desugared like this:
```rust
pub use std::{}; // "list stem"
pub use std::fmt;
pub use std::io;
```
Each of these HIR nodes has it's own effective visibility and the list stem is always considered private.
To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items.

</details>

For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places.

As as side effect of fixing `extern crate`, i've turned
```rust
#[doc(masked)]
extern crate self as _;
```
into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus.

fixes rust-lang/rust#113896
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2023
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Apr 7, 2024
…henkov

fix intra-doc links on nested `use` and `extern crate` items

This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example:
```rust
/// Re-export [`fmt`] and [`io`].
pub use std::{fmt, io}; // "nested" use = use with braces

/// Re-export [`std`].
pub extern crate std;
```

Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`.

<details>

During AST->HIR lowering, nested `use` items are desugared like this:
```rust
pub use std::{}; // "list stem"
pub use std::fmt;
pub use std::io;
```
Each of these HIR nodes has it's own effective visibility and the list stem is always considered private.
To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items.

</details>

For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places.

As as side effect of fixing `extern crate`, i've turned
```rust
#[doc(masked)]
extern crate self as _;
```
into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus.

fixes rust-lang/rust#113896
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
…henkov

fix intra-doc links on nested `use` and `extern crate` items

This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example:
```rust
/// Re-export [`fmt`] and [`io`].
pub use std::{fmt, io}; // "nested" use = use with braces

/// Re-export [`std`].
pub extern crate std;
```

Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`.

<details>

During AST->HIR lowering, nested `use` items are desugared like this:
```rust
pub use std::{}; // "list stem"
pub use std::fmt;
pub use std::io;
```
Each of these HIR nodes has it's own effective visibility and the list stem is always considered private.
To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items.

</details>

For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places.

As as side effect of fixing `extern crate`, i've turned
```rust
#[doc(masked)]
extern crate self as _;
```
into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus.

fixes rust-lang/rust#113896
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. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants