As @matklad mentioned in ERA08, rust-analyzer should not suggest to fill struct fields if they are inaccessible.
Example:
use std::rc::Rc;
struct Struct {
field: String
}
type Data = Rc<Struct>;
fn main() {
let data = Data {};
}
It fails to compile with the following error:
error: cannot construct `Rc<Struct>` with struct literal syntax due to inaccessible fields
--> src/main.rs:10:16
|
10 | let data = Data {};
|
Currently rust-analyzer offers to fill the fields, which results in following code:
let data = Data { ptr: todo!(), phantom: todo!() };
Of course it fails to compile:
error[E0451]: field `ptr` of struct `Rc` is private
--> src/main.rs:10:23
|
10 | let data = Data { ptr: todo!(), phantom: todo!() };
| ^^^^^^^^^^^^ private field
error[E0451]: field `phantom` of struct `Rc` is private
--> src/main.rs:10:37
|
10 | let data = Data { ptr: todo!(), phantom: todo!() };
|
I'd like to fix this issue :)
As @matklad mentioned in ERA08, rust-analyzer should not suggest to fill struct fields if they are inaccessible.
Example:
It fails to compile with the following error:
Currently rust-analyzer offers to fill the fields, which results in following code:
Of course it fails to compile:
I'd like to fix this issue :)