diff options
| author | Camelid <camelidcamel@gmail.com> | 2020-10-02 18:00:57 -0700 |
|---|---|---|
| committer | Camelid <camelidcamel@gmail.com> | 2020-10-02 18:00:57 -0700 |
| commit | 21fb9dfa8d49d6aa3e74dfcc7032badcd6f51b91 (patch) | |
| tree | 955a0fc9e3f9f31301edfa30c9ee3f89216f2d15 | |
| parent | 0193a8871cc2c2cca2de03243097519ce6c910ce (diff) | |
| download | rust-21fb9dfa8d49d6aa3e74dfcc7032badcd6f51b91.tar.gz rust-21fb9dfa8d49d6aa3e74dfcc7032badcd6f51b91.zip | |
Use old error when there's partial resolution
The new error was confusing when there was partial resolution (something like `std::io::nonexistent`); the old one is better for those cases.
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 15 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/intra-link-errors.rs | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/intra-link-errors.stderr | 4 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 56585919ec0..024d333d871 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1575,11 +1575,16 @@ fn resolution_failure( _ => None, }; // See if this was a module: `[path]` or `[std::io::nope]` - if let Some(_module) = last_found_module { - let note = format!( - "there is no item named `{}` in scope", - unresolved - ); + if let Some(module) = last_found_module { + let note = if partial_res.is_some() { + let module_name = collector.cx.tcx.item_name(module); + format!( + "the module `{}` contains no item named `{}`", + module_name, unresolved + ) + } else { + format!("there is no item named `{}` in scope", unresolved) + }; if let Some(span) = sp { diag.span_label(span, ¬e); } else { diff --git a/src/test/rustdoc-ui/intra-link-errors.rs b/src/test/rustdoc-ui/intra-link-errors.rs index 872fb70bfc5..701fd6991c4 100644 --- a/src/test/rustdoc-ui/intra-link-errors.rs +++ b/src/test/rustdoc-ui/intra-link-errors.rs @@ -18,11 +18,11 @@ /// [std::io::not::here] //~^ ERROR unresolved link -//~| NOTE there is no item named `not` in scope +//~| NOTE `io` contains no item named `not` /// [type@std::io::not::here] //~^ ERROR unresolved link -//~| NOTE there is no item named `not` in scope +//~| NOTE `io` contains no item named `not` /// [std::io::Error::x] //~^ ERROR unresolved link diff --git a/src/test/rustdoc-ui/intra-link-errors.stderr b/src/test/rustdoc-ui/intra-link-errors.stderr index 1299ec5af4b..8b12c721f78 100644 --- a/src/test/rustdoc-ui/intra-link-errors.stderr +++ b/src/test/rustdoc-ui/intra-link-errors.stderr @@ -26,13 +26,13 @@ error: unresolved link to `std::io::not::here` --> $DIR/intra-link-errors.rs:19:6 | LL | /// [std::io::not::here] - | ^^^^^^^^^^^^^^^^^^ there is no item named `not` in scope + | ^^^^^^^^^^^^^^^^^^ the module `io` contains no item named `not` error: unresolved link to `std::io::not::here` --> $DIR/intra-link-errors.rs:23:6 | LL | /// [type@std::io::not::here] - | ^^^^^^^^^^^^^^^^^^^^^^^ there is no item named `not` in scope + | ^^^^^^^^^^^^^^^^^^^^^^^ the module `io` contains no item named `not` error: unresolved link to `std::io::Error::x` --> $DIR/intra-link-errors.rs:27:6 |
