Git Product home page Git Product logo

Comments (1)

lunacookies avatar lunacookies commented on August 29, 2024 1

I only realized while I was typing up a reply to you that this wouldn’t quite work.

Let’s start from the simplest case – suppose we’ve just written p.start() somewhere randomly. With drop_bomb we get a panic at runtime, while with #[must_use] we get a warning telling us that the Marker value can’t just be discarded like that.

Next, suppose we’ve created a marker with let m = p.start(), but forget to call m.complete(p, kind) – with drop_bomb we again get a panic, but with #[must_use] we get a warning about m being an unused local. We would’ve gotten the same warning even without #[must_use], because from the compiler’s perspective the marker is “used” by it being stored in that m local, regardless of whether the local is ever accessed.

In this scenario, had we actually used m at some point (and never called Marker::complete), we wouldn’t get a warning with #[must_use] where we would’ve panicked with drop_bomb. In some complex scenarios you can actually end up needing to pass markers around to grammar functions, so it isn’t like this is a hypothetical. I’ve never had to do this in any of the parsers I’ve written, but it can happen.

Also there’s no need to apologize, I’m happy to see people are still finding this useful :D

from lang.

Related Issues (1)

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.