Skip to content

Add an explanatory note when suggesting to use impl Trait instead of a type parameter #104755

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

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
format!("impl {}", all_bounds_str),
Applicability::MaybeIncorrect,
);
err.note("the caller chooses the value of a type parameter");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like..

the type of T is chosen by the caller

..would be clearer?

I'm not keen on describing type parameters as having a "value", I think that could lead to confusion.

}

pub(in super::super) fn suggest_missing_break_or_return_expr(
Expand Down