Code
use clap::Parser;
fn wrong_type() -> Option<String> {
return true;
}
Current output
error[E0308]: mismatched types
--> src/lib.rs:4:12
|
3 | fn wrong_type() -> Option<String> {
| -------------- expected `Option<std::string::String>` because of return type
4 | return true;
| ^^^^ expected `Option<String>`, found `bool`
|
= note: expected enum `Option<std::string::String>`
found type `bool`
Desired output
error[E0308]: mismatched types
--> src/lib.rs:4:12
|
3 | fn wrong_type() -> Option<String> {
| -------------- expected `Option<String>` because of return type
4 | return true;
| ^^^^ expected `Option<String>`, found `bool`
|
= note: expected enum `Option<String>`
found type `bool`
Rationale and extra context
Adding imports, even though they don't introduce another String type in the current file, is making rustc print fully qualified type names.
Clap doesn't define any types called String, although it does have a variant named String elsewhere in the library: https://docs.rs/clap/latest/clap/error/enum.ContextValue.html#variant.String
Other cases
There's a similar issue with serde and option:
use serde::Deserialize;
fn wrong_type() -> Option<String> {
return true;
}
rustc output:
error[E0308]: mismatched types
--> src/lib.rs:4:12
|
3 | fn wrong_type() -> Option<String> {
| -------------- expected `std::option::Option<std::string::String>` because of return type
4 | return true;
| ^^^^ expected `Option<String>`, found `bool`
|
= note: expected enum `std::option::Option<std::string::String>`
found type `bool`
Anything else?
Playground links:
Code
Current output
Desired output
Rationale and extra context
Adding imports, even though they don't introduce another
Stringtype in the current file, is making rustc print fully qualified type names.Clap doesn't define any types called
String, although it does have a variant namedStringelsewhere in the library: https://docs.rs/clap/latest/clap/error/enum.ContextValue.html#variant.StringOther cases
There's a similar issue with serde and option:
rustc output:
Anything else?
Playground links: