-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Add a note when suggesting to use Impl Trait #112088
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -856,6 +856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| format!("impl {}", all_bounds_str), | ||
| Applicability::MaybeIncorrect, | ||
| ); | ||
| err.note(format!("the type of `{}` is chosen by the caller", expected_ty_as_param.name)); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @compiler-errors Here found_ty_as_param should return the parameter found right, or am I understanding something wrong There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Converting found to string still does not return the type expected. |
||
|
|
||
| pub(in super::super) fn suggest_missing_break_or_return_expr( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this note adds much value in this context. Not exactly sure why, but something about the ordering or placement of this note feels to me like it's missing context.
In the
tests/ui/return/return-impl-trait-bad.stderrstderr below:My sense would be that "this type parameter" label could be replaced with the text above... Not sure how hard that is though.
Alternatively, "the type of
{}is chosen by the caller" should probably be extended to explain its significance. Maybe something along the lines of "and may be a type that is different than {(the other type mentioned)}"...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the message to explain its significance. However finding exactly where "this type parameter" is derived from and put into the message here is a bit hard. Do let me know if this is sufficient, or if not some more context on how I can find the construction of the above "this type parameter"