Closed
Description
I tried this code:
#![warn(impl_trait_overcaptures)]
pub fn f(x: &i32) -> &impl Clone {
x
}
I expected to see this happen: Provides a valid suggestion that is -> &(impl Clone + use<>)
with parentheses to avoid ambiguity.
Instead, this happened: Provides a suggestion that includes &impl Clone + use<>
which fails to parse with:
error: ambiguous `+` in a type
--> src/main.rs:3:23
|
3 | pub fn f(x: &i32) -> &impl Clone + use<> {
| ^^^^^^^^^^^^^^^^^^
|
help: try adding parentheses
|
3 | pub fn f(x: &i32) -> &(impl Clone + use<>) {
| + +
Meta
rustc --version --verbose
:
rustc 1.84.0-nightly (b91a3a056 2024-11-07)
binary: rustc
commit-hash: b91a3a05609a46f73d23e0995ae7ebb4a4f429a5
commit-date: 2024-11-07
host: aarch64-apple-darwin
release: 1.84.0-nightly
LLVM version: 19.1.3
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The 2024 editionArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: An error or lint that should account for edition differences.Diagnostics: A structured suggestion resulting in incorrect code.Lint: impl_trait_overcapturesRelevant to the compiler team, which will review and decide on the PR/issue.