-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This code produces invalid suggestion:
fn foo(x: impl Clone) {}
fn gen<T>() -> T { todo!() }
fn main() {
foo(gen());
}
error[E0283]: type annotations needed
--> src/main.rs:5:5
|
1 | fn foo(x: impl Clone) {}
| ----- required by this bound in `foo`
...
5 | foo(gen());
| ^^^ cannot infer type for type parameter `impl Clone` declared on the function `foo`
|
= note: cannot satisfy `_: Clone`
help: consider specifying the type argument in the function call
|
5 | foo::<impl Clone>(gen());
| ^^^^^^^^^^^^^^
Also this code:
fn foo<const N: usize>(x: impl Clone) {}
fn gen<T>() -> T { todo!() }
fn main() {
foo(gen());
}
error[E0283]: type annotations needed
--> src/main.rs:5:5
|
1 | fn foo<const N: usize>(x: impl Clone) {}
| ----- required by this bound in `foo`
...
5 | foo(gen());
| ^^^ cannot infer type for type parameter `impl Clone` declared on the function `foo`
|
= note: cannot satisfy `_: Clone`
help: consider specifying the type arguments in the function call
|
5 | foo::<N, impl Clone>(gen());
| ^^^^^^^^^^^^^^^^^
None of them produce valid suggestion, as what it suggests will produce error[E0632]: cannot provide explicit generic arguments when impl Trait is used in argument position
.
Related to #83606.
@rustbot label: +A-diagnostics +D-invalid-suggestion +T-compiler
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.