-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Remove incorrect assert #79976
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
Remove incorrect assert #79976
Conversation
@bors r+ p=1 This is breaking rustc-perf. |
📌 Commit 130dbe4 has been approved by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hotfix!
@@ -436,8 +436,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { | |||
// Try looking for methods and associated items. | |||
let mut split = path_str.rsplitn(2, "::"); | |||
// NB: `split`'s first element is always defined, even if the delimiter was not present. | |||
// NB: `item_str` could be empty when resolving in the root namespace (e.g. `::std`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, I'm confused. Note that rsplit returns a reverse iterator. In this example, I think the first element would be std, right? It would not be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the debug output from the assertion failure on hyper:
TRACE rustdoc::passes::collect_intra_doc_links considering link '::client'
DEBUG rustdoc::passes::collect_intra_doc_links resolving ::client as a macro in the module DefId(0:248 ~ hyper[8787]::body)
DEBUG rustdoc::passes::collect_intra_doc_links ::client resolved to Err(()) in namespace TypeNS
DEBUG rustdoc::passes::collect_intra_doc_links resolved to Err(()) in namespace TypeNS
DEBUG rustdoc::passes::collect_intra_doc_links ::client resolved to Err(()) in namespace ValueNS
DEBUG rustdoc::passes::collect_intra_doc_links resolved to Err(()) in namespace TypeNS
DEBUG rustdoc::passes::collect_intra_doc_links looking for enum variant ::client
DEBUG rustdoc::passes::collect_intra_doc_links resolved to Err(()) in namespace TypeNS
thread 'rustc' panicked at 'assertion failed: !item_str.is_empty()', src/librustdoc/passes/collect_intra_doc_links.rs:439:9
So I think what's going wrong is that resolve_variant
calls resolve
recursively, and on the second call the string is empty (and only has one item in the iterator). This could probably be improved but it would require a redesign of the algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, this is the backtrace:
0: std::panicking::begin_panic
at /home/joshua/rustc/library/std/src/panicking.rs:519:12
1: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:439:9
2: rustdoc::passes::collect_intra_doc_links::LinkCollector::check_full_res
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:637:17
3: rustdoc::passes::collect_intra_doc_links::resolution_failure::{{closure}}
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:1680:33
4: rustdoc::passes::collect_intra_doc_links::report_diagnostic::{{closure}}
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:1597:9
5: core::ops::function::FnOnce::call_once{{vtable.shim}}
at /home/joshua/rustc/library/core/src/ops/function.rs:227:5
6: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /home/joshua/rustc/library/alloc/src/boxed.rs:1328:9
7: rustc_middle::lint::struct_lint_level::struct_lint_level_impl
at /home/joshua/rustc/compiler/rustc_middle/src/lint.rs:362:9
8: rustc_middle::lint::struct_lint_level
at /home/joshua/rustc/compiler/rustc_middle/src/lint.rs:364:5
9: rustc_middle::ty::context::TyCtxt::struct_span_lint_hir
at /home/joshua/rustc/compiler/rustc_middle/src/ty/context.rs:2562:9
10: rustdoc::passes::collect_intra_doc_links::report_diagnostic
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:1567:5
11: rustdoc::passes::collect_intra_doc_links::resolution_failure
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:1617:5
12: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve_with_disambiguator
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:1299:21
13: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve_link
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:1082:39
14: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
at /home/joshua/rustc/src/librustdoc/passes/collect_intra_doc_links.rs:909:28
Notice this is in diagnostics, not the main resole code.
☀️ Test successful - checks-actions |
Fixes an assertion failure when resolving
::std
(or any other crate that uses the::
style, see https://github.com/rust-lang/rust/pull/79809/files#r541776478, https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Perf.20failing).Unblocks rust-lang/rustc-perf#806.
r? @ghost - this is a trivial fix and breaking rustc-perf so I'm going to approve it unilaterally. cc @Mark-Simulacrum @Eric-Arellano