Skip to content

Commit 503c669

Browse files
committed
fix typo in note about multiple inaccessible type aliases
Mainly intended as a small typo fix ("aliass" -> "aliases") for the case where a type cannot be found in scope, and there are multiple inaccessible type aliases that match the missing type. In general this change would use the correct plural form in this scenario for words that end with 's'.
1 parent 7b46aa5 commit 503c669

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2589,8 +2589,10 @@ fn show_candidates(
25892589
} else {
25902590
"item".to_string()
25912591
};
2592+
let plural_descr =
2593+
if descr.ends_with("s") { format!("{}es", descr) } else { format!("{}s", descr) };
25922594

2593-
let mut msg = format!("{}these {}s exist but are inaccessible", prefix, descr);
2595+
let mut msg = format!("{}these {} exist but are inaccessible", prefix, plural_descr);
25942596
let mut has_colon = false;
25952597

25962598
let mut spans = Vec::new();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
mod a {
2+
type Foo = u64;
3+
type Bar = u64;
4+
}
5+
6+
mod b {
7+
type Foo = u64;
8+
}
9+
10+
fn main() {
11+
let x: Foo = 100; //~ ERROR: cannot find type `Foo` in this scope
12+
let y: Bar = 100; //~ ERROR: cannot find type `Bar` in this scope
13+
println!("x: {}, y: {}", x, y);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0412]: cannot find type `Foo` in this scope
2+
--> $DIR/inaccessible_type_aliases.rs:11:12
3+
|
4+
LL | let x: Foo = 100;
5+
| ^^^ not found in this scope
6+
|
7+
note: these type aliases exist but are inaccessible
8+
--> $DIR/inaccessible_type_aliases.rs:2:5
9+
|
10+
LL | type Foo = u64;
11+
| ^^^^^^^^^^^^^^^ `a::Foo`: not accessible
12+
...
13+
LL | type Foo = u64;
14+
| ^^^^^^^^^^^^^^^ `b::Foo`: not accessible
15+
16+
error[E0412]: cannot find type `Bar` in this scope
17+
--> $DIR/inaccessible_type_aliases.rs:12:12
18+
|
19+
LL | let y: Bar = 100;
20+
| ^^^ not found in this scope
21+
|
22+
note: type alias `a::Bar` exists but is inaccessible
23+
--> $DIR/inaccessible_type_aliases.rs:3:5
24+
|
25+
LL | type Bar = u64;
26+
| ^^^^^^^^^^^^^^^ not accessible
27+
28+
error: aborting due to 2 previous errors
29+
30+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)