Skip to content

Do not ICE when failing to resolve for rustdoc. #109345

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
wants to merge 1 commit into from
Closed
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
5 changes: 1 addition & 4 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,10 +1860,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
match self.maybe_resolve_path(&segments, Some(ns), &parent_scope) {
PathResult::Module(ModuleOrUniformRoot::Module(module)) => Some(module.res().unwrap()),
PathResult::NonModule(path_res) => path_res.full_res(),
PathResult::Module(ModuleOrUniformRoot::ExternPrelude) | PathResult::Failed { .. } => {
None
}
PathResult::Module(..) | PathResult::Indeterminate => unreachable!(),
PathResult::Module(..) | PathResult::Failed { .. } | PathResult::Indeterminate => None,
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/ui/resolve/issue-109343.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Verify that we do not ICE when failing to resolve a doc-link.
#![crate_type = "lib"]

extern crate f;
//~^ ERROR E0463

pub use inner::f;
//~^ ERROR E0432

/// [mod@std::env] [g]
pub use f as g;
//~^ ERROR pub_use_of_private_extern_crate
//~| WARN this was previously accepted by the compiler
28 changes: 28 additions & 0 deletions tests/ui/resolve/issue-109343.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
error[E0463]: can't find crate for `f`
--> $DIR/issue-109343.rs:4:1
|
LL | extern crate f;
| ^^^^^^^^^^^^^^^ can't find crate

error[E0432]: unresolved import `inner`
--> $DIR/issue-109343.rs:7:9
|
LL | pub use inner::f;
| ^^^^^ maybe a missing crate `inner`?
|
= help: consider adding `extern crate inner` to use the `inner` crate

error: extern crate `f` is private, and cannot be re-exported (error E0365), consider declaring with `pub`
--> $DIR/issue-109343.rs:11:9
|
LL | pub use f as g;
| ^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
= note: `#[deny(pub_use_of_private_extern_crate)]` on by default

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0432, E0463.
For more information about an error, try `rustc --explain E0432`.