Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
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'.
  • Loading branch information
ClementTsang committed Jul 6, 2022
commit 503c66992737d81e64b38a123ad9ac00dd88cf38
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2589,8 +2589,10 @@ fn show_candidates(
} else {
"item".to_string()
};
let plural_descr =
if descr.ends_with("s") { format!("{}es", descr) } else { format!("{}s", descr) };

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

let mut spans = Vec::new();
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/imports/inaccessible_type_aliases.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod a {
type Foo = u64;
type Bar = u64;
}

mod b {
type Foo = u64;
}

fn main() {
let x: Foo = 100; //~ ERROR: cannot find type `Foo` in this scope
let y: Bar = 100; //~ ERROR: cannot find type `Bar` in this scope
println!("x: {}, y: {}", x, y);
}
30 changes: 30 additions & 0 deletions src/test/ui/imports/inaccessible_type_aliases.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
error[E0412]: cannot find type `Foo` in this scope
--> $DIR/inaccessible_type_aliases.rs:11:12
|
LL | let x: Foo = 100;
| ^^^ not found in this scope
|
note: these type aliases exist but are inaccessible
--> $DIR/inaccessible_type_aliases.rs:2:5
|
LL | type Foo = u64;
| ^^^^^^^^^^^^^^^ `a::Foo`: not accessible
...
LL | type Foo = u64;
| ^^^^^^^^^^^^^^^ `b::Foo`: not accessible

error[E0412]: cannot find type `Bar` in this scope
--> $DIR/inaccessible_type_aliases.rs:12:12
|
LL | let y: Bar = 100;
| ^^^ not found in this scope
|
note: type alias `a::Bar` exists but is inaccessible
--> $DIR/inaccessible_type_aliases.rs:3:5
|
LL | type Bar = u64;
| ^^^^^^^^^^^^^^^ not accessible

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.