Comments (2)
This syn::Generics
includes a syn::Lifetime
that you created yourself right? It looks like the Lifetimes parsed by syn always include the apostrophe.
I want the apostrophe to be included in the Lifetime name because this is how libsyntax does it. Here is what I did to check:
Create main.rs:
fn f<'a>() {}
Run rustc -Z ast-json main.rs
. The following appears in the output:
"lifetimes": [
{
"attrs": {
"_field0": null
},
"lifetime": {
"id": 5,
"span": {
"lo": 5,
"hi": 7
},
"name": "'a"
},
"bounds": []
}
],
The lifetime is "'a"
not just "a"
.
Can you think of a better way to handle this? Maybe it should panic if there is a lifetime that does not start with apostrophe? Or maybe add the apostrophe if one is missing? Or maybe just document that user is responsible for the apostrophe?
from syn.
Ah! I never noticed the lifetime name included the '
. syn
behavior seems legit then.
Some documentation would be enough I guess. Maybe a panic in syn::Lifetime::new
if there is no '
.
Thanks!
from syn.
Related Issues (20)
- Add `parse_macro_input2` for `proc_macro2::TokenStream` HOT 1
- Incorrect line column information when parsing from string HOT 2
- Why is Spanned sealed? HOT 6
- "unexpected token" error even when all input has been parsed HOT 4
- dump_syntax doesn't give span info for lex errors
- How to avoid from the specific error when parsing nested meta? HOT 3
- Add `parse2_macro_input` (or equivalent) parsing macro using `syn::parse2` instead of `syn::parse` HOT 2
- Bare trait objects HOT 2
- attribute macro has no access to attributes defined before it HOT 1
- Parse `builtin #` syntax
- Syn parses `1f32` as `syn::Lit::Int`. HOT 3
- How to save syn::File to disk? HOT 2
- span.source_text() broken HOT 1
- Keywords in meta path positions cause parsing errors HOT 7
- `syn::meta::parser` should not fail on empty meta list
- How to use the parse_file or parse_str function? HOT 2
- Can't parse_macro_input with what used to be AttributeArgs HOT 3
- Group spans don't round-trip when run under rust-analyzer HOT 1
- QSelf isn't spanned HOT 2
- Upgrade from syn 1 to 2 breaks import 'ParseQuote' HOT 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 syn.