diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/sized/expr-type-error-plus-sized-obligation.rs | 22 | ||||
| -rw-r--r-- | tests/ui/sized/expr-type-error-plus-sized-obligation.stderr | 19 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/sized/expr-type-error-plus-sized-obligation.rs b/tests/ui/sized/expr-type-error-plus-sized-obligation.rs new file mode 100644 index 00000000000..a96beeecab9 --- /dev/null +++ b/tests/ui/sized/expr-type-error-plus-sized-obligation.rs @@ -0,0 +1,22 @@ +#![allow(warnings)] + +fn issue_117846_repro() { + let (a, _) = if true { + produce() + } else { + (Vec::new(), &[]) //~ ERROR E0308 + }; + + accept(&a); +} + +struct Foo; +struct Bar; + +fn produce() -> (Vec<Foo>, &'static [Bar]) { + todo!() +} + +fn accept(c: &[Foo]) {} + +fn main() {} diff --git a/tests/ui/sized/expr-type-error-plus-sized-obligation.stderr b/tests/ui/sized/expr-type-error-plus-sized-obligation.stderr new file mode 100644 index 00000000000..9cf477fbd41 --- /dev/null +++ b/tests/ui/sized/expr-type-error-plus-sized-obligation.stderr @@ -0,0 +1,19 @@ +error[E0308]: `if` and `else` have incompatible types + --> $DIR/expr-type-error-plus-sized-obligation.rs:7:9 + | +LL | let (a, _) = if true { + | __________________- +LL | | produce() + | | --------- expected because of this +LL | | } else { +LL | | (Vec::new(), &[]) + | | ^^^^^^^^^^^^^^^^^ expected `(Vec<Foo>, &[Bar])`, found `(Vec<_>, &[_; 0])` +LL | | }; + | |_____- `if` and `else` have incompatible types + | + = note: expected tuple `(Vec<Foo>, &[Bar])` + found tuple `(Vec<_>, &[_; 0])` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. |
