-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use more precise span for E0282 in cast expressions #85971
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
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
@@ -995,7 +995,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |||
} else { | |||
// Defer other checks until we're done type checking. | |||
let mut deferred_cast_checks = self.deferred_cast_checks.borrow_mut(); | |||
match cast::CastCheck::new(self, e, t_expr, t_cast, t.span, expr.span) { | |||
match cast::CastCheck::new(self, e, t_expr, e.span, t_cast, t.span, expr.span) { |
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.
You should be able to remove the new Span
parameter, and just use self.expr.span
inside of CastCheck
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.
You are right; it seems that I got confused with e.span
and expr.span
. Thanks for pointing this out, I have fixed it now.
r? @davidtwco |
@bors r+ |
📌 Commit 74d1bd2 has been approved by |
☀️ Test successful - checks-actions |
This pull request fixes #85586. The example code given there:
currently produces
even though the type of the entire cast expression quite clearly should be
usize
. The error is in the cast's left-hand side, which is made explicit by the changes in this PR: