rust/tests/ui/closures/2229_closure_analysis/wild_patterns.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.3 KiB
Rust
Raw Normal View History

2021-06-27 01:22:46 -05:00
// edition:2021
2020-11-05 14:16:24 -06:00
#![feature(rustc_attrs)]
// Test to ensure that we can handle cases where
2021-12-26 18:20:38 -06:00
// let statements create no bindings are initialized
2020-11-05 14:16:24 -06:00
// using a Place expression
//
// Note: Currently when feature `capture_disjoint_fields` is enabled
2020-11-13 00:51:19 -06:00
// we can't handle such cases. So the test current use `_x` instead of
// `_` until the issue is resolved.
// Check rust-lang/project-rfc-2229#24 for status.
2020-11-05 14:16:24 -06:00
struct Point {
x: i32,
y: i32,
}
fn wild_struct() {
let p = Point { x: 10, y: 20 };
let c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
2020-11-13 00:51:19 -06:00
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
2024-01-10 00:39:02 -06:00
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020-11-05 14:16:24 -06:00
|| {
2020-11-13 00:51:19 -06:00
//~^ ERROR: First Pass analysis includes:
//~| ERROR: Min Capture analysis includes:
2020-11-05 14:16:24 -06:00
// FIXME(arora-aman): Change `_x` to `_`
let Point { x: _x, y: _ } = p;
2020-11-13 00:51:19 -06:00
//~^ NOTE: Capturing p[(0, 0)] -> ImmBorrow
//~| NOTE: Min Capture p[(0, 0)] -> ImmBorrow
2020-11-05 14:16:24 -06:00
};
c();
}
fn wild_tuple() {
let t = (String::new(), 10);
let c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
2020-11-13 00:51:19 -06:00
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
2024-01-10 00:39:02 -06:00
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020-11-05 14:16:24 -06:00
|| {
2020-11-13 00:51:19 -06:00
//~^ ERROR: First Pass analysis includes:
//~| ERROR: Min Capture analysis includes:
2020-11-05 14:16:24 -06:00
// FIXME(arora-aman): Change `_x` to `_`
let (_x, _) = t;
2020-11-13 00:51:19 -06:00
//~^ NOTE: Capturing t[(0, 0)] -> ByValue
//~| NOTE: Min Capture t[(0, 0)] -> ByValue
2020-11-05 14:16:24 -06:00
};
c();
}
fn wild_arr() {
let arr = [String::new(), String::new()];
let c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
2020-11-13 00:51:19 -06:00
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
2024-01-10 00:39:02 -06:00
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020-11-05 14:16:24 -06:00
|| {
2020-11-13 00:51:19 -06:00
//~^ ERROR: First Pass analysis includes:
//~| ERROR: Min Capture analysis includes:
2020-11-05 14:16:24 -06:00
// FIXME(arora-aman): Change `_x` to `_`
let [_x, _] = arr;
2020-11-13 00:51:19 -06:00
//~^ NOTE: Capturing arr[Index] -> ByValue
//~| NOTE: Min Capture arr[] -> ByValue
2020-11-05 14:16:24 -06:00
};
c();
}
fn main() {}