Skip to content

Commit 5ea3eaf

Browse files
committed
Name the current module
'not in scope' -> 'not in `module`'
1 parent b2a5a7a commit 5ea3eaf

10 files changed

+61
-84
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1554,12 +1554,13 @@ fn resolution_failure(
15541554
}
15551555
variants_seen.push(variant);
15561556
let note = match failure {
1557-
ResolutionFailure::NotInScope { name, .. } => {
1557+
ResolutionFailure::NotInScope { module_id, name, .. } => {
15581558
if in_scope {
15591559
continue;
15601560
}
15611561
// NOTE: uses an explicit `continue` so the `note:` will come before the `help:`
1562-
let note = format!("no item named `{}` is in scope", name);
1562+
let module_name = collector.cx.tcx.item_name(module_id);
1563+
let note = format!("no item named `{}` in `{}`", name, module_name);
15631564
if let Some(span) = sp {
15641565
diag.span_label(span, &note);
15651566
} else {

src/test/rustdoc-ui/assoc-item-not-in-scope.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ error: unresolved link to `S::fmt`
22
--> $DIR/assoc-item-not-in-scope.rs:4:14
33
|
44
LL | /// Link to [`S::fmt`]
5-
| ^^^^^^^^
5+
| ^^^^^^^^ the struct `S` has no field or associated item named `fmt`
66
|
77
note: the lint level is defined here
88
--> $DIR/assoc-item-not-in-scope.rs:1:9
99
|
1010
LL | #![deny(broken_intra_doc_links)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^
12-
= note: the struct `S` has no field or associated item named `fmt`
1312

1413
error: aborting due to previous error
1514

src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ error: unresolved link to `v2`
22
--> $DIR/deny-intra-link-resolution-failure.rs:3:6
33
|
44
LL | /// [v2]
5-
| ^^
5+
| ^^ no item named `v2` in `deny_intra_link_resolution_failure`
66
|
77
note: the lint level is defined here
88
--> $DIR/deny-intra-link-resolution-failure.rs:1:9
99
|
1010
LL | #![deny(broken_intra_doc_links)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^
12-
= note: no item named `v2` is in scope
1312
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1413

1514
error: aborting due to previous error

src/test/rustdoc-ui/intra-doc-alias-ice.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ error: unresolved link to `TypeAlias::hoge`
22
--> $DIR/intra-doc-alias-ice.rs:5:30
33
|
44
LL | /// [broken cross-reference](TypeAlias::hoge)
5-
| ^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^ the type alias `TypeAlias` has no associated item named `hoge`
66
|
77
note: the lint level is defined here
88
--> $DIR/intra-doc-alias-ice.rs:1:9
99
|
1010
LL | #![deny(broken_intra_doc_links)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^
12-
= note: the type alias `TypeAlias` has no associated item named `hoge`
1312

1413
error: aborting due to previous error
1514

src/test/rustdoc-ui/intra-link-errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
77
/// [path::to::nonexistent::module]
88
//~^ ERROR unresolved link
9-
//~| NOTE no item named `path` is in scope
9+
//~| NOTE no item named `path` in `intra_link_errors`
1010

1111
/// [path::to::nonexistent::macro!]
1212
//~^ ERROR unresolved link
13-
//~| NOTE no item named `path` is in scope
13+
//~| NOTE no item named `path` in `intra_link_errors`
1414

1515
/// [type@path::to::nonexistent::type]
1616
//~^ ERROR unresolved link
17-
//~| NOTE no item named `path` is in scope
17+
//~| NOTE no item named `path` in `intra_link_errors`
1818

1919
/// [std::io::not::here]
2020
//~^ ERROR unresolved link

src/test/rustdoc-ui/intra-link-errors.stderr

+28-47
Original file line numberDiff line numberDiff line change
@@ -2,134 +2,115 @@ error: unresolved link to `path::to::nonexistent::module`
22
--> $DIR/intra-link-errors.rs:7:6
33
|
44
LL | /// [path::to::nonexistent::module]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in `intra_link_errors`
66
|
77
note: the lint level is defined here
88
--> $DIR/intra-link-errors.rs:1:9
99
|
1010
LL | #![deny(broken_intra_doc_links)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^
12-
= note: no item named `path` is in scope
1312

1413
error: unresolved link to `path::to::nonexistent::macro`
1514
--> $DIR/intra-link-errors.rs:11:6
1615
|
1716
LL | /// [path::to::nonexistent::macro!]
18-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19-
|
20-
= note: no item named `path` is in scope
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in `intra_link_errors`
2118

2219
error: unresolved link to `path::to::nonexistent::type`
2320
--> $DIR/intra-link-errors.rs:15:6
2421
|
2522
LL | /// [type@path::to::nonexistent::type]
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27-
|
28-
= note: no item named `path` is in scope
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in `intra_link_errors`
2924

3025
error: unresolved link to `std::io::not::here`
3126
--> $DIR/intra-link-errors.rs:19:6
3227
|
3328
LL | /// [std::io::not::here]
34-
| ^^^^^^^^^^^^^^^^^^
35-
|
36-
= note: the module `io` has no inner item named `not`
29+
| ^^^^^^^^^^^^^^^^^^ the module `io` has no inner item named `not`
3730

3831
error: unresolved link to `std::io::Error::x`
3932
--> $DIR/intra-link-errors.rs:23:6
4033
|
4134
LL | /// [std::io::Error::x]
42-
| ^^^^^^^^^^^^^^^^^
43-
|
44-
= note: the struct `Error` has no field or associated item named `x`
35+
| ^^^^^^^^^^^^^^^^^ the struct `Error` has no field or associated item named `x`
4536

4637
error: unresolved link to `std::io::ErrorKind::x`
4738
--> $DIR/intra-link-errors.rs:27:6
4839
|
4940
LL | /// [std::io::ErrorKind::x]
50-
| ^^^^^^^^^^^^^^^^^^^^^
51-
|
52-
= note: the enum `ErrorKind` has no variant or associated item named `x`
41+
| ^^^^^^^^^^^^^^^^^^^^^ the enum `ErrorKind` has no variant or associated item named `x`
5342

5443
error: unresolved link to `f::A`
5544
--> $DIR/intra-link-errors.rs:31:6
5645
|
5746
LL | /// [f::A]
58-
| ^^^^
59-
|
60-
= note: `f` is a function, not a module or type, and cannot have associated items
47+
| ^^^^ `f` is a function, not a module or type, and cannot have associated items
6148

6249
error: unresolved link to `S::A`
6350
--> $DIR/intra-link-errors.rs:35:6
6451
|
6552
LL | /// [S::A]
66-
| ^^^^
67-
|
68-
= note: the struct `S` has no field or associated item named `A`
53+
| ^^^^ the struct `S` has no field or associated item named `A`
6954

7055
error: unresolved link to `S::fmt`
7156
--> $DIR/intra-link-errors.rs:39:6
7257
|
7358
LL | /// [S::fmt]
74-
| ^^^^^^
75-
|
76-
= note: the struct `S` has no field or associated item named `fmt`
59+
| ^^^^^^ the struct `S` has no field or associated item named `fmt`
7760

7861
error: unresolved link to `E::D`
7962
--> $DIR/intra-link-errors.rs:43:6
8063
|
8164
LL | /// [E::D]
82-
| ^^^^
83-
|
84-
= note: the enum `E` has no variant or associated item named `D`
65+
| ^^^^ the enum `E` has no variant or associated item named `D`
8566

8667
error: unresolved link to `u8::not_found`
8768
--> $DIR/intra-link-errors.rs:47:6
8869
|
8970
LL | /// [u8::not_found]
90-
| ^^^^^^^^^^^^^
91-
|
92-
= note: the builtin type `u8` does not have an associated item named `not_found`
71+
| ^^^^^^^^^^^^^ the builtin type `u8` does not have an associated item named `not_found`
9372

9473
error: unresolved link to `S`
9574
--> $DIR/intra-link-errors.rs:51:6
9675
|
9776
LL | /// [S!]
98-
| ^^ help: to link to the struct, prefix with `struct@`: `struct@S`
99-
|
100-
= note: this link resolves to the struct `S`, which is not in the macro namespace
77+
| ^^
78+
| |
79+
| this link resolves to the struct `S`, which is not in the macro namespace
80+
| help: to link to the struct, prefix with `struct@`: `struct@S`
10181

10282
error: unresolved link to `T::g`
10383
--> $DIR/intra-link-errors.rs:69:6
10484
|
10585
LL | /// [type@T::g]
106-
| ^^^^^^^^^ help: to link to the associated function, add parentheses: `T::g()`
107-
|
108-
= note: this link resolves to the associated function `g`, which is not in the type namespace
86+
| ^^^^^^^^^
87+
| |
88+
| this link resolves to the associated function `g`, which is not in the type namespace
89+
| help: to link to the associated function, add parentheses: `T::g()`
10990

11091
error: unresolved link to `T::h`
11192
--> $DIR/intra-link-errors.rs:74:6
11293
|
11394
LL | /// [T::h!]
114-
| ^^^^^
115-
|
116-
= note: the trait `T` has no macro named `h`
95+
| ^^^^^ the trait `T` has no macro named `h`
11796

11897
error: unresolved link to `S::h`
11998
--> $DIR/intra-link-errors.rs:61:6
12099
|
121100
LL | /// [type@S::h]
122-
| ^^^^^^^^^ help: to link to the associated function, add parentheses: `S::h()`
123-
|
124-
= note: this link resolves to the associated function `h`, which is not in the type namespace
101+
| ^^^^^^^^^
102+
| |
103+
| this link resolves to the associated function `h`, which is not in the type namespace
104+
| help: to link to the associated function, add parentheses: `S::h()`
125105

126106
error: unresolved link to `m`
127107
--> $DIR/intra-link-errors.rs:81:6
128108
|
129109
LL | /// [m()]
130-
| ^^^ help: to link to the macro, add an exclamation mark: `m!`
131-
|
132-
= note: this link resolves to the macro `m`, which is not in the value namespace
110+
| ^^^
111+
| |
112+
| this link resolves to the macro `m`, which is not in the value namespace
113+
| help: to link to the macro, add an exclamation mark: `m!`
133114

134115
error: aborting due to 16 previous errors
135116

src/test/rustdoc-ui/intra-link-span-ice-55723.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ error: unresolved link to `i`
22
--> $DIR/intra-link-span-ice-55723.rs:9:10
33
|
44
LL | /// (arr[i])
5-
| ^
5+
| ^ no item named `i` in `intra_link_span_ice_55723`
66
|
77
note: the lint level is defined here
88
--> $DIR/intra-link-span-ice-55723.rs:1:9
99
|
1010
LL | #![deny(broken_intra_doc_links)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^
12-
= note: no item named `i` is in scope
1312
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1413

1514
error: aborting due to previous error

src/test/rustdoc-ui/intra-links-warning-crlf.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ warning: unresolved link to `error`
22
--> $DIR/intra-links-warning-crlf.rs:7:6
33
|
44
LL | /// [error]
5-
| ^^^^^ no item named `error` is in scope
5+
| ^^^^^ no item named `error` in `intra_links_warning_crlf`
66
|
77
= note: `#[warn(broken_intra_doc_links)]` on by default
88
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
@@ -11,23 +11,23 @@ warning: unresolved link to `error1`
1111
--> $DIR/intra-links-warning-crlf.rs:12:11
1212
|
1313
LL | /// docs [error1]
14-
| ^^^^^^ no item named `error1` is in scope
14+
| ^^^^^^ no item named `error1` in `intra_links_warning_crlf`
1515
|
1616
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1717

1818
warning: unresolved link to `error2`
1919
--> $DIR/intra-links-warning-crlf.rs:15:11
2020
|
2121
LL | /// docs [error2]
22-
| ^^^^^^ no item named `error2` is in scope
22+
| ^^^^^^ no item named `error2` in `intra_links_warning_crlf`
2323
|
2424
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
2525

2626
warning: unresolved link to `error`
2727
--> $DIR/intra-links-warning-crlf.rs:23:20
2828
|
2929
LL | * It also has an [error].
30-
| ^^^^^ no item named `error` is in scope
30+
| ^^^^^ no item named `error` in `intra_links_warning_crlf`
3131
|
3232
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
3333

0 commit comments

Comments
 (0)