Open estebank opened 3 years ago
I'm gonna try to take a shot at this. @rustbot claim
Can I throw in this one?
mod inner {
pub struct BadStruct {
_field: (),
}
}
fn main() {
let _ = inner::BadStruct();
}
suggests the following, which won't work because the field is private:
help: use struct literal syntax instead: `inner::BadStruct { _field: val }`
@ben0x539 I would say that that is better covered by https://github.com/rust-lang/rust/issues/57951
mhm, stayed away from there because it talks about tuple structs and crates, but it's probably really the same thing :+1:
Sorry for the inactivity. I'm going to let someone else work on this for now, I think. @rustbot release-assignment
Current output:
error[E0423]: expected value, found struct `S`
--> src/lib.rs:8:5
|
1 | struct S {}
| ----------- `S` defined here
...
5 | struct T();
| ----------- similarly named tuple struct `T` defined here
...
8 | S
| ^
|
help: use struct literal syntax instead
|
8 | S {}
|
help: a tuple struct with a similar name exists
|
8 | T
|
help: consider importing this unit variant instead
|
1 + use unicode_bidi::BidiClass::S;
|
error[E0423]: expected value, found enum `E`
--> src/lib.rs:12:5
|
5 | struct T();
| ----------- similarly named tuple struct `T` defined here
...
12 | E
| ^
|
note: the enum is defined here
--> src/lib.rs:2:1
|
2 | / enum E {
3 | | V,
4 | | }
| |_^
help: you might have meant to use the following enum variant
|
12 | E::V
|
help: a tuple struct with a similar name exists
|
12 | T
|
help: consider importing one of these constants instead
|
1 + use std::f128::consts::E;
|
1 + use std::f16::consts::E;
|
1 + use std::f32::consts::E;
|
1 + use std::f64::consts::E;
|
error[E0308]: mismatched types
--> src/lib.rs:16:5
|
5 | struct T();
| -------- `T` defines a struct constructor here, which should be called
...
15 | fn baz() -> T {
| - expected `T` because of return type
16 | T
| ^ expected `T`, found struct constructor
|
= note: expected struct `T`
found struct constructor `fn() -> T {T}`
help: use parentheses to construct this tuple struct
|
16 | T()
| ++
Some errors have detailed explanations: E0308, E0423.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `playground` (lib) due to 3 previous errors
Given:
we currently emit
which is reasonable, particularly the suggestions, but it isn't entirely clear to a newcomer that
S
in TypeNS isn't the same asS
in ValueNS.Ideally, the output would look closer to: