]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/infallible_destructuring_match.rs
Addition `manual_map` test for `unsafe` blocks
[rust.git] / tests / ui / infallible_destructuring_match.rs
index 37ae19497d18cc6577b5bc5396beb6678d238140..106cd438b90e79e1b0dd28c41c8b0bf3cc1e576d 100644 (file)
@@ -1,13 +1,6 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
+// run-rustfix
 #![feature(exhaustive_patterns, never_type)]
+#![allow(dead_code, unreachable_code, unused_variables)]
 #![allow(clippy::let_and_return)]
 
 enum SingleVariantEnum {
@@ -18,6 +11,14 @@ enum SingleVariantEnum {
 
 enum EmptyEnum {}
 
+macro_rules! match_enum {
+    ($param:expr) => {
+        let data = match $param {
+            SingleVariantEnum::Variant(i) => i,
+        };
+    };
+}
+
 fn infallible_destructuring_match_enum() {
     let wrapper = SingleVariantEnum::Variant(0);
 
@@ -26,6 +27,9 @@ fn infallible_destructuring_match_enum() {
         SingleVariantEnum::Variant(i) => i,
     };
 
+    // This shouldn't (inside macro)
+    match_enum!(wrapper);
+
     // This shouldn't!
     let data = match wrapper {
         SingleVariantEnum::Variant(_) => -1,
@@ -39,6 +43,14 @@ fn infallible_destructuring_match_enum() {
     let SingleVariantEnum::Variant(data) = wrapper;
 }
 
+macro_rules! match_struct {
+    ($param:expr) => {
+        let data = match $param {
+            TupleStruct(i) => i,
+        };
+    };
+}
+
 fn infallible_destructuring_match_struct() {
     let wrapper = TupleStruct(0);
 
@@ -47,6 +59,9 @@ fn infallible_destructuring_match_struct() {
         TupleStruct(i) => i,
     };
 
+    // This shouldn't (inside macro)
+    match_struct!(wrapper);
+
     // This shouldn't!
     let data = match wrapper {
         TupleStruct(_) => -1,
@@ -60,6 +75,14 @@ fn infallible_destructuring_match_struct() {
     let TupleStruct(data) = wrapper;
 }
 
+macro_rules! match_never_enum {
+    ($param:expr) => {
+        let data = match $param {
+            Ok(i) => i,
+        };
+    };
+}
+
 fn never_enum() {
     let wrapper: Result<i32, !> = Ok(23);
 
@@ -68,6 +91,9 @@ fn never_enum() {
         Ok(i) => i,
     };
 
+    // This shouldn't (inside macro)
+    match_never_enum!(wrapper);
+
     // This shouldn't!
     let data = match wrapper {
         Ok(_) => -1,