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 ice: 'internal error: entered unreachable code', compiler/rustc_resolve/src/lib.rs:3305:6 #95879

Closed
matthiaskrgr opened this issue Apr 10, 2022 · 5 comments · Fixed by #95887
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

I tried this code:

This code needs to be placed into compiler/rustc_borrowck/src/diagnostics/mod.rs (just overwrite the file).
My repo is currently at f7b4824

//! hello
mod find_all_local_uses;

If you then run rustdoc ./compiler/rustc_borrowck/src/diagnostics/mod.rs, rustdoc will crash:

Meta

rustc --version --verbose:

rustdoc 1.62.0-nightly (8bf93e9b6 2022-04-09)
binary: rustdoc
commit-hash: 8bf93e9b6791acee3a594ed202fdfe45ad9952b5
commit-date: 2022-04-09
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.0
Backtrace

error[E0433]: failed to resolve: maybe a missing crate `rustc_middle`?
 --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:3:5
  |
3 | use rustc_middle::mir::visit::{PlaceContext, Visitor};
  |     ^^^^^^^^^^^^ maybe a missing crate `rustc_middle`?

error[E0433]: failed to resolve: maybe a missing crate `rustc_middle`?
 --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:4:5
  |
4 | use rustc_middle::mir::{Body, Local, Location};
  |     ^^^^^^^^^^^^ maybe a missing crate `rustc_middle`?

error[E0412]: cannot find type `Body` in this scope
 --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:9:33
  |
9 | pub(super) fn find<'tcx>(body: &Body<'tcx>, local: Local) -> BTreeSet<Location> {
  |                                 ^^^^ not found in this scope

error[E0412]: cannot find type `Local` in this scope
 --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:9:52
  |
9 | pub(super) fn find<'tcx>(body: &Body<'tcx>, local: Local) -> BTreeSet<Location> {
  |                                                    ^^^^^ not found in this scope

error[E0412]: cannot find type `Location` in this scope
 --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:9:71
  |
9 | pub(super) fn find<'tcx>(body: &Body<'tcx>, local: Local) -> BTreeSet<Location> {
  |                                                                       ^^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 | use std::panic::Location;
  |

error[E0412]: cannot find type `Local` in this scope
  --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:16:16
   |
16 |     for_local: Local,
   |                ^^^^^ not found in this scope

error[E0412]: cannot find type `Location` in this scope
  --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:17:20
   |
17 |     uses: BTreeSet<Location>,
   |                    ^^^^^^^^ not found in this scope
   |
help: consider importing this struct
   |
1  | use std::panic::Location;
   |

error[E0405]: cannot find trait `Visitor` in this scope
  --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:20:12
   |
20 | impl<'tcx> Visitor<'tcx> for AllLocalUsesVisitor {
   |            ^^^^^^^ not found in this scope

error[E0412]: cannot find type `Local` in this scope
  --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:21:39
   |
21 |     fn visit_local(&mut self, local: &Local, _context: PlaceContext, location: Location) {
   |                                       ^^^^^ not found in this scope

error[E0412]: cannot find type `PlaceContext` in this scope
  --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:21:56
   |
21 |     fn visit_local(&mut self, local: &Local, _context: PlaceContext, location: Location) {
   |                                                        ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `Location` in this scope
  --> ./compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs:21:80
   |
21 |     fn visit_local(&mut self, local: &Local, _context: PlaceContext, location: Location) {
   |                                                                                ^^^^^^^^ not found in this scope
   |
help: consider importing this struct
   |
1  | use std::panic::Location;
   |

thread 'rustc' panicked at 'internal error: entered unreachable code', compiler/rustc_resolve/src/lib.rs:3305:67
stack backtrace:
   0:     0x7ff4d549e00d - std::backtrace_rs::backtrace::libunwind::trace::h06b71e168fca8ca7
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff4d549e00d - std::backtrace_rs::backtrace::trace_unsynchronized::hd5c568c45ebf115f
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff4d549e00d - std::sys_common::backtrace::_print_fmt::h2207f18151caed70
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7ff4d549e00d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hec1ef25b87918dac
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7ff4d54f7d2c - core::fmt::write::h3bdfdbc9caaeb5c4
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/core/src/fmt/mod.rs:1194:17
   5:     0x7ff4d548f8d1 - std::io::Write::write_fmt::h75f007d851ff8f3e
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/io/mod.rs:1655:15
   6:     0x7ff4d54a0f25 - std::sys_common::backtrace::_print::h8cb608922c1cc56d
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7ff4d54a0f25 - std::sys_common::backtrace::print::h69d750eeeb320760
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7ff4d54a0f25 - std::panicking::default_hook::{{closure}}::h220d8c7b31c1776e
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/panicking.rs:295:22
   9:     0x7ff4d54a0b99 - std::panicking::default_hook::hd732eb9b63a7d08e
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/panicking.rs:314:9
  10:     0x7ff4d5ccf3c1 - rustc_driver[3655e38759671b1e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7ff4d54a16c0 - std::panicking::rust_panic_with_hook::he731ea0e4d942ce4
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/panicking.rs:702:17
  12:     0x7ff4d54a14b9 - std::panicking::begin_panic_handler::{{closure}}::h7572f87a59230791
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/panicking.rs:586:13
  13:     0x7ff4d549e4c4 - std::sys_common::backtrace::__rust_end_short_backtrace::ha3eefb66086a857c
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7ff4d54a1229 - rust_begin_unwind
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/panicking.rs:584:5
  15:     0x7ff4d5465773 - core::panicking::panic_fmt::h4508dc135e264600
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/core/src/panicking.rs:142:14
  16:     0x7ff4d546563d - core::panicking::panic::hed1ca88aad7c3049
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/core/src/panicking.rs:48:5
  17:     0x7ff4d6130459 - <rustc_resolve[577bf44bd1426e45]::Resolver>::resolve_rustdoc_path
  18:     0x558d3f747622 - <rustdoc[31e9a93f42be1f5]::passes::collect_intra_doc_links::early::EarlyDocLinkResolver>::load_links_in_attrs
  19:     0x558d3f747ce0 - <rustdoc[31e9a93f42be1f5]::passes::collect_intra_doc_links::early::EarlyDocLinkResolver as rustc_ast[139425a543286658]::visit::Visitor>::visit_item
  20:     0x558d3f79bd2b - rustc_ast[139425a543286658]::visit::walk_item::<rustdoc[31e9a93f42be1f5]::passes::collect_intra_doc_links::early::EarlyDocLinkResolver>
  21:     0x558d3f747d2e - <rustdoc[31e9a93f42be1f5]::passes::collect_intra_doc_links::early::EarlyDocLinkResolver as rustc_ast[139425a543286658]::visit::Visitor>::visit_item
  22:     0x558d3f74559a - rustdoc[31e9a93f42be1f5]::passes::collect_intra_doc_links::early::early_resolve_intra_doc_links
  23:     0x558d3f63962d - <rustc_interface[aab2741c181344a3]::interface::Compiler>::enter::<rustdoc[31e9a93f42be1f5]::main_options::{closure#0}::{closure#0}, core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>>
  24:     0x558d3f7d44f6 - rustc_span[2556154be3375056]::with_source_map::<core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>, rustc_interface[aab2741c181344a3]::interface::create_compiler_and_run<core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>, rustdoc[31e9a93f42be1f5]::main_options::{closure#0}>::{closure#1}>
  25:     0x558d3f670a04 - rustc_interface[aab2741c181344a3]::interface::create_compiler_and_run::<core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>, rustdoc[31e9a93f42be1f5]::main_options::{closure#0}>
  26:     0x558d3f4cd237 - <scoped_tls[8f93d9f95e89128f]::ScopedKey<rustc_span[2556154be3375056]::SessionGlobals>>::set::<rustdoc[31e9a93f42be1f5]::main_args::{closure#0}, core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>>
  27:     0x558d3f6712df - std[4f0b898746aae38d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[aab2741c181344a3]::util::run_in_thread_pool_with_globals<rustdoc[31e9a93f42be1f5]::main_args::{closure#0}, core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>>::{closure#0}, core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>>
  28:     0x558d3f713a19 - <<std[4f0b898746aae38d]::thread::Builder>::spawn_unchecked_<rustc_interface[aab2741c181344a3]::util::run_in_thread_pool_with_globals<rustdoc[31e9a93f42be1f5]::main_args::{closure#0}, core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>>::{closure#0}, core[491626612f8df212]::result::Result<(), rustc_errors[ced839e2d504a56c]::ErrorGuaranteed>>::{closure#1} as core[491626612f8df212]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7ff4d54ab823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6aa3defc4f10dc70
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/alloc/src/boxed.rs:1858:9
  30:     0x7ff4d54ab823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h553d7c8698383f07
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/alloc/src/boxed.rs:1858:9
  31:     0x7ff4d54ab823 - std::sys::unix::thread::Thread::new::thread_start::h0643c814f607f90a
                               at /rustc/8bf93e9b6791acee3a594ed202fdfe45ad9952b5/library/std/src/sys/unix/thread.rs:108:17
  32:     0x7ff4d519b5c2 - start_thread
  33:     0x7ff4d5220584 - __clone
  34:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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.62.0-nightly (8bf93e9b6 2022-04-09) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 11 previous errors

Some errors have detailed explanations: E0405, E0412, E0433.
For more information about an error, try `rustc --explain E0405`.

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 10, 2022
@petrochenkov petrochenkov self-assigned this Apr 10, 2022
@petrochenkov
Copy link
Contributor

petrochenkov commented Apr 10, 2022

This was fixed by #95681, most likely.
I'm not sure which rustdoc do you use, could you check whether it includes that PR?

UPD: Ah, ok, it's 2022-04-09, let me check.

@matthiaskrgr
Copy link
Member Author

I used yesterdays/today(?) nightly which already contains #95681 so I was a bit suspect of this being different issue 😅

@petrochenkov
Copy link
Contributor

Confirmed, this is a different case, and not even a regression from #95337 like #95879 (comment), it reproduces with stable rustc as well.

@petrochenkov
Copy link
Contributor

Minimized:

use unresolved_crate::module::Name;

/// [Name]
pub struct S;

@petrochenkov
Copy link
Contributor

Fixed in #95887.

@bors bors closed this as completed in 0a8acac Apr 16, 2022
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-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants