Auto merge of #57580 - Centril:rollup, r=Centril
Rollup of 4 pull requests Successful merges: - #56874 (Simplify foreign type rendering.) - #57113 (Move diagnostics out from QueryJob and optimize for the case with no diagnostics) - #57366 (Point at match discriminant on type error in match arm pattern) - #57538 (librustc_mir: Fix ICE with slice patterns) Failed merges: - #57381 (Tweak output of type mismatch between "then" and `else` `if` arms) r? @ghost
This commit is contained in:
commit
9aee7ed335
50 changed files with 420 additions and 221 deletions
|
|
@ -12,6 +12,8 @@ LL | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13624.rs:22:9
|
||||
|
|
||||
LL | match enum_struct_variant {
|
||||
| ------------------- this match expression has type `()`
|
||||
LL | a::Enum::EnumStructVariant { x, y, z } => {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/E0308-4.rs:4:9
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression has type `u8`
|
||||
LL | 0u8..=3i8 => (), //~ ERROR E0308
|
||||
| ^^^^^^^^^ expected u8, found i8
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-11844.rs:6:9
|
||||
|
|
||||
LL | match a {
|
||||
| - this match expression has type `std::option::Option<std::boxed::Box<{integer}>>`
|
||||
LL | Ok(a) => //~ ERROR: mismatched types
|
||||
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-12552.rs:6:5
|
||||
|
|
||||
LL | match t {
|
||||
| - this match expression has type `std::result::Result<_, {integer}>`
|
||||
LL | Some(k) => match k { //~ ERROR mismatched types
|
||||
| ^^^^^^^ expected enum `std::result::Result`, found enum `std::option::Option`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13466.rs:8:9
|
||||
|
|
||||
LL | let _x: usize = match Some(1) {
|
||||
| ------- this match expression has type `std::option::Option<{integer}>`
|
||||
LL | Ok(u) => u,
|
||||
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
@ -10,6 +12,9 @@ LL | Ok(u) => u,
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13466.rs:14:9
|
||||
|
|
||||
LL | let _x: usize = match Some(1) {
|
||||
| ------- this match expression has type `std::option::Option<{integer}>`
|
||||
...
|
||||
LL | Err(e) => panic!(e)
|
||||
| ^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-15896.rs:11:11
|
||||
|
|
||||
LL | let u = match e {
|
||||
| - this match expression has type `main::R`
|
||||
LL | E::B(
|
||||
LL | Tau{t: x},
|
||||
| ^^^^^^^^^ expected enum `main::R`, found struct `main::Tau`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-16401.rs:8:9
|
||||
|
|
||||
LL | match () {
|
||||
| -- this match expression has type `()`
|
||||
LL | Slice { data: data, len: len } => (),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `Slice`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-3680.rs:3:9
|
||||
|
|
||||
LL | match None {
|
||||
| ---- this match expression has type `std::option::Option<_>`
|
||||
LL | Err(_) => ()
|
||||
| ^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ LL | (true, false, false) => ()
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-5100.rs:33:9
|
||||
|
|
||||
LL | match (true, false) {
|
||||
| ------------- this match expression has type `(bool, bool)`
|
||||
LL | box (true, false) => ()
|
||||
| ^^^^^^^^^^^^^^^^^ expected tuple, found struct `std::boxed::Box`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-5358-1.rs:6:9
|
||||
|
|
||||
LL | match S(Either::Left(5)) {
|
||||
| ------------------ this match expression has type `S`
|
||||
LL | Either::Right(_) => {}
|
||||
| ^^^^^^^^^^^^^^^^ expected struct `S`, found enum `Either`
|
||||
|
|
||||
|
|
|
|||
35
src/test/ui/issues/issue-57472.rs
Normal file
35
src/test/ui/issues/issue-57472.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#![crate_type="lib"]
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
mod test_struct {
|
||||
// Test the exact copy of the minimal example
|
||||
// posted in the issue.
|
||||
pub struct Punned {
|
||||
foo: [u8; 1],
|
||||
bar: [u8; 1],
|
||||
}
|
||||
|
||||
pub fn test(punned: Punned) {
|
||||
match punned {
|
||||
Punned { foo: [_], .. } => println!("foo"),
|
||||
Punned { bar: [_], .. } => println!("bar"),
|
||||
//~^ ERROR unreachable pattern [unreachable_patterns]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod test_union {
|
||||
// Test the same thing using a union.
|
||||
pub union Punned {
|
||||
foo: [u8; 1],
|
||||
bar: [u8; 1],
|
||||
}
|
||||
|
||||
pub fn test(punned: Punned) {
|
||||
match punned {
|
||||
Punned { foo: [_] } => println!("foo"),
|
||||
Punned { bar: [_] } => println!("bar"),
|
||||
//~^ ERROR unreachable pattern [unreachable_patterns]
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/test/ui/issues/issue-57472.stderr
Normal file
20
src/test/ui/issues/issue-57472.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error: unreachable pattern
|
||||
--> $DIR/issue-57472.rs:15:13
|
||||
|
|
||||
LL | Punned { bar: [_], .. } => println!("bar"),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/issue-57472.rs:2:9
|
||||
|
|
||||
LL | #![deny(unreachable_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/issue-57472.rs:31:13
|
||||
|
|
||||
LL | Punned { bar: [_] } => println!("bar"),
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-7092.rs:6:9
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression has type `Whatever`
|
||||
LL | Some(field) =>
|
||||
| ^^^^^^^^^^^ expected enum `Whatever`, found enum `std::option::Option`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/match-struct.rs:6:9
|
||||
|
|
||||
LL | match (S { a: 1 }) {
|
||||
| ------------ this match expression has type `S`
|
||||
LL | E::C(_) => (),
|
||||
| ^^^^^^^ expected struct `S`, found enum `E`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/match-tag-unary.rs:4:43
|
||||
|
|
||||
LL | fn main() { let x: A = A::A(0); match x { B::B(y) => { } } } //~ ERROR mismatched types
|
||||
| ^^^^^^^ expected enum `A`, found enum `B`
|
||||
| - ^^^^^^^ expected enum `A`, found enum `B`
|
||||
| |
|
||||
| this match expression has type `A`
|
||||
|
|
||||
= note: expected type `A`
|
||||
found type `B`
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ LL | A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/pattern-error-continue.rs:22:9
|
||||
|
|
||||
LL | match 'c' {
|
||||
| --- this match expression has type `char`
|
||||
LL | S { .. } => (),
|
||||
| ^^^^^^^^ expected char, found struct `S`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/pattern-tyvar.rs:5:18
|
||||
|
|
||||
LL | match t {
|
||||
| - this match expression has type `std::option::Option<std::vec::Vec<isize>>`
|
||||
LL | Bar::T1(_, Some::<isize>(x)) => { //~ ERROR mismatched types
|
||||
| ^^^^^^^^^^^^^^^^ expected struct `std::vec::Vec`, found isize
|
||||
|
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ LL | PointF::<u32> { .. } => {} //~ ERROR wrong number of type arguments
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/structure-constructor-type-mismatch.rs:54:9
|
||||
|
|
||||
LL | match (Point { x: 1, y: 2 }) {
|
||||
| ---------------------- this match expression has type `Point<{integer}>`
|
||||
LL | PointF::<u32> { .. } => {} //~ ERROR wrong number of type arguments
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected integer, found f32
|
||||
|
|
||||
|
|
@ -118,6 +120,8 @@ LL | PointF::<u32> { .. } => {} //~ ERROR wrong number of type arguments
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/structure-constructor-type-mismatch.rs:59:9
|
||||
|
|
||||
LL | match (Point { x: 1, y: 2 }) {
|
||||
| ---------------------- this match expression has type `Point<{integer}>`
|
||||
LL | PointF { .. } => {} //~ ERROR mismatched types
|
||||
| ^^^^^^^^^^^^^ expected integer, found f32
|
||||
|
|
||||
|
|
@ -127,6 +131,8 @@ LL | PointF { .. } => {} //~ ERROR mismatched types
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/structure-constructor-type-mismatch.rs:67:9
|
||||
|
|
||||
LL | match (Pair { x: 1, y: 2 }) {
|
||||
| --------------------- this match expression has type `Pair<{integer}, {integer}>`
|
||||
LL | PairF::<u32> { .. } => {} //~ ERROR mismatched types
|
||||
| ^^^^^^^^^^^^^^^^^^^ expected integer, found f32
|
||||
|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue