Comments (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
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 lang.