diff options
| author | Roxane <roxane.fruytier@hotmail.com> | 2021-09-26 14:48:56 -0400 |
|---|---|---|
| committer | Roxane <roxane.fruytier@hotmail.com> | 2021-09-26 15:52:02 -0400 |
| commit | 87010206adc0123277d7e355893e83551a28814f (patch) | |
| tree | 6586cfcc521edab4a22995ece59b1f1b6ed67845 /src | |
| parent | ac8dd1b2f24dc62c962172b27433106b4e84dc62 (diff) | |
| download | rust-87010206adc0123277d7e355893e83551a28814f.tar.gz rust-87010206adc0123277d7e355893e83551a28814f.zip | |
2229: Consume IfLet expr
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/closures/2229_closure_analysis/issue-88118-2.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/closures/2229_closure_analysis/issue-88118-2.stderr | 19 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/issue-88118-2.rs b/src/test/ui/closures/2229_closure_analysis/issue-88118-2.rs new file mode 100644 index 00000000000..a4cbbc1d25a --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/issue-88118-2.rs @@ -0,0 +1,21 @@ +// edition:2021 +#![feature(if_let_guard)] + +fn print_error_count(registry: &Registry) { + |x: &Registry| { + match &x { + Registry if let _ = registry.try_find_description() => { } + //~^ WARNING: irrefutable `if let` guard pattern + _ => {} + } + }; +} + +struct Registry; +impl Registry { + pub fn try_find_description(&self) { + unimplemented!() + } +} + +fn main() {} diff --git a/src/test/ui/closures/2229_closure_analysis/issue-88118-2.stderr b/src/test/ui/closures/2229_closure_analysis/issue-88118-2.stderr new file mode 100644 index 00000000000..d51f3f0eb7b --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/issue-88118-2.stderr @@ -0,0 +1,19 @@ +warning: irrefutable `if let` guard pattern + --> $DIR/issue-88118-2.rs:7:29 + | +LL | Registry if let _ = registry.try_find_description() => { } + | ^ + | + = note: `#[warn(irrefutable_let_patterns)]` on by default + = note: this pattern will always match, so the guard is useless + = help: consider removing the guard and adding a `let` inside the match arm + +error[E0507]: cannot move out of `*registry` which is behind a shared reference + --> $DIR/issue-88118-2.rs:7:33 + | +LL | Registry if let _ = registry.try_find_description() => { } + | ^^^^^^^^ move occurs because `*registry` has type `Registry`, which does not implement the `Copy` trait + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0507`. |
