Code Monkey home page Code Monkey logo

Comments (8)

Jacherr avatar Jacherr commented on August 23, 2024

@rustbot claim

from rust-clippy.

Jacherr avatar Jacherr commented on August 23, 2024

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.

CryZe avatar CryZe commented on August 23, 2024

TIL, yeah so I guess this can be closed then.

from rust-clippy.

CryZe avatar CryZe commented on August 23, 2024

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.

Jacherr avatar Jacherr commented on August 23, 2024

Might as well make this change and see what people think. On the whole I agree.

@rustbot claim

from rust-clippy.

Jacherr avatar Jacherr commented on August 23, 2024

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.

CryZe avatar CryZe commented on August 23, 2024

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.

Alexendoo avatar Alexendoo commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.