Commit Graph

208 Commits

Author SHA1 Message Date
Alexey Shmalko 7bf33f00bf Fix comments around test harness generation 2019-04-17 12:02:04 +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
Vadim Petrochenkov 8371caf5ee syntax: Do not accidentally treat multi-segment meta-items as single-segment 2019-03-16 23:13:15 +03:00
Taiki Endo c360ba285c Cleanup imports 2019-02-13 00:31:51 +09:00
Taiki Endo 3216c7656a Rename rustc_errors dependency in rust 2018 crates 2019-02-13 00:28:52 +09:00
Oliver Scherer b681433b9d Use Rc<[Symbol]> instead of Vec<Symbol> to reduce # of allocs 2019-02-11 15:08:17 +01:00
Oliver Scherer d3c212c552 Require a list of features to allow in allow_internal_unstable 2019-02-11 15:08:16 +01:00
Taiki Endo 7bb082d27f libsyntax => 2018 2019-02-07 02:33:01 +09:00
Nicholas Nethercote 9fcb1658ab Overhaul syntax::fold::Folder.
This commit changes `syntax::fold::Folder` from a functional style
(where most methods take a `T` and produce a new `T`) to a more
imperative style (where most methods take and modify a `&mut T`), and
renames it `syntax::mut_visit::MutVisitor`.

The first benefit is speed. The functional style does not require any
reallocations, due to the use of `P::map` and
`MoveMap::move_{,flat_}map`. However, every field in the AST must be
overwritten; even those fields that are unchanged are overwritten with
the same value. This causes a lot of unnecessary memory writes. The
imperative style reduces instruction counts by 1--3% across a wide range
of workloads, particularly incremental workloads.

The second benefit is conciseness; the imperative style is usually more
concise. E.g. compare the old functional style:
```
fn fold_abc(&mut self, abc: ABC) {
    ABC {
        a: fold_a(abc.a),
        b: fold_b(abc.b),
        c: abc.c,
    }
}
```
with the imperative style:
```
fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
    visit_a(a);
    visit_b(b);
}
```
(The reductions get larger in more complex examples.)

Overall, the patch removes over 200 lines of code -- even though the new
code has more comments -- and a lot of the remaining lines have fewer
characters.

Some notes:

- The old style used methods called `fold_*`. The new style mostly uses
  methods called `visit_*`, but there are a few methods that map a `T`
  to something other than a `T`, which are called `flat_map_*` (`T` maps
  to multiple `T`s) or `filter_map_*` (`T` maps to 0 or 1 `T`s).

- `move_map.rs`/`MoveMap`/`move_map`/`move_flat_map` are renamed
  `map_in_place.rs`/`MapInPlace`/`map_in_place`/`flat_map_in_place` to
  reflect their slightly changed signatures.

- Although this commit renames the `fold` module as `mut_visit`, it
  keeps it in the `fold.rs` file, so as not to confuse git. The next
  commit will rename the file.
2019-02-06 09:06:27 +11:00
Vadim Petrochenkov 41c65992c5 Implement basic input validation for built-in attributes 2019-01-13 14:17:19 +03:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Alexander Regueiro ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Shotaro Yamada 3878d24ef6 Remove redundant clone 2018-10-26 12:07:39 +09:00
bors c4501a0f1d Auto merge of #52319 - tinco:issue_12590, r=pnkfelix
Track whether module declarations are inline (fixes #12590)

To track whether module declarations are inline I added a field `inline: bool` to `ast::Mod`. The main use case is for pretty to know whether it should render the items associated with the module, but perhaps there are use cases for this information to not be forgotten in the AST.
2018-09-27 09:51:12 +00:00
ljedrz 130a32fa72 Remove OneVector 2018-09-26 10:43:37 +02:00
Tinco Andringa ad5c0d49ff reintroduce inline to libsyntax test 2018-09-10 15:19:27 +02:00
Tinco Andringa c3afb16e16 Track whether module declarations are inline (fixes #12590) 2018-09-10 12:33:37 +02:00
John Renner 0593dc7e3c Move #[test_case] to a syntax extension 2018-09-04 22:33:23 -07:00
John Renner 9b27de41d4 Introduce Custom Test Frameworks 2018-09-04 22:33:00 -07:00
Igor Gutorov 4d81fe9243 Use optimized SmallVec implementation 2018-08-23 10:45:53 +03:00
Donato Sciarra 062bfbf39b mv codemap source_map 2018-08-19 23:01:01 +02:00
Donato Sciarra 82607d2cf3 mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
Donato Sciarra d6dcbcd4e1 mv FileMap SourceFile 2018-08-19 23:00:59 +02:00
Donato Sciarra c655473378 mv CodeMap SourceMap 2018-08-19 23:00:59 +02:00
ljedrz e5e6375352 Move SmallVec and ThinVec out of libsyntax 2018-08-13 22:11:57 +02:00
ljedrz 44d32d4413 Avoid unnecessary pattern matching against Option and Result 2018-08-07 10:24:27 +02:00
Vadim Petrochenkov 7d142c1e53 Address comments 2018-07-14 14:57:15 +03:00
Vadim Petrochenkov 4d1a30c92b Remove most of PartialEq impls from AST and HIR structures 2018-07-14 14:56:57 +03:00
ljedrz e28e4877a8 Deny bare trait objects in in src/libsyntax 2018-07-10 21:06:26 +02:00
Vadim Petrochenkov d347270e0c Implement #[macro_export(local_inner_macros)] 2018-06-27 13:10:16 +03:00
Vadim Petrochenkov 20ce91076a hygiene: Merge NameAndSpan into ExpnInfo 2018-06-23 21:53:24 +03:00
Taylor Cramer cf844b547d async await desugaring and tests 2018-06-21 22:36:36 -07:00
Without Boats 18ff7d091a Parse async fn header.
This is gated on edition 2018 & the `async_await` feature gate.

The parser will accept `async fn` and `async unsafe fn` as fn
items. Along the same lines as `const fn`, only `async unsafe fn`
is permitted, not `unsafe async fn`.The parser will not accept
`async` functions as trait methods.

To do a little code clean up, four fields of the function type
struct have been merged into the new `FnHeader` struct: constness,
asyncness, unsafety, and ABI.

Also, a small bug in HIR printing is fixed: it previously printed
`const unsafe fn` as `unsafe const fn`, which is grammatically
incorrect.
2018-06-21 22:29:47 -07:00
varkor e1d888c722 Remove methods from ast::GenericParam and ast::Generics 2018-06-20 12:21:08 +01:00
QuietMisdreavus 122b5b47c2 create multiple HIR items for a use statement 2018-06-14 17:47:28 -05:00
dylan_DPC 1048ae29a1 append unused variables with _ 2018-06-06 12:22:38 +05:30
dylan_DPC e8fd74a11d remove redundant match branch 2018-06-05 23:44:42 +05:30
dylan_DPC b78457f0fb Stabilize unit tests with non-() return type 2018-06-02 17:27:37 +05:30
Vadim Petrochenkov 1e4269cb83 Add Ident::as_str helper 2018-05-26 15:20:23 +03:00
Vadim Petrochenkov 640884bad0 Add edition to expansion info 2018-05-17 23:13:08 +03:00
Irina Popa a131c518ad Fixed tidy errors. 2018-04-26 17:49:24 +03:00
Irina Popa 04fa0e7bb3 rustc_target: move in syntax::abi and flip dependency. 2018-04-26 17:49:16 +03:00
Russell Cohen 14e5e0e9c9 Don't allow #[should_panic] with non-() tests 2018-04-23 07:13:29 -07: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
bors 14ac1b5faa Auto merge of #49279 - varkor:generated-closure-return-type, r=alexcrichton
Fix implicit closure return type generation for libsyntax

The `lambda` function for constructing closures in libsyntax was explicitly setting the return type to `_`, which resulted in incorrect corresponding syntax (as `|| -> _ x` is not valid, without the enclosing brackets). This meant the generated code, when printed, was invalid.

I also took the opportunity to slightly improve the generated code for the `RustcEncodable::encode` method for unit structs.

Fixes #42213.
2018-03-27 07:16:29 +00:00
kennytm 8d57071cbb Rollup merge of #49162 - tmandry:stabilize-termination-trait, r=nikomatsakis
Stabilize termination_trait, split out termination_trait_test

For #48453.

First time contribution, so I'd really appreciate any feedback on how this PR can be better.

Not sure exactly what kind of documentation update is needed. If there is no PR to update the reference, I can try doing that this week as I have time.
2018-03-25 01:26:32 +08:00
varkor 0d278ca6a8 Use FunctionRetTy::Default rather than an explicit TyKind::Infer for lambda-building
This prevents explicit `-> _` return type annotations for closures generated by `lambda`.
2018-03-22 15:55:57 +00:00
kennytm 8d3f3f0cac Rollup merge of #49117 - nivkner:fixme_fixup3, r=estebank
address some FIXME whose associated issues were marked as closed

part of #44366
2018-03-22 22:43:37 +08:00