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.
13 #![feature(exhaustive_patterns, never_type)]
14 #![allow(clippy::let_and_return)]
16 enum SingleVariantEnum {
20 struct TupleStruct(i32);
24 fn infallible_destructuring_match_enum() {
25 let wrapper = SingleVariantEnum::Variant(0);
28 let data = match wrapper {
29 SingleVariantEnum::Variant(i) => i,
33 let data = match wrapper {
34 SingleVariantEnum::Variant(_) => -1,
37 // Neither should this!
38 let data = match wrapper {
39 SingleVariantEnum::Variant(i) => -1,
42 let SingleVariantEnum::Variant(data) = wrapper;
45 fn infallible_destructuring_match_struct() {
46 let wrapper = TupleStruct(0);
49 let data = match wrapper {
54 let data = match wrapper {
58 // Neither should this!
59 let data = match wrapper {
63 let TupleStruct(data) = wrapper;
67 let wrapper: Result<i32, !> = Ok(23);
70 let data = match wrapper {
75 let data = match wrapper {
79 // Neither should this!
80 let data = match wrapper {
84 let Ok(data) = wrapper;
88 fn match_on(&self) -> ! {
89 // The lint shouldn't pick this up, as `let` won't work here!
90 let data = match *self {};