diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-23 05:28:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-23 05:28:22 +0200 |
| commit | 736e8ebd1ca703c7de40806a727559bef836d3f7 (patch) | |
| tree | 71d6b1ed91a078049dd1282e7ba854f01f1a144b /src | |
| parent | 0f81c7faf5f657704b2e29154af3c09aca7afd67 (diff) | |
| parent | 7d7ebf88057ad6e16331e02a86c5951ecd1f23db (diff) | |
Rollup merge of #89730 - crlf0710:type_changing_feature, r=jackh726
add feature flag for `type_changing_struct_update` This implements the PR0 part of the mentoring notes within #86618. overrides the previous inactive #86646 pr. r? ```@nikomatsakis```
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-type_changing_struct_update.rs | 26 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-type_changing_struct_update.stderr | 12 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/feature-gates/feature-gate-type_changing_struct_update.rs b/src/test/ui/feature-gates/feature-gate-type_changing_struct_update.rs new file mode 100644 index 00000000000..520c1478f32 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-type_changing_struct_update.rs @@ -0,0 +1,26 @@ +#[derive(Debug)] +struct Machine<S> { + state: S, + common_field1: &'static str, + common_field2: i32, +} +#[derive(Debug)] +struct State1; +#[derive(Debug, PartialEq)] +struct State2; + +fn update_to_state2() { + let m1: Machine<State1> = Machine { + state: State1, + common_field1: "hello", + common_field2: 2, + }; + let m2: Machine<State2> = Machine { + state: State2, + ..m1 //~ ERROR mismatched types + }; + // FIXME: this should trigger feature gate + assert_eq!(State2, m2.state); +} + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-type_changing_struct_update.stderr b/src/test/ui/feature-gates/feature-gate-type_changing_struct_update.stderr new file mode 100644 index 00000000000..9934fe68164 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-type_changing_struct_update.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/feature-gate-type_changing_struct_update.rs:20:11 + | +LL | ..m1 + | ^^ expected struct `State2`, found struct `State1` + | + = note: expected struct `Machine<State2>` + found struct `Machine<State1>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
