Closed
Description
Given the following code: Playground link
fn main() {
let s = string::new();
let s = Str::new();
}
The current output is:
error[E0433]: failed to resolve: use of undeclared crate or module `string`
--> src/main.rs:2:13
|
2 | let s = string::new();
| ^^^^^^ use of undeclared crate or module `string`
error[E0433]: failed to resolve: use of undeclared type `Str`
--> src/main.rs:3:13
|
3 | let s = Str::new();
| ^^^ use of undeclared type `Str`
Some errors have detailed explanations: E0433.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `sandbox` due to 2 previous errors
Ideally the output should look like:
error[E0433]: failed to resolve: use of undeclared crate or module `string`
--> src/main.rs:2:13
|
2 | let s = string::new();
| ^^^^^^ use of undeclared crate or module `string`
|
help: there is a type with a similar name (notice the capitalization)
|
2 | let s = String::new();
| ~~~~~~
help: there is a type with a similar name
|
3 | let s = str::new();
| ~~~
error[E0433]: failed to resolve: use of undeclared type `Str`
--> src/main.rs:3:13
|
3 | let s = Str::new();
| ^^^ use of undeclared type `Str`
help: there is a type with a similar name (notice the capitalization)
|
3 | let s = str::new();
| ~~~
help: there is a type with a similar name
|
2 | let s = String::new();
| ~~~~~~
Some errors have detailed explanations: E0433.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `sandbox` due to 2 previous errors
Currently, when a crate, function, method, or enum variant is not found, similar-named items will be shown as hints. However, when a type, module, or macro is misspelled, the same kind of hints are not shown. I particularly think mistakes involving capitalisation should be considered. This issue came about with a friend I was introducing to rust, and I was hoping the compiler would suggest correcting string
to String
.