Skip to content

Commit

Permalink
Rollup merge of rust-lang#95681 - petrochenkov:doclinkregr2, r=Dylan-DPC
Browse files Browse the repository at this point in the history
resolve: Fix resolution of empty paths passed from rustdoc

Fixes rust-lang#95337 (comment)
  • Loading branch information
Dylan-DPC authored Apr 5, 2022
2 parents 8046c93 + 7faaf8f commit 1de6149
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3298,7 +3298,9 @@ impl<'a> Resolver<'a> {
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
Some(path_res.base_res())
}
PathResult::NonModule(..) | PathResult::Failed { .. } => None,
PathResult::Module(ModuleOrUniformRoot::ExternPrelude)
| PathResult::NonModule(..)
| PathResult::Failed { .. } => None,
PathResult::Module(..) | PathResult::Indeterminate => unreachable!(),
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc-ui/intra-doc/global-path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Doc link path with empty prefix that resolves to "extern prelude" instead of a module.

// check-pass
// edition:2018

/// [::Unresolved]
//~^ WARN unresolved link to `::Unresolved`
pub struct Item;
10 changes: 10 additions & 0 deletions src/test/rustdoc-ui/intra-doc/global-path.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: unresolved link to `::Unresolved`
--> $DIR/global-path.rs:6:6
|
LL | /// [::Unresolved]
| ^^^^^^^^^^^^ no item named `` in scope
|
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: 1 warning emitted

0 comments on commit 1de6149

Please sign in to comment.