Add feature trigger and correct is_struct check

This commit is contained in:
SparrowLii 2021-10-29 20:08:30 +08:00
parent f3679bc23e
commit 1ab2616b4d
5 changed files with 129 additions and 81 deletions

View file

@ -17,10 +17,11 @@ fn update_to_state2() {
common_field1: "hello",
common_field2: 2,
};
// FIXME: this should trigger feature gate
let m2: Machine<State2> = Machine {
state: State2,
..m1 //~ ERROR mismatched types
..m1
//~^ ERROR type changing struct updating is experimental [E0658]
//~| ERROR mismatched types [E0308]
};
assert_eq!(State2, m2.state);
}

View file

@ -1,5 +1,14 @@
error[E0658]: type changing struct updating is experimental
--> $DIR/feature-gate.rs:22:11
|
LL | ..m1
| ^^
|
= note: see issue #86555 <https://github.com/rust-lang/rust/issues/86555> for more information
= help: add `#![feature(type_changing_struct_update)]` to the crate attributes to enable
error[E0308]: mismatched types
--> $DIR/feature-gate.rs:23:11
--> $DIR/feature-gate.rs:22:11
|
LL | ..m1
| ^^ expected struct `State2`, found struct `State1`
@ -7,6 +16,7 @@ LL | ..m1
= note: expected struct `Machine<State2>`
found struct `Machine<State1>`
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.

View file

@ -50,7 +50,6 @@ fn fail_update() {
let m3 = Machine::<i32, i32> {
..m1
//~^ ERROR mismatched types [E0308]
//~| ERROR mismatched types [E0308]
};
}

View file

@ -16,15 +16,6 @@ LL | ..m1
= note: expected type `i32`
found type `f64`
error[E0308]: mismatched types
--> $DIR/type-generic-update.rs:51:11
|
LL | ..m1
| ^^ field type mismatch: Machine.message
|
= note: expected type `i32`
found type `f64`
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.