Comments (8)
@rustbot claim
from rust-clippy.
This seemingly already exists as a pedantic lint: https://rust-lang.github.io/rust-clippy/master/#/unchecked_duration_subtraction
@rustbot release-assignment
from rust-clippy.
TIL, yeah so I guess this can be closed then.
from rust-clippy.
Is pedantic with allow by default the right approach for it though? You basically should never subtract from Instant is what I think. In fact I was contemplating opening an issue directly in the Rust repo to possibly even deprecate it.
To me it should be in correctness and possibly even deny by default.
from rust-clippy.
Might as well make this change and see what people think. On the whole I agree.
@rustbot claim
from rust-clippy.
FWIW, this lint does differ in what you suggested by suggesting the use of checked_sub
instead of rewriting to use addition. We could either remove this suggestion and essentially suggest that the user rewrite the operation entirely, or keep the suggestion as-is and just change the category to correctness?
from rust-clippy.
Yeah there's definitely different solutions, but in general it should probably be avoided, because there's likely not a good way to recover from the checked operation failing. Not subtracting at all in case it fails is probably the wrong behavior. Rewriting in terms of an addition is generally the safer solution, just not one that clippy can offer automatically probably.
from rust-clippy.
See also #10061 and the linked zulip discussions. Becoming on by default again is not impossible but the help message would have to be improved to suggest avoiding the operation rather than replacing it with a slightly worse one
I think a concrete example for the description could also help, when I read things like "certain platforms" I assume it means uncommon ones but that may not be the case
from rust-clippy.
Related Issues (20)
- redundant_locals incorrectly emitted when binding in new local scope for early drop
- Print_* family of lints fail to match on `async_trait` functions with a return value
- indexing does not trigger missing_panics_doc HOT 4
- declare_interior_mutable_const fires for static pointer types
- Lint against Arc<impl Copy> HOT 1
- duplicated_attributes: false positive with apistos crate
- Clippy to fix warnings when they are converted to errors HOT 1
- Incorrectly printed suggestion for `map(<f>).unwrap_or(false)` on multiple lines HOT 1
- 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)
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.