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

resolve: Fix resolution of empty paths passed from rustdoc #95681

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to the changes here, this error message seems wrong. Should we open an issue to change the diagnostic to check for empty paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe.
I don't plan to work on this personally.

Copy link
Member

Choose a reason for hiding this comment

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

I'm looking into it.

|
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: 1 warning emitted