forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#89730 - crlf0710:type_changing_feature, r=j…
…ackh726 add feature flag for `type_changing_struct_update` This implements the PR0 part of the mentoring notes within rust-lang#86618. overrides the previous inactive rust-lang#86646 pr. r? ```@nikomatsakis```
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/ui/feature-gates/feature-gate-type_changing_struct_update.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/feature-gates/feature-gate-type_changing_struct_update.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |