Commit Graph

179 Commits

Author SHA1 Message Date
Vadim Petrochenkov 67ce3f4589 syntax: Switch function parameter order in TokenTree::token 2019-06-06 14:04:02 +03:00
Vadim Petrochenkov aa6fba98ae syntax: Use Token in Parser 2019-06-06 14:04:02 +03:00
Vadim Petrochenkov e0127dbf81 syntax: Use Token in TokenTree::Token 2019-06-06 14:03:15 +03:00
Nicholas Nethercote 17a8aff20a Use SmallVec in TokenStreamBuilder.
This reduces by 12% the number of allocations done for a "clean
incremental" of `webrender_api`, which reduces the instruction count by
about 0.5%.

It also reduces instruction counts by up to 1.4% across a range of
rustc-perf benchmark runs.
2019-03-29 09:32:58 +11:00
Vadim Petrochenkov 2fd4cbb3f2 Fix rebase 2019-03-16 23:14:42 +03:00
Vadim Petrochenkov 0cf96131f4 Refactor away NestedMetaItemKind
Remove methods `Attribute::span` and `MetaItem::span` duplicating public fields
2019-03-16 23:14:42 +03:00
Vadim Petrochenkov 63116d313d Rename MetaItem::ident to MetaItem::path 2019-03-16 23:13:15 +03:00
Esteban Küber 02eb523d91 Surround found token with ` 2019-03-06 14:45:23 -08:00
Esteban Küber 669be1a0a6 On incorrect cfg literal/identifier, point at the right span 2019-03-05 19:05:03 -08:00
Vadim Petrochenkov 8e1b5d897a Restrict value in key-value attributes to literals 2019-02-25 22:40:38 +03:00
Nicholas Nethercote f8801f3bf6 Remove LazyTokenStream.
It's present within `Token::Interpolated` as an optimization, so that if
a nonterminal is converted to a `TokenStream` multiple times, the
first-computed value is saved and reused.

But in practice it's not needed. `interpolated_to_tokenstream()` is a
cold function: it's only called a few dozen times while compiling rustc
itself, and a few hundred times across the entire `rustc-perf` suite.
Furthermore, when it is called, it is almost always the first
conversion, so no benefit is gained from it.

So this commit removes `LazyTokenStream`, along with the now-unnecessary
`Token::interpolated()`.

As well as a significant simplification, the removal speeds things up
slightly, mostly due to not having to `drop` the `LazyTokenStream`
instances.
2019-02-18 09:46:33 +11:00
Taiki Endo 7bb082d27f libsyntax => 2018 2019-02-07 02:33:01 +09:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Nicholas Nethercote e80c7ddb05 Rename TokenStream::concat and remove TokenStream::concat_rc_vec.
`TokenStream::new` is a better name for the former, and the latter is
now just equivalent to `TokenStream::Stream`.
2018-12-12 20:36:00 +11:00
ljedrz d0c64bb296 cleanup: remove static lifetimes from consts 2018-12-04 12:46:10 +01:00
Donato Sciarra 82607d2cf3 mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
Vadim Petrochenkov 097c40cf6e syntax: Enforce attribute grammar in the parser 2018-08-15 00:05:55 +03:00
Vadim Petrochenkov 4d1a30c92b Remove most of PartialEq impls from AST and HIR structures 2018-07-14 14:56:57 +03:00
Mark Simulacrum 60058e5dbe Crate-ify and delete unused code in syntax::parse 2018-06-09 16:57:19 -06:00
flip1995 121abd0599 make it compile again 2018-05-02 12:05:13 +02:00
Seiichi Uchida 759bd01e03 Allow Path for name of MetaItem 2018-05-02 11:32:34 +02:00
Vadim Petrochenkov 3a30bad6de Use Ident instead of Name in MetaItem 2018-04-06 11:52:16 +03:00
Vadim Petrochenkov b3b5ef186c Remove more duplicated spans 2018-04-06 11:50:49 +03:00
csmoe 9f5a356c1d improve attribute trailing semicolon error 2018-03-17 21:23:41 +08:00
Zack M. Davis 42ef3f1784 edit and fix bad spacing of inner-attribute-not-allowed note
This multiline string literal was missing a backslash, leaving an awkward
newline and 35 spaces in the middle of the message.

But while we're here, the existing message seems kind of long in comparison to
similar notes: to cut it down, we excise the mentions of doc comments, which
seems sensible because we know that this erroneous attribute is not a doc
comment (notice the `is_sugared_doc: false` at the end of the function; if it
had been a doc comment, that error would get set in the `token::DocComment`
match branch of `parse_outer_attributes`).
2017-10-30 17:11:33 -07:00
bors e6ab51165a Auto merge of #43904 - topecongiro:libsyntax/parse-attr, r=petrochenkov
Eat open paren when parsing list in libsyntax/parse/attr.rs

This PR adds a small refactoring:
```diff
      pub fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> {
         Ok(if self.eat(&token::Eq) {
             ast::MetaItemKind::NameValue(self.parse_unsuffixed_lit()?)
-        } else if self.token == token::OpenDelim(token::Paren) {
+        } else if self.eat(&token::OpenDelim(token::Paren)) {
             ast::MetaItemKind::List(self.parse_meta_seq()?)
         } else {
-            self.eat(&token::OpenDelim(token::Paren));
             ast::MetaItemKind::Word
         })
     }
```
in `parse_meta_item_kind()`, the parser calls `self.eat(&token::OpenDelim(token::Paren));` before returning `ast::MetaItemKind::Word` just to add `(` to expected token. It seems more natural to eat the paren when parsing `ast::MetaItemKind::List`.
2017-08-18 08:17:45 +00:00
Seiichi Uchida 0bfe4178af Eat open paren when parsing list 2017-08-16 23:40:06 +09:00
Zack M. Davis 1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Jeffrey Seyfried 7d493bdd2a Add LazyTokenStream. 2017-06-26 02:06:31 +00:00
Andre Bogus a9c163ebe9 Fix some clippy warnings in libsyntax
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-05-12 20:05:39 +02:00
Jeffrey Seyfried f08d5ad4c5 Refactor how spans are combined in the parser. 2017-03-29 11:17:59 +00:00
Jeffrey Seyfried 839c2860cc Liberalize attributes. 2017-03-14 04:39:21 +00:00
Jeffrey Seyfried 68c1cc68b4 Refactor Attribute to use Path and TokenStream instead of MetaItem. 2017-03-14 04:03:43 +00:00
Jeffrey Seyfried e85a0d70b8 Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Jeffrey Seyfried f177a00ac9 Refactor P<ast::MetaItem> -> ast::MetaItem. 2016-11-20 12:36:41 +00:00
Jeffrey Seyfried e97686d048 Move MetaItemKind's Name to a field of MetaItem. 2016-11-20 12:36:30 +00:00
Jeffrey Seyfried a2626410d7 Refactor MetaItemKind to use Names instead of InternedStrings. 2016-11-20 11:46:06 +00:00
Jeffrey Seyfried 3ea2bc4e93 Refactor away ast::Attribute_. 2016-11-20 11:46:00 +00:00
Jeffrey Seyfried eb3ac29a10 Reduce the size of Token and make it cheaper to clone by refactoring
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-11-03 23:48:24 +00:00
Nicholas Nethercote 2747923c27 Rename Parser::last_span as prev_span.
This is a [breaking-change] for libsyntax.
2016-10-05 08:53:18 +11:00
Mikhail Modin 82639d4f04 fix top level attr spans 2016-09-16 21:44:15 +03:00
Mikhail Modin fb85dd398b fix span for errors E0537, E0535 & E0536 2016-09-10 10:21:13 +03:00
Sergio Benitez 8250a26b5b Implement RFC#1559: allow all literals in attributes. 2016-08-25 13:25:22 -07:00
Aravind Gollakota ff95ba3a8c syntax: Better error message for inner attr following doc comment 2016-07-15 21:02:53 -07:00
Zack M. Davis d37edef9dd prefer if let to match with None => {} arm in some places
This is a spiritual succesor to #34268/8531d581, in which we replaced a
number of matches of None to the unit value with `if let` conditionals
where it was judged that this made for clearer/simpler code (as would be
recommended by Manishearth/rust-clippy's `single_match` lint). The same
rationale applies to matches of None to the empty block.
2016-07-03 16:27:02 -07:00
Jonathan Turner 6ae3502134 Move errors from libsyntax to its own crate 2016-06-23 08:07:35 -04:00
Georg Brandl 72560e1403 parser: show a helpful note on unexpected inner comment
Fixes: #30318.
2016-05-03 17:53:23 +02:00
Niko Matsakis 489a6c95bf replace fileline_{help,note} with {help,note}
The extra filename and line was mainly there to keep the indentation
relative to the main snippet; now that this doesn't include
filename/line-number as a prefix, it is distracted.
2016-05-02 11:49:23 -04:00
Jorge Aparicio 0f02309e4b try! -> ?
Automated conversion using the untry tool [1] and the following command:

```
$ find -name '*.rs' -type f | xargs untry
```

at the root of the Rust repo.

[1]: https://github.com/japaric/untry
2016-03-22 22:01:37 -05:00
Corey Farwell bc2f5e2612 Use associated functions for libsyntax SepSeq constructors. 2016-02-22 23:24:42 -05:00