diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-08-13 18:43:46 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-08-14 15:59:32 +0000 |
| commit | caadc8df3519f1c92ef59ea816eb628345d9f52a (patch) | |
| tree | 6766e7d1c0c3011c6eec9c88dcf223db18eb7381 /tests | |
| parent | 30017c36d6b5e3382ee7cf018d330a6a4a937d39 (diff) | |
| download | rust-caadc8df3519f1c92ef59ea816eb628345d9f52a.tar.gz rust-caadc8df3519f1c92ef59ea816eb628345d9f52a.zip | |
Do not ICE on private type in field of unresolved struct
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.rs | 8 | ||||
| -rw-r--r-- | tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.stderr | 22 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.rs b/tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.rs new file mode 100644 index 00000000000..4c5926a91ea --- /dev/null +++ b/tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.rs @@ -0,0 +1,8 @@ +// Regression test for https://github.com/rust-lang/rust/issues/145367 +mod m { + struct Priv2; +} +fn main() { + WithUse { one: m::Priv2 } //~ ERROR: cannot find struct, variant or union type `WithUse` in this scope + //~^ ERROR: unit struct `Priv2` is private +} diff --git a/tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.stderr b/tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.stderr new file mode 100644 index 00000000000..1f0c80092b7 --- /dev/null +++ b/tests/ui/structs/default-field-values/non-exhaustive-ctor-not-found.stderr @@ -0,0 +1,22 @@ +error[E0422]: cannot find struct, variant or union type `WithUse` in this scope + --> $DIR/non-exhaustive-ctor-not-found.rs:6:5 + | +LL | WithUse { one: m::Priv2 } + | ^^^^^^^ not found in this scope + +error[E0603]: unit struct `Priv2` is private + --> $DIR/non-exhaustive-ctor-not-found.rs:6:23 + | +LL | WithUse { one: m::Priv2 } + | ^^^^^ private unit struct + | +note: the unit struct `Priv2` is defined here + --> $DIR/non-exhaustive-ctor-not-found.rs:3:5 + | +LL | struct Priv2; + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0422, E0603. +For more information about an error, try `rustc --explain E0422`. |
