Skip to content

Commit 3f2159f

Browse files
committed
Add test for rust-lang#117846
1 parent 3cdcdaf commit 3f2159f

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![allow(warnings)]
2+
3+
fn issue_117846_repro() {
4+
let (a, _) = if true { //~ ERROR E0277
5+
produce()
6+
} else {
7+
(Vec::new(), &[]) //~ ERROR E0308
8+
};
9+
10+
accept(&a);
11+
}
12+
13+
struct Foo;
14+
struct Bar;
15+
16+
fn produce() -> (Vec<Foo>, &'static [Bar]) {
17+
todo!()
18+
}
19+
20+
fn accept(c: &[Foo]) {}
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0308]: `if` and `else` have incompatible types
2+
--> $DIR/expr-type-error-plus-sized-obligation.rs:7:9
3+
|
4+
LL | let (a, _) = if true {
5+
| __________________-
6+
LL | | produce()
7+
| | --------- expected because of this
8+
LL | | } else {
9+
LL | | (Vec::new(), &[])
10+
| | ^^^^^^^^^^^^^^^^^ expected `(Vec<Foo>, &[Bar])`, found `(Vec<_>, &[_; 0])`
11+
LL | | };
12+
| |_____- `if` and `else` have incompatible types
13+
|
14+
= note: expected tuple `(Vec<Foo>, &[Bar])`
15+
found tuple `(Vec<_>, &[_; 0])`
16+
17+
error[E0277]: the size for values of type `[Foo]` cannot be known at compilation time
18+
--> $DIR/expr-type-error-plus-sized-obligation.rs:4:10
19+
|
20+
LL | let (a, _) = if true {
21+
| ^ doesn't have a size known at compile-time
22+
|
23+
= help: the trait `Sized` is not implemented for `[Foo]`
24+
= note: all local variables must have a statically known size
25+
= help: unsized locals are gated as an unstable feature
26+
27+
error: aborting due to 2 previous errors
28+
29+
Some errors have detailed explanations: E0277, E0308.
30+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)