Skip to content

Commit 51a4664

Browse files
authored
Unrolled build for rust-lang#127160
Rollup merge of rust-lang#127160 - pacak:123630-test, r=Nadrieril Add a regression test for rust-lang#123630 Fixes rust-lang#123630 compiler should not suggest nonsensical signatures, original suggestion was ``` error[E0308]: mismatched types --> src/lib.rs:3:31 | 3 | fn select<F, I>(filter: F) -> Select<F, I> { | ------ ^^^^^^^^^^^^ expected `Select<F, I>`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression | = note: expected struct `Select<F, I>` found unit type `()` error[E0282]: type annotations needed for `Select<{closure@src/lib.rs:8:22: 8:25}, I>` --> src/lib.rs:8:9 | 8 | let lit = select(|x| match x { | ^^^ | help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified | 8 | let lit: Select<{closure@src/lib.rs:8:22: 8:25}, I> = select(|x| match x { | ++++++++++++++++++++++++++++++++++++++++++++ Some errors have detailed explanations: E0282, E0308. For more information about an error, try `rustc --explain E0282`. ```
2 parents ef3d6fd + 8a0e1ab commit 51a4664

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This is a regression test for #123630
2+
//
3+
// Prior to #123703 this was resulting in compiler suggesting add a type signature
4+
// for `lit` containing path to a file containing `Select` - something obviously invalid.
5+
6+
struct Select<F, I>(F, I);
7+
fn select<F, I>(filter: F) -> Select<F, I> {}
8+
//~^ 7:31: 7:43: mismatched types [E0308]
9+
10+
fn parser1() {
11+
let lit = select(|x| match x {
12+
//~^ 11:23: 11:24: type annotations needed [E0282]
13+
_ => (),
14+
});
15+
}
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/dont-suggest-path-names.rs:7:31
3+
|
4+
LL | fn select<F, I>(filter: F) -> Select<F, I> {}
5+
| ------ ^^^^^^^^^^^^ expected `Select<F, I>`, found `()`
6+
| |
7+
| implicitly returns `()` as its body has no tail or `return` expression
8+
|
9+
= note: expected struct `Select<F, I>`
10+
found unit type `()`
11+
12+
error[E0282]: type annotations needed
13+
--> $DIR/dont-suggest-path-names.rs:11:23
14+
|
15+
LL | let lit = select(|x| match x {
16+
| ^ - type must be known at this point
17+
|
18+
help: consider giving this closure parameter an explicit type
19+
|
20+
LL | let lit = select(|x: /* Type */| match x {
21+
| ++++++++++++
22+
23+
error: aborting due to 2 previous errors
24+
25+
Some errors have detailed explanations: E0282, E0308.
26+
For more information about an error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)