Skip to content

Add a regression test for #123630 #127160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/ui/suggestions/types/dont-suggest-path-names.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This is a regression test for #123630
//
// Prior to #123703 this was resulting in compiler suggesting add a type signature
// for `lit` containing path to a file containing `Select` - something obviously invalid.

struct Select<F, I>(F, I);
fn select<F, I>(filter: F) -> Select<F, I> {}
//~^ 7:31: 7:43: mismatched types [E0308]

fn parser1() {
let lit = select(|x| match x {
//~^ 11:23: 11:24: type annotations needed [E0282]
_ => (),
});
}

fn main() {}
26 changes: 26 additions & 0 deletions tests/ui/suggestions/types/dont-suggest-path-names.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error[E0308]: mismatched types
--> $DIR/dont-suggest-path-names.rs:7:31
|
LL | 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
--> $DIR/dont-suggest-path-names.rs:11:23
|
LL | let lit = select(|x| match x {
| ^ - type must be known at this point
|
help: consider giving this closure parameter an explicit type
|
LL | let lit = select(|x: /* Type */| match x {
| ++++++++++++

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0282, E0308.
For more information about an error, try `rustc --explain E0282`.
Loading