1
Fork 0

Update existing tests for or-patterns

This commit is contained in:
Matthew Jasper 2019-12-27 17:53:00 +00:00
parent a20969c489
commit 30058df867
28 changed files with 361 additions and 399 deletions

View file

@ -10,18 +10,18 @@ fn main() {
// ... // ...
// _3 = std::option::Option::<bool>::Some(const true,); // _3 = std::option::Option::<bool>::Some(const true,);
// _4 = discriminant(_3); // _4 = discriminant(_3);
// switchInt(move _4) -> [1isize: bb3, otherwise: bb2]; // switchInt(move _4) -> [1isize: bb2, otherwise: bb1];
// } // }
// bb1: { // bb1: {
// _2 = const 42i32;
// goto -> bb4;
// }
// bb2: {
// _2 = const 10i32; // _2 = const 10i32;
// goto -> bb4; // goto -> bb4;
// } // }
// bb2: {
// switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3];
// }
// bb3: { // bb3: {
// switchInt(((_3 as Some).0: bool)) -> [false: bb2, otherwise: bb1]; // _2 = const 42i32;
// goto -> bb4;
// } // }
// bb4: { // bb4: {
// _1 = Add(move _2, const 0i32); // _1 = Add(move _2, const 0i32);
@ -33,18 +33,18 @@ fn main() {
// ... // ...
// _3 = const Scalar(0x01) : std::option::Option<bool>; // _3 = const Scalar(0x01) : std::option::Option<bool>;
// _4 = const 1isize; // _4 = const 1isize;
// switchInt(const 1isize) -> [1isize: bb3, otherwise: bb2]; // switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1];
// } // }
// bb1: { // bb1: {
// _2 = const 42i32;
// goto -> bb4;
// }
// bb2: {
// _2 = const 10i32; // _2 = const 10i32;
// goto -> bb4; // goto -> bb4;
// } // }
// bb2: {
// switchInt(const true) -> [false: bb1, otherwise: bb3];
// }
// bb3: { // bb3: {
// switchInt(const true) -> [false: bb2, otherwise: bb1]; // _2 = const 42i32;
// goto -> bb4;
// } // }
// bb4: { // bb4: {
// _1 = Add(move _2, const 0i32); // _1 = Add(move _2, const 0i32);

View file

@ -32,41 +32,12 @@ fn main() {
// bb2: { // bb2: {
// StorageDead(_4); // StorageDead(_4);
// _5 = discriminant(_3); // _5 = discriminant(_3);
// switchInt(move _5) -> [0isize: bb10, 1isize: bb5, otherwise: bb4]; // switchInt(move _5) -> [0isize: bb4, 1isize: bb6, otherwise: bb5];
// } // }
// bb3 (cleanup): { // bb3 (cleanup): {
// drop(_2) -> bb1; // drop(_2) -> bb1;
// } // }
// bb4: { // bb4: {
// unreachable;
// }
// bb5: {
// StorageLive(_6);
// _6 = ((_3 as Err).0: std::option::NoneError);
// StorageLive(_8);
// StorageLive(_9);
// _9 = _6;
// _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb7, unwind: bb3];
// }
// bb6: {
// return;
// }
// bb7: {
// StorageDead(_9);
// _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb8, unwind: bb3];
// }
// bb8: {
// StorageDead(_8);
// StorageDead(_6);
// drop(_2) -> bb9;
// }
// bb9: {
// StorageDead(_2);
// StorageDead(_1);
// StorageDead(_3);
// goto -> bb6;
// }
// bb10: {
// StorageLive(_10); // StorageLive(_10);
// _10 = ((_3 as Ok).0: u32); // _10 = ((_3 as Ok).0: u32);
// (*_2) = _10; // (*_2) = _10;
@ -74,6 +45,35 @@ fn main() {
// _1 = move _2; // _1 = move _2;
// drop(_2) -> [return: bb12, unwind: bb11]; // drop(_2) -> [return: bb12, unwind: bb11];
// } // }
// bb5: {
// unreachable;
// }
// bb6: {
// StorageLive(_6);
// _6 = ((_3 as Err).0: std::option::NoneError);
// StorageLive(_8);
// StorageLive(_9);
// _9 = _6;
// _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb8, unwind: bb3];
// }
// bb7: {
// return;
// }
// bb8: {
// StorageDead(_9);
// _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb9, unwind: bb3];
// }
// bb9: {
// StorageDead(_8);
// StorageDead(_6);
// drop(_2) -> bb10;
// }
// bb10: {
// StorageDead(_2);
// StorageDead(_1);
// StorageDead(_3);
// goto -> bb7;
// }
// bb11 (cleanup): { // bb11 (cleanup): {
// drop(_1) -> bb1; // drop(_1) -> bb1;
// } // }
@ -85,7 +85,7 @@ fn main() {
// bb13: { // bb13: {
// StorageDead(_1); // StorageDead(_1);
// StorageDead(_3); // StorageDead(_3);
// goto -> bb6; // goto -> bb7;
// } // }
// } // }
// END rustc.test.ElaborateDrops.before.mir // END rustc.test.ElaborateDrops.before.mir

View file

@ -28,10 +28,7 @@ const CASES: &[(bool, bool, bool, i32)] = &[
fn main() { fn main() {
for &(cond, items_1, items_2, result) in CASES { for &(cond, items_1, items_2, result) in CASES {
assert_eq!( assert_eq!(complicated_match(cond, (items_1, items_2, String::new())), result,);
complicated_match(cond, (items_1, items_2, String::new())),
result,
);
} }
} }
@ -64,31 +61,38 @@ fn main() {
// } // }
// bb0: { // bb0: {
// FakeRead(ForMatchedPlace, _2); // FakeRead(ForMatchedPlace, _2);
// switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb5]; // switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3];
// } // }
// bb1 (cleanup): { // bb1 (cleanup): {
// resume; // resume;
// } // }
// bb2: { // bb2: { // pre-binding for arm 1 first pattern
// falseEdges -> [real: bb8, imaginary: bb3]; // falseEdges -> [real: bb9, imaginary: bb4];
// } // }
// bb3: { // bb3: {
// falseEdges -> [real: bb17, imaginary: bb4]; // switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5];
// } // }
// bb4: { // bb4: { // pre-binding for arm 1 second pattern
// falseEdges -> [real: bb25, imaginary: bb26]; // falseEdges -> [real: bb18, imaginary: bb6];
// } // }
// bb5: { // bb5: {
// switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb6]; // switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6];
// } // }
// bb6: { // bb6: { // pre-binding for arm 2 first pattern
// switchInt((_2.0: bool)) -> [false: bb26, otherwise: bb4]; // falseEdges -> [real: bb26, imaginary: bb7];
// } // }
// bb7: { // arm 1 // bb7: { // bindings for arm 2 - second pattern
// StorageLive(_15);
// _15 = (_2.1: bool);
// StorageLive(_16);
// _16 = move (_2.2: std::string::String);
// goto -> bb25;
// }
// bb8: { // arm 1
// _0 = const 1i32; // _0 = const 1i32;
// drop(_7) -> [return: bb23, unwind: bb13]; // drop(_7) -> [return: bb24, unwind: bb14];
// } // }
// bb8: { // guard - first time // bb9: { // guard - first time
// StorageLive(_6); // StorageLive(_6);
// _6 = &(_2.1: bool); // _6 = &(_2.1: bool);
// StorageLive(_8); // StorageLive(_8);
@ -99,34 +103,34 @@ fn main() {
// StorageLive(_10); // StorageLive(_10);
// _10 = _1; // _10 = _1;
// FakeRead(ForMatchedPlace, _10); // FakeRead(ForMatchedPlace, _10);
// switchInt(_10) -> [false: bb10, otherwise: bb9]; // switchInt(_10) -> [false: bb11, otherwise: bb10];
// } // }
// bb9: { // bb10: {
// falseEdges -> [real: bb11, imaginary: bb10]; // falseEdges -> [real: bb12, imaginary: bb11];
// } // }
// bb10: { // `else` block - first time // bb11: { // `else` block - first time
// _9 = (*_6); // _9 = (*_6);
// StorageDead(_10); // StorageDead(_10);
// switchInt(move _9) -> [false: bb16, otherwise: bb15]; // switchInt(move _9) -> [false: bb17, otherwise: bb16];
// } // }
// bb11: { // `return 3` - first time // bb12: { // `return 3` - first time
// _0 = const 3i32; // _0 = const 3i32;
// StorageDead(_10); // StorageDead(_10);
// StorageDead(_9); // StorageDead(_9);
// StorageDead(_8); // StorageDead(_8);
// StorageDead(_6); // StorageDead(_6);
// goto -> bb14; // goto -> bb15;
// } // }
// bb12: { // bb13: {
// return; // return;
// } // }
// bb13 (cleanup): { // bb14 (cleanup): {
// drop(_2) -> bb1; // drop(_2) -> bb1;
// } // }
// bb14: {
// drop(_2) -> [return: bb12, unwind: bb1];
// }
// bb15: { // bb15: {
// drop(_2) -> [return: bb13, unwind: bb1];
// }
// bb16: {
// StorageDead(_9); // StorageDead(_9);
// FakeRead(ForMatchGuard, _3); // FakeRead(ForMatchGuard, _3);
// FakeRead(ForMatchGuard, _4); // FakeRead(ForMatchGuard, _4);
@ -136,15 +140,15 @@ fn main() {
// _5 = (_2.1: bool); // _5 = (_2.1: bool);
// StorageLive(_7); // StorageLive(_7);
// _7 = move (_2.2: std::string::String); // _7 = move (_2.2: std::string::String);
// goto -> bb7; // goto -> bb8;
// } // }
// bb16: { // guard otherwise case - first time // bb17: { // guard otherwise case - first time
// StorageDead(_9); // StorageDead(_9);
// StorageDead(_8); // StorageDead(_8);
// StorageDead(_6); // StorageDead(_6);
// falseEdges -> [real: bb5, imaginary: bb3]; // falseEdges -> [real: bb3, imaginary: bb4];
// } // }
// bb17: { // guard - second time // bb18: { // guard - second time
// StorageLive(_6); // StorageLive(_6);
// _6 = &(_2.0: bool); // _6 = &(_2.0: bool);
// StorageLive(_8); // StorageLive(_8);
@ -155,25 +159,25 @@ fn main() {
// StorageLive(_13); // StorageLive(_13);
// _13 = _1; // _13 = _1;
// FakeRead(ForMatchedPlace, _13); // FakeRead(ForMatchedPlace, _13);
// switchInt(_13) -> [false: bb19, otherwise: bb18]; // switchInt(_13) -> [false: bb20, otherwise: bb19];
// } // }
// bb18: { // bb19: {
// falseEdges -> [real: bb20, imaginary: bb19]; // falseEdges -> [real: bb21, imaginary: bb20];
// } // }
// bb19: { // `else` block - second time // bb20: { // `else` block - second time
// _12 = (*_6); // _12 = (*_6);
// StorageDead(_13); // StorageDead(_13);
// switchInt(move _12) -> [false: bb22, otherwise: bb21]; // switchInt(move _12) -> [false: bb23, otherwise: bb22];
// } // }
// bb20: { // bb21: {
// _0 = const 3i32; // _0 = const 3i32;
// StorageDead(_13); // StorageDead(_13);
// StorageDead(_12); // StorageDead(_12);
// StorageDead(_8); // StorageDead(_8);
// StorageDead(_6); // StorageDead(_6);
// goto -> bb14; // goto -> bb15;
// } // }
// bb21: { // bindings for arm 1 // bb22: { // bindings for arm 1
// StorageDead(_12); // StorageDead(_12);
// FakeRead(ForMatchGuard, _3); // FakeRead(ForMatchGuard, _3);
// FakeRead(ForMatchGuard, _4); // FakeRead(ForMatchGuard, _4);
@ -183,46 +187,40 @@ fn main() {
// _5 = (_2.0: bool); // _5 = (_2.0: bool);
// StorageLive(_7); // StorageLive(_7);
// _7 = move (_2.2: std::string::String); // _7 = move (_2.2: std::string::String);
// goto -> bb7; // goto -> bb8;
// } // }
// bb22: { // Guard otherwise case - second time // bb23: { // Guard otherwise case - second time
// StorageDead(_12); // StorageDead(_12);
// StorageDead(_8); // StorageDead(_8);
// StorageDead(_6); // StorageDead(_6);
// falseEdges -> [real: bb6, imaginary: bb4]; // falseEdges -> [real: bb5, imaginary: bb6];
// } // }
// bb23: { // rest of arm 1 // bb24: { // rest of arm 1
// StorageDead(_7); // StorageDead(_7);
// StorageDead(_5); // StorageDead(_5);
// StorageDead(_8); // StorageDead(_8);
// StorageDead(_6); // StorageDead(_6);
// goto -> bb28; // goto -> bb28;
// } // }
// bb24: { // arm 2 // bb25: { // arm 2
// _0 = const 2i32; // _0 = const 2i32;
// drop(_16) -> [return: bb27, unwind: bb13]; // drop(_16) -> [return: bb27, unwind: bb14];
// } // }
// bb25: { // bindings for arm 2 - first pattern // bb26: { // bindings for arm 2 - first pattern
// StorageLive(_15); // StorageLive(_15);
// _15 = (_2.1: bool); // _15 = (_2.1: bool);
// StorageLive(_16); // StorageLive(_16);
// _16 = move (_2.2: std::string::String); // _16 = move (_2.2: std::string::String);
// goto -> bb24; // goto -> bb25;
// }
// bb26: { // bindings for arm 2 - second pattern
// StorageLive(_15);
// _15 = (_2.1: bool);
// StorageLive(_16);
// _16 = move (_2.2: std::string::String);
// goto -> bb24;
// } // }
// bb27: { // rest of arm 2 // bb27: { // rest of arm 2
// StorageDead(_16); // StorageDead(_16);
// StorageDead(_15); // StorageDead(_15);
// goto -> bb28; // goto -> bb28;
// } // }
// bb28: { // bb28: {
// drop(_2) -> [return: bb12, unwind: bb1]; // drop(_2) -> [return: bb13, unwind: bb1];
// } // }
// END rustc.complicated_match.SimplifyCfg-initial.after.mir // END rustc.complicated_match.SimplifyCfg-initial.after.mir
// START rustc.complicated_match.ElaborateDrops.after.mir // START rustc.complicated_match.ElaborateDrops.after.mir

View file

@ -4,7 +4,7 @@ fn guard() -> bool {
false false
} }
fn guard2(_:i32) -> bool { fn guard2(_: i32) -> bool {
true true
} }
@ -45,21 +45,21 @@ fn main() {
// _2 = std::option::Option::<i32>::Some(const 42i32,); // _2 = std::option::Option::<i32>::Some(const 42i32,);
// FakeRead(ForMatchedPlace, _2); // FakeRead(ForMatchedPlace, _2);
// _3 = discriminant(_2); // _3 = discriminant(_2);
// switchInt(move _3) -> [0isize: bb4, 1isize: bb2, otherwise: bb5]; // switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5];
// } // }
// bb1 (cleanup): { // bb1 (cleanup): {
// resume; // resume;
// } // }
// bb2: { // bb2: { // pre_binding3 and arm3
// falseEdges -> [real: bb6, imaginary: bb3]; //pre_binding1
// }
// bb3: {
// falseEdges -> [real: bb10, imaginary: bb4]; //pre_binding2
// }
// bb4: { //pre_binding3 and arm3
// _1 = (const 3i32, const 3i32); // _1 = (const 3i32, const 3i32);
// goto -> bb11; // goto -> bb11;
// } // }
// bb3: {
// falseEdges -> [real: bb6, imaginary: bb4]; //pre_binding1
// }
// bb4: {
// falseEdges -> [real: bb10, imaginary: bb2]; //pre_binding2
// }
// bb5: { // bb5: {
// unreachable; // unreachable;
// } // }
@ -91,7 +91,7 @@ fn main() {
// bb9: { // to pre_binding2 // bb9: { // to pre_binding2
// StorageDead(_7); // StorageDead(_7);
// StorageDead(_6); // StorageDead(_6);
// goto -> bb3; // goto -> bb4;
// } // }
// bb10: { // arm2 // bb10: { // arm2
// StorageLive(_9); // StorageLive(_9);
@ -103,7 +103,7 @@ fn main() {
// StorageDead(_9); // StorageDead(_9);
// goto -> bb11; // goto -> bb11;
// } // }
// bb11: { // arm3 // bb11: {
// StorageDead(_2); // StorageDead(_2);
// StorageDead(_1); // StorageDead(_1);
// _0 = (); // _0 = ();
@ -117,31 +117,41 @@ fn main() {
// _2 = std::option::Option::<i32>::Some(const 42i32,); // _2 = std::option::Option::<i32>::Some(const 42i32,);
// FakeRead(ForMatchedPlace, _2); // FakeRead(ForMatchedPlace, _2);
// _3 = discriminant(_2); // _3 = discriminant(_2);
// switchInt(move _3) -> [0isize: bb3, 1isize: bb2, otherwise: bb4]; // switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5];
// } // }
// bb1 (cleanup): { // bb1 (cleanup): {
// resume; // resume;
// } // }
// bb2: { // bb2: { // pre_binding2
// falseEdges -> [real: bb5, imaginary: bb3]; // falseEdges -> [real: bb10, imaginary: bb4];
// } // }
// bb3: { // bb3: { // pre_binding1
// falseEdges -> [real: bb9, imaginary: bb10]; // falseEdges -> [real: bb6, imaginary: bb2];
// } // }
// bb4: { // to arm3 (can skip 2 since this is `Some`) // bb4: { // binding3 and arm3
// StorageLive(_9);
// _9 = ((_2 as Some).0: i32);
// StorageLive(_10);
// _10 = _9;
// _1 = (const 2i32, move _10);
// StorageDead(_10);
// StorageDead(_9);
// goto -> bb11;
// }
// bb5: {
// unreachable; // unreachable;
// } // }
// bb5: { // binding1 and guard // bb6: {
// StorageLive(_6); // StorageLive(_6);
// _6 = &((_2 as Some).0: i32); // _6 = &((_2 as Some).0: i32);
// _4 = &shallow _2; // _4 = &shallow _2;
// StorageLive(_7); // StorageLive(_7);
// _7 = const guard() -> [return: bb6, unwind: bb1]; // _7 = const guard() -> [return: bb7, unwind: bb1];
// } // }
// bb6: { // end of guard // bb7: { // end of guard
// switchInt(move _7) -> [false: bb8, otherwise: bb7]; // switchInt(move _7) -> [false: bb9, otherwise: bb8];
// } // }
// bb7: { // bb8: {
// StorageDead(_7); // StorageDead(_7);
// FakeRead(ForMatchGuard, _4); // FakeRead(ForMatchGuard, _4);
// FakeRead(ForGuardBinding, _6); // FakeRead(ForGuardBinding, _6);
@ -155,25 +165,15 @@ fn main() {
// StorageDead(_6); // StorageDead(_6);
// goto -> bb11; // goto -> bb11;
// } // }
// bb8: { // to pre_binding3 (can skip 2 since this is `Some`) // bb9: { // to pre_binding3 (can skip 2 since this is `Some`)
// StorageDead(_7); // StorageDead(_7);
// StorageDead(_6); // StorageDead(_6);
// falseEdges -> [real: bb10, imaginary: bb3]; // falseEdges -> [real: bb4, imaginary: bb2];
// } // }
// bb9: { // arm2 // bb10: { // arm2
// _1 = (const 3i32, const 3i32); // _1 = (const 3i32, const 3i32);
// goto -> bb11; // goto -> bb11;
// } // }
// bb10: { // binding3 and arm3
// StorageLive(_9);
// _9 = ((_2 as Some).0: i32);
// StorageLive(_10);
// _10 = _9;
// _1 = (const 2i32, move _10);
// StorageDead(_10);
// StorageDead(_9);
// goto -> bb11;
// }
// bb11: { // bb11: {
// StorageDead(_2); // StorageDead(_2);
// StorageDead(_1); // StorageDead(_1);
@ -188,31 +188,38 @@ fn main() {
// _2 = std::option::Option::<i32>::Some(const 1i32,); // _2 = std::option::Option::<i32>::Some(const 1i32,);
// FakeRead(ForMatchedPlace, _2); // FakeRead(ForMatchedPlace, _2);
// _4 = discriminant(_2); // _4 = discriminant(_2);
// switchInt(move _4) -> [1isize: bb2, otherwise: bb3]; // switchInt(move _4) -> [1isize: bb3, otherwise: bb2];
// } // }
// bb1 (cleanup): { // bb1 (cleanup): {
// resume; // resume;
// } // }
// bb2: { // bb2: {
// falseEdges -> [real: bb5, imaginary: bb3]; // falseEdges -> [real: bb10, imaginary: bb5];
// } // }
// bb3: { // bb3: {
// falseEdges -> [real: bb9, imaginary: bb4]; // falseEdges -> [real: bb6, imaginary: bb2];
// } // }
// bb4: { // bb4: {
// falseEdges -> [real: bb10, imaginary: bb14]; // StorageLive(_14);
// _14 = _2;
// _1 = const 4i32;
// StorageDead(_14);
// goto -> bb15;
// } // }
// bb5: { // bb5: {
// falseEdges -> [real: bb11, imaginary: bb4];
// }
// bb6: { //end of guard1
// StorageLive(_7); // StorageLive(_7);
// _7 = &((_2 as Some).0: i32); // _7 = &((_2 as Some).0: i32);
// _5 = &shallow _2; // _5 = &shallow _2;
// StorageLive(_8); // StorageLive(_8);
// _8 = const guard() -> [return: bb6, unwind: bb1]; // _8 = const guard() -> [return: bb7, unwind: bb1];
// }
// bb6: { //end of guard1
// switchInt(move _8) -> [false: bb8, otherwise: bb7];
// } // }
// bb7: { // bb7: {
// switchInt(move _8) -> [false: bb9, otherwise: bb8];
// }
// bb8: {
// StorageDead(_8); // StorageDead(_8);
// FakeRead(ForMatchGuard, _5); // FakeRead(ForMatchGuard, _5);
// FakeRead(ForGuardBinding, _7); // FakeRead(ForGuardBinding, _7);
@ -223,32 +230,32 @@ fn main() {
// StorageDead(_7); // StorageDead(_7);
// goto -> bb15; // goto -> bb15;
// } // }
// bb8: { // bb9: {
// StorageDead(_8); // StorageDead(_8);
// StorageDead(_7); // StorageDead(_7);
// falseEdges -> [real: bb3, imaginary: bb3]; // falseEdges -> [real: bb2, imaginary: bb2];
// } // }
// bb9: { // binding2 & arm2 // bb10: { // binding2 & arm2
// StorageLive(_9); // StorageLive(_9);
// _9 = _2; // _9 = _2;
// _1 = const 2i32; // _1 = const 2i32;
// StorageDead(_9); // StorageDead(_9);
// goto -> bb15; // goto -> bb15;
// } // }
// bb10: { // binding3: Some(y) if guard2(y) // bb11: { // binding3: Some(y) if guard2(y)
// StorageLive(_11); // StorageLive(_11);
// _11 = &((_2 as Some).0: i32); // _11 = &((_2 as Some).0: i32);
// _5 = &shallow _2; // _5 = &shallow _2;
// StorageLive(_12); // StorageLive(_12);
// StorageLive(_13); // StorageLive(_13);
// _13 = (*_11); // _13 = (*_11);
// _12 = const guard2(move _13) -> [return: bb11, unwind: bb1]; // _12 = const guard2(move _13) -> [return: bb12, unwind: bb1];
// } // }
// bb11: { // end of guard2 // bb12: { // end of guard2
// StorageDead(_13); // StorageDead(_13);
// switchInt(move _12) -> [false: bb13, otherwise: bb12]; // switchInt(move _12) -> [false: bb14, otherwise: bb13];
// } // }
// bb12: { // binding4 & arm4 // bb13: { // binding4 & arm4
// StorageDead(_12); // StorageDead(_12);
// FakeRead(ForMatchGuard, _5); // FakeRead(ForMatchGuard, _5);
// FakeRead(ForGuardBinding, _11); // FakeRead(ForGuardBinding, _11);
@ -259,17 +266,10 @@ fn main() {
// StorageDead(_11); // StorageDead(_11);
// goto -> bb15; // goto -> bb15;
// } // }
// bb13: { // bb14: {
// StorageDead(_12); // StorageDead(_12);
// StorageDead(_11); // StorageDead(_11);
// falseEdges -> [real: bb14, imaginary: bb14]; // falseEdges -> [real: bb4, imaginary: bb4];
// }
// bb14: {
// StorageLive(_14);
// _14 = _2;
// _1 = const 4i32;
// StorageDead(_14);
// goto -> bb15;
// } // }
// bb15: { // bb15: {
// StorageDead(_2); // StorageDead(_2);

View file

@ -20,35 +20,35 @@ fn main() {
// START rustc.main.SimplifyCfg-initial.after.mir // START rustc.main.SimplifyCfg-initial.after.mir
// bb0: { // bb0: {
// ... // ...
// switchInt(move _6) -> [false: bb6, otherwise: bb5]; // switchInt(move _6) -> [false: bb4, otherwise: bb1];
// } // }
// bb1: { // bb1: {
// falseEdges -> [real: bb9, imaginary: bb2]; // _7 = Lt(_1, const 10i32);
// switchInt(move _7) -> [false: bb4, otherwise: bb2];
// } // }
// bb2: { // bb2: {
// falseEdges -> [real: bb12, imaginary: bb3]; // falseEdges -> [real: bb9, imaginary: bb6];
// } // }
// bb3: { // bb3: {
// falseEdges -> [real: bb13, imaginary: bb4];
// }
// bb4: {
// _3 = const 3i32; // _3 = const 3i32;
// goto -> bb14; // goto -> bb14;
// } // }
// bb4: {
// _4 = Le(const 10i32, _1);
// switchInt(move _4) -> [false: bb7, otherwise: bb5];
// }
// bb5: { // bb5: {
// _7 = Lt(_1, const 10i32); // _5 = Le(_1, const 20i32);
// switchInt(move _7) -> [false: bb6, otherwise: bb1]; // switchInt(move _5) -> [false: bb7, otherwise: bb6];
// } // }
// bb6: { // bb6: {
// _4 = Le(const 10i32, _1); // falseEdges -> [real: bb12, imaginary: bb8];
// switchInt(move _4) -> [false: bb8, otherwise: bb7];
// } // }
// bb7: { // bb7: {
// _5 = Le(_1, const 20i32); // switchInt(_1) -> [-1i32: bb8, otherwise: bb3];
// switchInt(move _5) -> [false: bb8, otherwise: bb2];
// } // }
// bb8: { // bb8: {
// switchInt(_1) -> [-1i32: bb3, otherwise: bb4]; // falseEdges -> [real: bb13, imaginary: bb3];
// } // }
// bb9: { // bb9: {
// _8 = &shallow _1; // _8 = &shallow _1;
@ -64,7 +64,7 @@ fn main() {
// } // }
// bb11: { // bb11: {
// StorageDead(_9); // StorageDead(_9);
// falseEdges -> [real: bb4, imaginary: bb2]; // falseEdges -> [real: bb3, imaginary: bb6];
// } // }
// bb12: { // bb12: {
// _3 = const 1i32; // _3 = const 1i32;

View file

@ -19,17 +19,17 @@ fn main() {
// bb0: { // bb0: {
// FakeRead(ForMatchedPlace, _1); // FakeRead(ForMatchedPlace, _1);
// _3 = discriminant(_1); // _3 = discriminant(_1);
// switchInt(move _3) -> [1isize: bb3, otherwise: bb2]; // switchInt(move _3) -> [1isize: bb2, otherwise: bb1];
// } // }
// bb1: { // bb1: {
// goto -> bb4;
// }
// bb2: {
// _0 = const 1i32; // _0 = const 1i32;
// goto -> bb7; // goto -> bb7;
// } // }
// bb2: {
// switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb3, otherwise: bb1];
// }
// bb3: { // bb3: {
// switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2]; // goto -> bb4;
// } // }
// bb4: { // bb4: {
// _4 = &shallow _1; // _4 = &shallow _1;
@ -51,7 +51,7 @@ fn main() {
// } // }
// bb6: { // bb6: {
// StorageDead(_8); // StorageDead(_8);
// goto -> bb2; // goto -> bb1;
// } // }
// bb7: { // bb7: {
// return; // return;
@ -65,17 +65,17 @@ fn main() {
// bb0: { // bb0: {
// nop; // nop;
// _3 = discriminant(_1); // _3 = discriminant(_1);
// switchInt(move _3) -> [1isize: bb3, otherwise: bb2]; // switchInt(move _3) -> [1isize: bb2, otherwise: bb1];
// } // }
// bb1: { // bb1: {
// goto -> bb4;
// }
// bb2: {
// _0 = const 1i32; // _0 = const 1i32;
// goto -> bb7; // goto -> bb7;
// } // }
// bb2: {
// switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb3, otherwise: bb1];
// }
// bb3: { // bb3: {
// switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2]; // goto -> bb4;
// } // }
// bb4: { // bb4: {
// nop; // nop;
@ -97,7 +97,7 @@ fn main() {
// } // }
// bb6: { // bb6: {
// StorageDead(_8); // StorageDead(_8);
// goto -> bb2; // goto -> bb1;
// } // }
// bb7: { // bb7: {
// return; // return;

View file

@ -47,22 +47,22 @@ fn main() {
// } // }
// bb0: { // bb0: {
// _5 = discriminant(_1); // _5 = discriminant(_1);
// switchInt(move _5) -> [0isize: bb3, otherwise: bb1]; // switchInt(move _5) -> [0isize: bb1, otherwise: bb2];
// } // }
// bb1: { // bb1: {
// _6 = ((_1 as Err).0: i32);
// ((_0 as Err).0: i32) = move _6;
// discriminant(_0) = 1;
// goto -> bb2;
// }
// bb2: {
// return;
// }
// bb3: {
// _10 = ((_1 as Ok).0: u32); // _10 = ((_1 as Ok).0: u32);
// ((_0 as Ok).0: u32) = move _10; // ((_0 as Ok).0: u32) = move _10;
// discriminant(_0) = 0; // discriminant(_0) = 0;
// goto -> bb2; // goto -> bb3;
// }
// bb2: {
// _6 = ((_1 as Err).0: i32);
// ((_0 as Err).0: i32) = move _6;
// discriminant(_0) = 1;
// goto -> bb3;
// }
// bb3: {
// return;
// } // }
// } // }
// END rustc.try_identity.SimplifyArmIdentity.before.mir // END rustc.try_identity.SimplifyArmIdentity.before.mir
@ -106,22 +106,22 @@ fn main() {
// } // }
// bb0: { // bb0: {
// _5 = discriminant(_1); // _5 = discriminant(_1);
// switchInt(move _5) -> [0isize: bb3, otherwise: bb1]; // switchInt(move _5) -> [0isize: bb1, otherwise: bb2];
// } // }
// bb1: { // bb1: {
// _0 = move _1; // _0 = move _1;
// nop; // nop;
// nop; // nop;
// goto -> bb2; // goto -> bb3;
// } // }
// bb2: { // bb2: {
// return;
// }
// bb3: {
// _0 = move _1; // _0 = move _1;
// nop; // nop;
// nop; // nop;
// goto -> bb2; // goto -> bb3;
// }
// bb3: {
// return;
// } // }
// } // }
// END rustc.try_identity.SimplifyArmIdentity.after.mir // END rustc.try_identity.SimplifyArmIdentity.after.mir
@ -165,16 +165,16 @@ fn main() {
// } // }
// bb0: { // bb0: {
// _5 = discriminant(_1); // _5 = discriminant(_1);
// goto -> bb2; // goto -> bb1;
// } // }
// bb1: { // bb1: {
// return;
// }
// bb2: {
// _0 = move _1; // _0 = move _1;
// nop; // nop;
// nop; // nop;
// goto -> bb1; // goto -> bb2;
// }
// bb2: {
// return;
// } // }
// } // }
// END rustc.try_identity.SimplifyBranchSame.after.mir // END rustc.try_identity.SimplifyBranchSame.after.mir

View file

@ -1,7 +1,7 @@
fn main() {} fn main() {}
const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument const fn slice(&[a, b]: &[i32]) -> i32 {
a + b //~ ERROR can only call other `const fn` within a `const fn` //~^ ERROR refutable pattern in function argument
//~^ ERROR use of possibly-uninitialized variable: `a` //~| ERROR loops and conditional expressions are not stable in const fn
//~| ERROR use of possibly-uninitialized variable: `b` a + b
} }

View file

@ -1,31 +1,19 @@
error[E0005]: refutable pattern in function argument: `&[]`, `&[_]` and `&[_, _, _, ..]` not covered error[E0005]: refutable pattern in function argument: `&[]`, `&[_]` and `&[_, _, _, ..]` not covered
--> $DIR/const_let_refutable.rs:3:16 --> $DIR/const_let_refutable.rs:3:16
| |
LL | const fn slice([a, b]: &[i32]) -> i32 { LL | const fn slice(&[a, b]: &[i32]) -> i32 {
| ^^^^^^ patterns `&[]`, `&[_]` and `&[_, _, _, ..]` not covered | ^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _, _, ..]` not covered
error[E0723]: can only call other `const fn` within a `const fn`, but `const <&i32 as std::ops::Add>::add` is not stable as `const fn` error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/const_let_refutable.rs:4:5 --> $DIR/const_let_refutable.rs:3:17
| |
LL | a + b LL | const fn slice(&[a, b]: &[i32]) -> i32 {
| ^^^^^ | ^^^^^^
| |
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0381]: use of possibly-uninitialized variable: `a` error: aborting due to 2 previous errors
--> $DIR/const_let_refutable.rs:4:5
|
LL | a + b
| ^ use of possibly-uninitialized `a`
error[E0381]: use of possibly-uninitialized variable: `b` Some errors have detailed explanations: E0005, E0723.
--> $DIR/const_let_refutable.rs:4:9
|
LL | a + b
| ^ use of possibly-uninitialized `b`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0005, E0381, E0723.
For more information about an error, try `rustc --explain E0005`. For more information about an error, try `rustc --explain E0005`.

View file

@ -10,7 +10,6 @@ fn transmute<T, U>(t: T) -> U {
let Helper::U(u) = Helper::T(t, []); let Helper::U(u) = Helper::T(t, []);
//~^ ERROR refutable pattern in local binding: `T(_, _)` not covered //~^ ERROR refutable pattern in local binding: `T(_, _)` not covered
u u
//~^ ERROR use of possibly-uninitialized variable: `u`
} }
fn main() { fn main() {

View file

@ -19,13 +19,6 @@ help: you might want to use `if let` to ignore the variant that isn't matched
LL | if let Helper::U(u) = Helper::T(t, []) { /* */ } LL | if let Helper::U(u) = Helper::T(t, []) { /* */ }
| |
error[E0381]: use of possibly-uninitialized variable: `u` error: aborting due to previous error
--> $DIR/empty-never-array.rs:12:5
|
LL | u
| ^ use of possibly-uninitialized `u`
error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0005`.
Some errors have detailed explanations: E0005, E0381.
For more information about an error, try `rustc --explain E0005`.

View file

@ -1,17 +1,3 @@
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:2:11
|
LL | match (l1, l2) {
| ^^^^^^^^ cannot move out of here
...
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| -- data moved here
LL | => println!("one empty"),
LL | (&[hd1, ..], &[hd2, ..])
| --- ...and here
|
= note: move occurs because these variables have types that don't implement the `Copy` trait
error[E0508]: cannot move out of type `[T]`, a non-copy slice error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:2:11 --> $DIR/issue-12567.rs:2:11
| |
@ -26,6 +12,20 @@ LL | (&[hd1, ..], &[hd2, ..])
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
error[E0508]: cannot move out of type `[T]`, a non-copy slice
--> $DIR/issue-12567.rs:2:11
|
LL | match (l1, l2) {
| ^^^^^^^^ cannot move out of here
...
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| -- data moved here
LL | => println!("one empty"),
LL | (&[hd1, ..], &[hd2, ..])
| --- ...and here
|
= note: move occurs because these variables have types that don't implement the `Copy` trait
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0508`. For more information about this error, try `rustc --explain E0508`.

View file

@ -4,6 +4,5 @@ fn main() {
for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) {
//~^ ERROR refutable pattern in `for` loop binding: `&[]`, `&[_]`, `&[_, _]` and 1 more not //~^ ERROR refutable pattern in `for` loop binding: `&[]`, `&[_]`, `&[_, _]` and 1 more not
println!("y={}", y); println!("y={}", y);
//~^ ERROR borrow of possibly-uninitialized variable: `y`
} }
} }

View file

@ -4,13 +4,6 @@ error[E0005]: refutable pattern in `for` loop binding: `&[]`, `&[_]`, `&[_, _]`
LL | for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { LL | for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) {
| ^^^^^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered | ^^^^^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered
error[E0381]: borrow of possibly-uninitialized variable: `y` error: aborting due to previous error
--> $DIR/issue-15381.rs:6:26
|
LL | println!("y={}", y);
| ^ use of possibly-uninitialized `y`
error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0005`.
Some errors have detailed explanations: E0005, E0381.
For more information about an error, try `rustc --explain E0005`.

View file

@ -2,6 +2,8 @@
// edition:2018 // edition:2018
// check-pass
#![feature(or_patterns)] #![feature(or_patterns)]
fn main() { fn main() {
@ -11,35 +13,29 @@ fn main() {
let Ok(ref mut a) | Err(ref mut a) = Ok(0); let Ok(ref mut a) | Err(ref mut a) = Ok(0);
// Two levels: // Two levels:
enum Tri<S, T, U> { V1(S), V2(T), V3(U) } enum Tri<S, T, U> {
V1(S),
V2(T),
V3(U),
}
use Tri::*; use Tri::*;
let Ok((V1(a) | V2(a) | V3(a), b)) | Err(Ok((a, b)) | Err((a, b))) let Ok((V1(a) | V2(a) | V3(a), b)) | Err(Ok((a, b)) | Err((a, b))): Result<_, Result<_, _>> =
: Result<_, Result<_, _>> Ok((V1(1), 1));
= Ok((V1(1), 1));
let Ok((V1(a) | V2(a) | V3(a), ref b)) | Err(Ok((a, ref b)) | Err((a, ref b))) let Ok((V1(a) | V2(a) | V3(a), ref b)) | Err(Ok((a, ref b)) | Err((a, ref b))): Result<
: Result<_, Result<_, _>> _,
= Ok((V1(1), 1)); Result<_, _>,
> = Ok((V1(1), 1));
// Three levels: // Three levels:
let ( let (
a, a,
Err((ref mut b, ref c, d)) | Err((ref mut b, ref c, d))
Ok(( | Ok((
Ok( Ok(V1((ref c, d)) | V2((d, ref c)) | V3((ref c, Ok((_, d)) | Err((d, _)))))
V1((ref c, d)) | | Err((ref c, d)),
V2((d, ref c)) | ref mut b,
V3((ref c, Ok((_, d)) | Err((d, _)))) )),
) | ): (_, Result<_, _>) = (1, Ok((Ok(V3((1, Ok::<_, (i32, i32)>((1, 1))))), 1)));
Err((ref c, d)),
ref mut b
))
) =
(1, Ok((Ok(V3((1, Ok((1, 1))))), 1)));
// FIXME(or_patterns; Centril | dlrobertson): remove this line below and
// change this test to check-pass once MIR can handle or-patterns with bindings.
let () = 0;
//~^ ERROR mismatched types
} }

View file

@ -1,9 +0,0 @@
error[E0308]: mismatched types
--> $DIR/consistent-bindings.rs:43:9
|
LL | let () = 0;
| ^^ expected integer, found `()`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,13 +1,8 @@
#![feature(or_patterns)] #![feature(or_patterns)]
#![deny(unreachable_patterns)] #![deny(unreachable_patterns)]
// We wrap patterns in a tuple because top-level or-patterns are special-cased for now. // We wrap patterns in a tuple because top-level or-patterns were special-cased.
fn main() { fn main() {
// Get the fatal error out of the way
match (0u8,) {
(0 | _,) => {} //~^ ERROR or-patterns are not fully implemented yet
}
match (0u8, 0u8) { match (0u8, 0u8) {
//~^ ERROR non-exhaustive patterns: `(2u8..=std::u8::MAX, _)` //~^ ERROR non-exhaustive patterns: `(2u8..=std::u8::MAX, _)`
(0 | 1, 2 | 3) => {} (0 | 1, 2 | 3) => {}

View file

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: `(2u8..=std::u8::MAX, _)` not covered error[E0004]: non-exhaustive patterns: `(2u8..=std::u8::MAX, _)` not covered
--> $DIR/exhaustiveness-non-exhaustive.rs:13:11 --> $DIR/exhaustiveness-non-exhaustive.rs:6:11
| |
LL | match (0u8, 0u8) { LL | match (0u8, 0u8) {
| ^^^^^^^^^^ pattern `(2u8..=std::u8::MAX, _)` not covered | ^^^^^^^^^^ pattern `(2u8..=std::u8::MAX, _)` not covered
@ -7,7 +7,7 @@ LL | match (0u8, 0u8) {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `((4u8..=std::u8::MAX))` not covered error[E0004]: non-exhaustive patterns: `((4u8..=std::u8::MAX))` not covered
--> $DIR/exhaustiveness-non-exhaustive.rs:17:11 --> $DIR/exhaustiveness-non-exhaustive.rs:10:11
| |
LL | match ((0u8,),) { LL | match ((0u8,),) {
| ^^^^^^^^^ pattern `((4u8..=std::u8::MAX))` not covered | ^^^^^^^^^ pattern `((4u8..=std::u8::MAX))` not covered
@ -15,19 +15,13 @@ LL | match ((0u8,),) {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `(Some(2u8..=std::u8::MAX))` not covered error[E0004]: non-exhaustive patterns: `(Some(2u8..=std::u8::MAX))` not covered
--> $DIR/exhaustiveness-non-exhaustive.rs:21:11 --> $DIR/exhaustiveness-non-exhaustive.rs:14:11
| |
LL | match (Some(0u8),) { LL | match (Some(0u8),) {
| ^^^^^^^^^^^^ pattern `(Some(2u8..=std::u8::MAX))` not covered | ^^^^^^^^^^^^ pattern `(Some(2u8..=std::u8::MAX))` not covered
| |
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error: or-patterns are not fully implemented yet error: aborting due to 3 previous errors
--> $DIR/exhaustiveness-non-exhaustive.rs:9:10
|
LL | (0 | _,) => {}
| ^^^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0004`. For more information about this error, try `rustc --explain E0004`.

View file

@ -1,13 +1,10 @@
#![feature(or_patterns)] #![feature(or_patterns)]
#![deny(unreachable_patterns)] #![deny(unreachable_patterns)]
// We wrap patterns in a tuple because top-level or-patterns are special-cased for now. // check-pass
fn main() {
// Get the fatal error out of the way
match (0,) {
(0 | _,) => {} //~^ ERROR or-patterns are not fully implemented yet
}
// We wrap patterns in a tuple because top-level or-patterns were special-cased.
fn main() {
match (0,) { match (0,) {
(1 | 2,) => {} (1 | 2,) => {}
_ => {} _ => {}

View file

@ -1,8 +0,0 @@
error: or-patterns are not fully implemented yet
--> $DIR/exhaustiveness-pass.rs:9:10
|
LL | (0 | _,) => {}
| ^^^^^
error: aborting due to previous error

View file

@ -1,13 +1,8 @@
#![feature(or_patterns)] #![feature(or_patterns)]
#![deny(unreachable_patterns)] #![deny(unreachable_patterns)]
// We wrap patterns in a tuple because top-level or-patterns are special-cased for now. // We wrap patterns in a tuple because top-level or-patterns were special-cased.
fn main() { fn main() {
// Get the fatal error out of the way
match (0u8,) {
(0 | _,) => {} //~^ ERROR or-patterns are not fully implemented yet
}
match (0u8,) { match (0u8,) {
(1 | 2,) => {} (1 | 2,) => {}
(1,) => {} //~ ERROR unreachable pattern (1,) => {} //~ ERROR unreachable pattern

View file

@ -1,110 +1,104 @@
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:15:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:8:9
| |
LL | (1,) => {} LL | (1,) => {}
| ^^^^ | ^^^^
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/exhaustiveness-unreachable-pattern.rs:3:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:2:9
| |
LL | #![deny(unreachable_patterns)] LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:20:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:13:9
| |
LL | (2,) => {} LL | (2,) => {}
| ^^^^ | ^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:26:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:19:9
| |
LL | (1 | 2,) => {} LL | (1 | 2,) => {}
| ^^^^^^^^ | ^^^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:31:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
| |
LL | (1, 3) => {} LL | (1, 3) => {}
| ^^^^^^ | ^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:32:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
| |
LL | (1, 4) => {} LL | (1, 4) => {}
| ^^^^^^ | ^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:33:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
| |
LL | (2, 4) => {} LL | (2, 4) => {}
| ^^^^^^ | ^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:34:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:27:9
| |
LL | (2 | 1, 4) => {} LL | (2 | 1, 4) => {}
| ^^^^^^^^^^ | ^^^^^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:36:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:29:9
| |
LL | (1, 4 | 5) => {} LL | (1, 4 | 5) => {}
| ^^^^^^^^^^ | ^^^^^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:41:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:34:9
| |
LL | (Some(1),) => {} LL | (Some(1),) => {}
| ^^^^^^^^^^ | ^^^^^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:42:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:35:9
| |
LL | (None,) => {} LL | (None,) => {}
| ^^^^^^^ | ^^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:47:9 --> $DIR/exhaustiveness-unreachable-pattern.rs:40:9
| |
LL | ((1..=4,),) => {}, LL | ((1..=4,),) => {}
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:12 --> $DIR/exhaustiveness-unreachable-pattern.rs:45:14
| |
LL | | 1,) => {} LL | (1 | 1,) => {}
| ^ | ^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:60:15 --> $DIR/exhaustiveness-unreachable-pattern.rs:52:15
| |
LL | | 0] => {} LL | | 0] => {}
| ^ | ^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:58:15 --> $DIR/exhaustiveness-unreachable-pattern.rs:50:15
| |
LL | | 0 LL | | 0
| ^ | ^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:68:10 --> $DIR/exhaustiveness-unreachable-pattern.rs:60:10
| |
LL | [1 LL | [1
| ^ | ^
error: unreachable pattern error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:74:14 --> $DIR/exhaustiveness-unreachable-pattern.rs:66:14
| |
LL | Some(0 LL | Some(0
| ^ | ^
error: or-patterns are not fully implemented yet error: aborting due to 16 previous errors
--> $DIR/exhaustiveness-unreachable-pattern.rs:9:10
|
LL | (0 | _,) => {}
| ^^^^^
error: aborting due to 17 previous errors

View file

@ -30,6 +30,8 @@ fn main() {
let x = Ok(3); let x = Ok(3);
let Ok(y) | Err(y) = x; let Ok(y) | Err(y) = x;
//~^ ERROR or-pattern is not allowed in a `const` //~^ ERROR or-pattern is not allowed in a `const`
//~| ERROR constant contains unimplemented expression type
//~| ERROR constant contains unimplemented expression type
2 2
}]; }];
} }

View file

@ -52,6 +52,19 @@ LL | let Ok(y) | Err(y) = x;
= note: for more information, see https://github.com/rust-lang/rust/issues/49146 = note: for more information, see https://github.com/rust-lang/rust/issues/49146
= help: add `#![feature(const_if_match)]` to the crate attributes to enable = help: add `#![feature(const_if_match)]` to the crate attributes to enable
error: aborting due to 6 previous errors error[E0019]: constant contains unimplemented expression type
--> $DIR/feature-gate-const-fn.rs:31:25
|
LL | let Ok(y) | Err(y) = x;
| ^
For more information about this error, try `rustc --explain E0658`. error[E0019]: constant contains unimplemented expression type
--> $DIR/feature-gate-const-fn.rs:31:16
|
LL | let Ok(y) | Err(y) = x;
| ^
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0019, E0658.
For more information about an error, try `rustc --explain E0019`.

View file

@ -6,7 +6,6 @@ fn foo(res: Result<u32, &R>) -> u32 {
let Ok(x) = res; let Ok(x) = res;
//~^ ERROR refutable pattern //~^ ERROR refutable pattern
x x
//~^ ERROR use of possibly-uninitialized variable: `x`
} }
fn main() { fn main() {

View file

@ -11,13 +11,6 @@ help: you might want to use `if let` to ignore the variant that isn't matched
LL | if let Ok(x) = res { /* */ } LL | if let Ok(x) = res { /* */ }
| |
error[E0381]: use of possibly-uninitialized variable: `x` error: aborting due to previous error
--> $DIR/recursive-types-are-not-uninhabited.rs:8:5
|
LL | x
| ^ use of possibly-uninitialized `x`
error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0005`.
Some errors have detailed explanations: E0005, E0381.
For more information about an error, try `rustc --explain E0005`.

View file

@ -65,13 +65,18 @@ LL | match &(e.clone(), e.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
LL | LL |
LL | &(Either::One(_t), Either::Two(_u)) LL | &(Either::One(_t), Either::Two(_u))
| ----------------------------------- | -- -- ...and here
| | | | | |
| | | ...and here | data moved here
| | data moved here
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the `&`
|
LL | (Either::One(_t), Either::Two(_u))
LL |
LL |
LL | | &(Either::Two(_t), Either::One(_u)) => (),
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/duplicate-suggestions.rs:70:11 --> $DIR/duplicate-suggestions.rs:70:11
@ -170,13 +175,18 @@ LL | match &mut (em.clone(), em.clone()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | LL |
LL | &mut (Either::One(_t), Either::Two(_u)) LL | &mut (Either::One(_t), Either::Two(_u))
| --------------------------------------- | -- -- ...and here
| | | | | |
| | | ...and here | data moved here
| | data moved here
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
| |
= note: move occurs because these variables have types that don't implement the `Copy` trait = note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the `&mut`
|
LL | (Either::One(_t), Either::Two(_u))
LL |
LL |
LL | | &mut (Either::Two(_t), Either::One(_u)) => (),
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/duplicate-suggestions.rs:122:11 --> $DIR/duplicate-suggestions.rs:122:11

View file

@ -263,11 +263,18 @@ LL | match r {
| ^ | ^
LL | LL |
LL | &Either::One(_t) LL | &Either::One(_t)
| ---------------- | --
| | | | |
| | data moved here | data moved here
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Either::One(_t)` |
help: consider removing the `&`
|
LL | Either::One(_t)
LL |
LL |
LL | | &Either::Two(_t) => (),
|
error[E0507]: cannot move out of `r.0` which is behind a shared reference error[E0507]: cannot move out of `r.0` which is behind a shared reference
--> $DIR/simple.rs:188:11 --> $DIR/simple.rs:188:11
@ -502,11 +509,18 @@ LL | match &e {
| ^^ | ^^
LL | LL |
LL | &Either::One(_t) LL | &Either::One(_t)
| ---------------- | --
| | | | |
| | data moved here | data moved here
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Either::One(_t)` |
help: consider removing the `&`
|
LL | Either::One(_t)
LL |
LL |
LL | | &Either::Two(_t) => (),
|
error[E0507]: cannot move out of a shared reference error[E0507]: cannot move out of a shared reference
--> $DIR/simple.rs:308:11 --> $DIR/simple.rs:308:11
@ -571,11 +585,18 @@ LL | match &mut em {
| ^^^^^^^ | ^^^^^^^
LL | LL |
LL | &mut Either::One(_t) LL | &mut Either::One(_t)
| -------------------- | --
| | | | |
| | data moved here | data moved here
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&mut`: `Either::One(_t)` |
help: consider removing the `&mut`
|
LL | Either::One(_t)
LL |
LL |
LL | | &mut Either::Two(_t) => (),
|
error[E0507]: cannot move out of a mutable reference error[E0507]: cannot move out of a mutable reference
--> $DIR/simple.rs:343:11 --> $DIR/simple.rs:343:11