diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-11-26 17:53:00 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-12-09 21:55:12 +0000 |
| commit | 550bcae8aa7859abace52c20b8b9149ae6cb37f1 (patch) | |
| tree | 0ac51fba8bb64e7dcfedc78876c01df1a8f574e7 /tests/ui/structs | |
| parent | 9ac95c10c09faf50cc22eb97b6e1c59d64053c28 (diff) | |
| download | rust-550bcae8aa7859abace52c20b8b9149ae6cb37f1.tar.gz rust-550bcae8aa7859abace52c20b8b9149ae6cb37f1.zip | |
Detect `struct S(ty = val);`
Emit a specific error for unsupported default field value syntax in tuple structs.
Diffstat (limited to 'tests/ui/structs')
| -rw-r--r-- | tests/ui/structs/default-field-values-failures.rs | 2 | ||||
| -rw-r--r-- | tests/ui/structs/default-field-values-failures.stderr | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/tests/ui/structs/default-field-values-failures.rs b/tests/ui/structs/default-field-values-failures.rs index c4de4f5cdad..27eff70dd3e 100644 --- a/tests/ui/structs/default-field-values-failures.rs +++ b/tests/ui/structs/default-field-values-failures.rs @@ -23,6 +23,8 @@ pub struct Qux<const C: i32> { bay: i32 = C, } +pub struct Rak(i32 = 42); //~ ERROR default field in tuple struct + impl<const C: i32> Qux<C> { const S: S = S; } diff --git a/tests/ui/structs/default-field-values-failures.stderr b/tests/ui/structs/default-field-values-failures.stderr index bd96777f865..3564c1dc20e 100644 --- a/tests/ui/structs/default-field-values-failures.stderr +++ b/tests/ui/structs/default-field-values-failures.stderr @@ -7,6 +7,12 @@ LL | bat: i32 = <Qux<{ C }> as T>::K, = help: const parameters may only be used as standalone arguments, i.e. `C` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions +error: default field in tuple struct + --> $DIR/default-field-values-failures.rs:26:22 + | +LL | pub struct Rak(i32 = 42); + | ^^ default fields are only supported on structs + error[E0277]: the trait bound `S: Default` is not satisfied --> $DIR/default-field-values-failures.rs:14:5 | @@ -24,7 +30,7 @@ LL | pub struct S; | error: missing mandatory field `bar` - --> $DIR/default-field-values-failures.rs:45:21 + --> $DIR/default-field-values-failures.rs:47:21 | LL | let _ = Bar { .. }; | ^ @@ -35,6 +41,6 @@ error: generic `Self` types are currently not permitted in anonymous constants LL | bar: S = Self::S, | ^^^^ -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. |
