Make functional record update/struct update syntax works inside closures when feature capture_disjoint_fields is enabled
This commit is contained in:
parent
180fdffa17
commit
e94cf57c3e
4 changed files with 51 additions and 5 deletions
|
|
@ -0,0 +1,30 @@
|
|||
// run-pass
|
||||
|
||||
// Test that functional record update/struct update syntax works inside
|
||||
// a closure when the feature `capture_disjoint_fields` is enabled.
|
||||
|
||||
#![feature(capture_disjoint_fields)]
|
||||
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
|
||||
//~| NOTE: `#[warn(incomplete_features)]` on by default
|
||||
//~| NOTE: see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
|
||||
|
||||
struct S {
|
||||
a: String,
|
||||
b: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = String::new();
|
||||
let b = String::new();
|
||||
let s = S {a, b};
|
||||
|
||||
let c = || {
|
||||
let s2 = S {
|
||||
a: format!("New a"),
|
||||
..s
|
||||
};
|
||||
println!("{} {}", s2.a, s2.b);
|
||||
};
|
||||
|
||||
c();
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/fru_syntax.rs:6:12
|
||||
|
|
||||
LL | #![feature(capture_disjoint_fields)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue