-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
deeb025
commit d0fac05
Showing
2 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/test/ui/closures/2229_closure_analysis/capture-enums.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,56 @@ | ||
#![feature(capture_disjoint_fields)] | ||
//~^ WARNING the feature `capture_disjoint_fields` is incomplete | ||
#![feature(rustc_attrs)] | ||
|
||
enum Info { | ||
Point(i32, i32, String), | ||
Meta(String, Vec<(i32, i32)>) | ||
} | ||
|
||
fn multi_variant_enum() { | ||
let point = Info::Point(10, -10, "1".into()); | ||
|
||
let vec = Vec::new(); | ||
let meta = Info::Meta("meta".into(), vec); | ||
|
||
let c = #[rustc_capture_analysis] | ||
//~^ ERROR: attributes on expressions are experimental | ||
|| { | ||
if let Info::Point(_, _, str) = point { | ||
//~^ Capturing point[] -> ImmBorrow | ||
//~| Capturing point[(2, 0)] -> ByValue | ||
//~| Min Capture point[] -> ByValue | ||
println!("{}", str); | ||
} | ||
|
||
if let Info::Meta(_, v) = meta { | ||
//~^ Capturing meta[] -> ImmBorrow | ||
//~| Capturing meta[(1, 1)] -> ByValue | ||
//~| Min Capture meta[] -> ByValue | ||
println!("{:?}", v); | ||
} | ||
}; | ||
|
||
c(); | ||
} | ||
|
||
enum SingleVariant { | ||
Point(i32, i32, String), | ||
} | ||
|
||
fn single_variant_enum() { | ||
let point = SingleVariant::Point(10, -10, "1".into()); | ||
|
||
let c = #[rustc_capture_analysis] | ||
//~^ ERROR: attributes on expressions are experimental | ||
|| { | ||
let SingleVariant::Point(_, _, str) = point; | ||
//~^ Capturing point[(2, 0)] -> ByValue | ||
//~| Min Capture point[(2, 0)] -> ByValue | ||
println!("{}", str); | ||
}; | ||
|
||
c(); | ||
} | ||
|
||
fn main() {} |
78 changes: 78 additions & 0 deletions
78
src/test/ui/closures/2229_closure_analysis/capture-enums.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,78 @@ | ||
error[E0658]: attributes on expressions are experimental | ||
--> $DIR/capture-enums.rs:16:13 | ||
| | ||
LL | let c = #[rustc_capture_analysis] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information | ||
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable | ||
|
||
error[E0658]: attributes on expressions are experimental | ||
--> $DIR/capture-enums.rs:44:13 | ||
| | ||
LL | let c = #[rustc_capture_analysis] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information | ||
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable | ||
|
||
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/capture-enums.rs:1: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 | ||
|
||
error: Capturing point[] -> ImmBorrow | ||
--> $DIR/capture-enums.rs:19:41 | ||
| | ||
LL | if let Info::Point(_, _, str) = point { | ||
| ^^^^^ | ||
|
||
error: Capturing point[(2, 0)] -> ByValue | ||
--> $DIR/capture-enums.rs:19:41 | ||
| | ||
LL | if let Info::Point(_, _, str) = point { | ||
| ^^^^^ | ||
|
||
error: Capturing meta[] -> ImmBorrow | ||
--> $DIR/capture-enums.rs:26:35 | ||
| | ||
LL | if let Info::Meta(_, v) = meta { | ||
| ^^^^ | ||
|
||
error: Capturing meta[(1, 1)] -> ByValue | ||
--> $DIR/capture-enums.rs:26:35 | ||
| | ||
LL | if let Info::Meta(_, v) = meta { | ||
| ^^^^ | ||
|
||
error: Min Capture point[] -> ByValue | ||
--> $DIR/capture-enums.rs:19:41 | ||
| | ||
LL | if let Info::Point(_, _, str) = point { | ||
| ^^^^^ | ||
|
||
error: Min Capture meta[] -> ByValue | ||
--> $DIR/capture-enums.rs:26:35 | ||
| | ||
LL | if let Info::Meta(_, v) = meta { | ||
| ^^^^ | ||
|
||
error: Capturing point[(2, 0)] -> ByValue | ||
--> $DIR/capture-enums.rs:47:43 | ||
| | ||
LL | let SingleVariant::Point(_, _, str) = point; | ||
| ^^^^^ | ||
|
||
error: Min Capture point[(2, 0)] -> ByValue | ||
--> $DIR/capture-enums.rs:47:43 | ||
| | ||
LL | let SingleVariant::Point(_, _, str) = point; | ||
| ^^^^^ | ||
|
||
error: aborting due to 10 previous errors; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0658`. |