-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
b86c5db
commit e39c3c0
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.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,16 @@ | ||
#![feature(capture_disjoint_fields)] | ||
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete | ||
//~| `#[warn(incomplete_features)]` on by default | ||
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488> | ||
|
||
// Test that array access is not stored as part of closure kind origin | ||
|
||
fn expect_fn<F: Fn()>(_f: F) {} | ||
|
||
fn main() { | ||
let s = [format!("s"), format!("s")]; | ||
let c = || { //~ ERROR expected a closure that implements the `Fn` | ||
let [_, _s] = s; | ||
}; | ||
expect_fn(c); | ||
} |
23 changes: 23 additions & 0 deletions
23
...est/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.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,23 @@ | ||
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/closure-origin-array-diagnostics.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[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` | ||
--> $DIR/closure-origin-array-diagnostics.rs:12:13 | ||
| | ||
LL | let c = || { | ||
| ^^ this closure implements `FnOnce`, not `Fn` | ||
LL | let [_, _s] = s; | ||
| - closure is `FnOnce` because it moves the variable `s` out of its environment | ||
LL | }; | ||
LL | expect_fn(c); | ||
| --------- the requirement to implement `Fn` derives from here | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0525`. |