1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #![feature(exhaustive_patterns, never_type)]
11 #![allow(clippy::let_and_return)]
13 enum SingleVariantEnum {
17 struct TupleStruct(i32);
21 fn infallible_destructuring_match_enum() {
22 let wrapper = SingleVariantEnum::Variant(0);
25 let data = match wrapper {
26 SingleVariantEnum::Variant(i) => i,
30 let data = match wrapper {
31 SingleVariantEnum::Variant(_) => -1,
34 // Neither should this!
35 let data = match wrapper {
36 SingleVariantEnum::Variant(i) => -1,
39 let SingleVariantEnum::Variant(data) = wrapper;
42 fn infallible_destructuring_match_struct() {
43 let wrapper = TupleStruct(0);
46 let data = match wrapper {
51 let data = match wrapper {
55 // Neither should this!
56 let data = match wrapper {
60 let TupleStruct(data) = wrapper;
64 let wrapper: Result<i32, !> = Ok(23);
67 let data = match wrapper {
72 let data = match wrapper {
76 // Neither should this!
77 let data = match wrapper {
81 let Ok(data) = wrapper;
85 fn match_on(&self) -> ! {
86 // The lint shouldn't pick this up, as `let` won't work here!
87 let data = match *self {};