Closed
Bug 1488003
Opened 6 years ago
Closed 5 years ago
webdriver: Cast i32 to i64 using "::from" instead of "as"
Categories
(Testing :: geckodriver, enhancement, P2)
Testing
geckodriver
Tracking
(Not tracked)
RESOLVED
INCOMPLETE
People
(Reporter: ato, Assigned: ato)
Details
Attachments
(1 file)
1.87 KB,
patch
|
Details | Diff | Splinter Review |
To ensure we don’t perform a lossy cast from i32 to i64, we should use > i64::from(x) rather than > x as i64
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → ato
Status: NEW → ASSIGNED
Assignee | ||
Comment 1•6 years ago
|
||
Attachment #9005829 -
Flags: review?(hskupin)
Comment 2•6 years ago
|
||
Comment on attachment 9005829 [details] [diff] [review] webdriver: fix lossy i64 cast Review of attachment 9005829 [details] [diff] [review]: ----------------------------------------------------------------- ::: testing/webdriver/src/command.rs @@ +578,3 @@ > let value = match opt { > Some(n) => { > + if n < i64::from(i32::min_value()) || n > i64::from(i32::max_value()) { Mind to explain me when this can be lossy? I can agree with i64->i32, but what's broken for i32->i64?
Attachment #9005829 -
Flags: review?(hskupin)
Assignee | ||
Comment 3•6 years ago
|
||
The warning from clippy is this:
> warning: casting i32 to i64 may become silently lossy if types change
> --> testing/webdriver/src/command.rs:576:20
> |
> 576 | if n < i32::min_value() as i64 || n > i32::max_value() as i64 {
> | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i64::from(i32::min_value())`
> |
> = note: #[warn(clippy::cast_lossless)] on by default
> = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#clippy::cast_lossless
I think my commit message is overstating what it’s fixing: it’s in
fact not fixing a lossy cast, but a potential future accident if
the type itself were to change.
Functionally speaking, I think the patch is equivalent.
Assignee | ||
Updated•6 years ago
|
Priority: -- → P2
Assignee | ||
Updated•6 years ago
|
Status: ASSIGNED → NEW
Assignee | ||
Comment 4•5 years ago
|
||
I think we should probably have one bug to resolve all the outstanding clippy lint violations for geckodriver and its in-tree dependencies.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•