-
Notifications
You must be signed in to change notification settings - Fork 14k
Point out the known type when field doesn't satisfy bound #38150
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 |
|---|---|---|
|
|
@@ -487,13 +487,29 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { | |
| } else { | ||
| let trait_ref = trait_predicate.to_poly_trait_ref(); | ||
|
|
||
| let mut err = struct_span_err!(self.tcx.sess, span, E0277, | ||
| "the trait bound `{}` is not satisfied", | ||
| trait_ref.to_predicate()); | ||
| err.span_label(span, &format!("the trait `{}` is not implemented \ | ||
| for `{}`", | ||
| trait_ref, | ||
| trait_ref.self_ty())); | ||
| let (post_message, pre_message) = | ||
| if let ObligationCauseCode::BuiltinDerivedObligation(ref data) | ||
| = obligation.cause.code { | ||
| let parent_trait_ref = self.resolve_type_vars_if_possible( | ||
| &data.parent_trait_ref); | ||
| (format!(" in `{}`", parent_trait_ref.0.self_ty()), | ||
|
||
| format!("within `{}`, ", parent_trait_ref.0.self_ty())) | ||
| } else { | ||
| (String::new(), String::new()) | ||
| }; | ||
| let mut err = struct_span_err!( | ||
| self.tcx.sess, | ||
| span, | ||
| E0277, | ||
| "the trait bound `{}` is not satisfied{}", | ||
| trait_ref.to_predicate(), | ||
| post_message); | ||
| err.span_label(span, | ||
| &format!("{}the trait `{}` is not \ | ||
| implemented for `{}`", | ||
| pre_message, | ||
| trait_ref, | ||
| trait_ref.self_ty())); | ||
|
|
||
| // Try to report a help message | ||
|
|
||
|
|
||
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.
Missing an indent level here.
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.
Is it? the
if letis part of the previous line, the only reason is below is because I couldn't get to fit nicely in under 100 chars. In this were to fit in one line it would be:I don't see why then line 493 would have to have double indentation. :)
I agree that it is slightly confusing as it is now, but haven't come up with a better way of presenting this.
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.
Oh indeed, you're absolutely right, my bad!
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.
one better way might be using
match:)