-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Provide suggestion to convert numeric op LHS rather than unwrapping RHS #73195
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @varkor (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
Given a code ```rust fn foo(x: u8, y: u32) -> bool { x > y } fn main() {} ``` it could be more helpful to provide a suggestion to do "u32::from(x)" rather than "y.try_into().unwrap()", since the latter may panic. We do this by passing the LHS of a binary expression up the stack into the coercion checker. Closes rust-lang#73145
@bors r+ |
📌 Commit 0c02f8a has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#73033 (Fix #[thread_local] statics as asm! sym operands) - rust-lang#73036 (std: Enable atomic.fence emission on wasm32) - rust-lang#73163 (Add long error explanation for E0724) - rust-lang#73187 (Remove missed `cfg(bootstrap)`) - rust-lang#73195 (Provide suggestion to convert numeric op LHS rather than unwrapping RHS) - rust-lang#73247 (Add various Zulip notifications for prioritization) - rust-lang#73254 (Add comment about LocalDefId -> DefId) Failed merges: r? @ghost
Given a code
it could be more helpful to provide a suggestion to do "u32::from(x)"
rather than "y.try_into().unwrap()", since the latter may panic.
We do this by passing the LHS of a binary expression up the stack into
the coercion checker.
Closes #73145