Comments (5)
I would like to work on this. Can you please elaborate more about this issue ?
from rust-clippy.
So here we need to check for situations where we are casting before comparing, i.e. x as u32 > 200
or x as u32 < 0
, and the original type has a range such that the comparison will always be true or always be false.
...actually, this isn't really an easy bug since you have to look up the value of x
and ensure its not getting written to.
from rust-clippy.
#97 should be easier. Its a simple check_ty with most of the details explained in the last comment. There are some complications there but I'll explain how to handle them when we reach that stage.
from rust-clippy.
I don't think so. It should suffice matching a comparison where one of the operands is an ExprCast whose inner expression has a primitive type that is smaller than the comapred value (via expr_ty)
from rust-clippy.
Ah, I misunderstood the issue. In that case this isn't too hard.
from rust-clippy.
Related Issues (20)
- regression: unnecessary_lazy_evaluations not triggered on thiserror enum variant
- Add lints to encourage use of specialized assert macros
- `cast_possible_truncation` could check whether floating point values are manually truncated (round, floor, ceil...) prior to cast HOT 1
- Cargo clippy --fix not working with 1.80.1 HOT 2
- `module_inception` false positive for private sub-module HOT 4
- Lint use of functions with underscore-prefixed names HOT 2
- Flag unnecessary visiblity attributes on nested functions HOT 1
- Cargo clippy report warnings from macros when using quote_spanned
- `iter.map(...).any(identity)` into `iter.any(...)` HOT 1
- if/then to IntType::from suggestion
- Vec![] to slice suggestion in simple cases HOT 1
- iter::repeat(copy_value).take(n) => repeat_n(copy_value, n)
- deref_addrof can suggest adding UB HOT 3
- missing_safety_doc has questionable utility as a default HOT 1
- `use_self` with different lifetimes HOT 1
- Dead comparison lint
- Always true/always false comparison lint
- Suggest `Option::is_some_and(...)` for manual `matches!(x, Some(x) if ...)` implementations
- Improve the suggestion's syntax in `collapsible_match` check
- `collapsible_match` might produce an incorrect suggestion for nested fields, when `ref` / `mut` / `box` modifiers are used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-clippy.