Comments (3)
I made the change to Result
because even though we don't need it for structs and enums, we do need it when parsing attributes that contains paths or where-clauses, and it was better to be consistent.
from syn.
For the Macros 1.1 use case the compiler guarantees that the input will be a valid struct or enum so the panics "can't happen," and besides, the way Macros 1.1 implementations signal failure is by panicking. From the RFC:
If a macro cannot process the input token stream, it is expected to panic for now, although eventually it will call methods in
rustc_macro
to provide more structured errors.
The way I think about it, panics are for situations where a program realizes it contains a bug, and Results are for expected failures. In this case if syn fails to parse an input, that indicates a bug.
If you disagree or have a different use case, I would be open to returning a Result as long as it is not nom-specific, allowing us to swap out the implementation later (like LALRPOP or something else).
from syn.
I added you as a collaborator on the repo and a crate owner on crates.io so you can make any changes you need. I don't want me to be a bottleneck on getting Diesel running. We can sort out the API later.
from syn.
Related Issues (20)
- Scope when parsing delimited group content does not necessarily belong to the right Group token
- Parsing function using `parse` referencing enum fails HOT 1
- Parse attributes on where-predicates
- Deny keyword lifetimes pre-expansion
- Parse unsafe attributes
- Parse unnamed C varargs within function pointer types HOT 1
- [Feature Request] Add support for incomplete expression and statement HOT 1
- FieldMutability is missing Parse and ToTokens HOT 1
- Breaking change to `Generics::lifetimes` in v2.0.73 HOT 8
- ExprPath to_tokens() output can't be parsed as an expression due to missing turbofish
- A
- Documentation discrepancy between `parse` and `parse2`
- Generics::split_for_impl can cause clippy::multiple_bound_locations HOT 2
- Error parsing `Option<()>` and `Result<(), ()>` literals in `syn::parse_macro_input`: `unexpected end of input, expected an expression` HOT 1
- test/debug directory is .gitignored by cargo vendor causing friction when placing vendored crates in git HOT 3
- Parse raw lifetimes
- Can't parse Stmt::Expr
- Parsing invalid source code results in stack overflow HOT 5
- Potential false-positive of rustdoc::broken_intra_doc_links lint
- Unable to create `Token` trait object
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 syn.