Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature flag for type_changing_struct_update #89730

Merged
merged 1 commit into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,10 @@ declare_features! (
/// Allows using the `non_exhaustive_omitted_patterns` lint.
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),

/// Allows creation of instances of a struct by moving fields that have
/// not changed from prior instances of the same struct (RFC #2528)
(incomplete, type_changing_struct_update, "1.58.0", Some(86555), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ symbols! {
type_alias_enum_variants,
type_alias_impl_trait,
type_ascription,
type_changing_struct_update,
type_id,
type_length_limit,
type_macros,
Expand Down
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() {}
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`.