diff options
| author | bors <bors@rust-lang.org> | 2025-08-10 23:47:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-08-10 23:47:25 +0000 |
| commit | 21a19c297d4f5a03501d92ca251bd7a17073c08a (patch) | |
| tree | 93ca4123ac144c6d8d5fc796bfa2251ffb95db27 /compiler/rustc_resolve/src/errors.rs | |
| parent | c8ca44c98eade864824a3c0a15fbdc1edb7f9dd4 (diff) | |
| parent | 29d26f27a6d6c466ed143bdfa128f76a19226743 (diff) | |
| download | rust-21a19c297d4f5a03501d92ca251bd7a17073c08a.tar.gz rust-21a19c297d4f5a03501d92ca251bd7a17073c08a.zip | |
Auto merge of #135846 - estebank:non-exhaustive-dfv-ctor-2, r=BoxyUwU
Detect struct construction with private field in field with default
When trying to construct a struct that has a public field of a private type, suggest using `..` if that field has a default value.
```
error[E0603]: struct `Priv1` is private
--> $DIR/non-exhaustive-ctor-2.rs:19:39
|
LL | let _ = S { field: (), field1: m::Priv1 {} };
| ------ ^^^^^ private struct
| |
| while setting this field
|
note: the struct `Priv1` is defined here
--> $DIR/non-exhaustive-ctor-2.rs:14:4
|
LL | struct Priv1 {}
| ^^^^^^^^^^^^
help: the type `Priv1` of field `field1` is private, but you can construct the default value defined for it in `S` using `..` in the struct initializer expression
|
LL | let _ = S { field: (), .. };
| ~~
```
Diffstat (limited to 'compiler/rustc_resolve/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
