259 Commits

Author SHA1 Message Date
Mark Rousskov
7e3791469f Replace src: &mut dyn Read with String 2019-07-10 07:12:28 -04:00
Matthew Jasper
db6f77f0d7 Add arm ids for -Zunpretty=hir,identified 2019-07-06 21:56:03 +01:00
Mazdak Farrokhzad
2e86c006f7
Rollup merge of #62168 - ljedrz:the_culmination_of_hiridification, r=Zoxc
The (almost) culmination of HirIdification

It's finally over.

This PR removes old `FIXME`s and renames some functions so that the `HirId` variant has the shorter name.
All that remains (and rightfully so) is stuff in `resolve`, `save_analysis` and (as far as I can tell) in a few places where we can't replace `NodeId` with `HirId`.
2019-07-05 20:26:56 +02:00
bors
f119bf2761 Auto merge of #62099 - Mark-Simulacrum:syntax-print-clean-2, r=eddyb
Remove io::Result from syntax::print

Since we're now writing directly to the vector, there's no need to
thread results through the whole printing infrastructure
2019-07-05 06:55:48 +00:00
ljedrz
37d7e1f22a rename hir::map::local_def_id_from_hir_id to local_def_id 2019-07-04 12:53:12 +02:00
ljedrz
4f7ba515c2 rename hir::map::local_def_id to local_def_id_from_node_id 2019-07-04 12:29:26 +02:00
Jeremy Stucki
ec711767a7
Remove needless lifetimes 2019-07-03 10:01:02 +02:00
Mark Rousskov
da5c835c8b Remove io::Result from syntax::print
Since we're now writing directly to the vector, there's no need to
thread results through the whole printing infrastructure
2019-06-29 09:10:17 -04:00
Mark Rousskov
1aff8af213 Replace pretty-printer Box<dyn Write> with &mut String 2019-06-29 09:10:15 -04:00
ljedrz
d82a12f64f HirIdify driver::pretty::HirPrinterSupport::node_path 2019-06-24 10:03:37 +02:00
ljedrz
f05cbc98f8 HIR: rename find_by_hir_id to find 2019-06-24 09:58:49 +02:00
ljedrz
90de9edce5 HIR: remove the NodeId find 2019-06-24 09:55:11 +02:00
ljedrz
d08bd72e97 HIR: rename get_parent_node_by_hir_id to get_parent_node 2019-06-24 09:46:38 +02:00
ljedrz
73cb9ab526 rename hir::map::get_by_hir_id to get 2019-06-20 12:50:06 +02:00
ljedrz
a64456e48e remove hir::map::get 2019-06-20 12:47:26 +02:00
ljedrz
ae72c91247 make blocks::Code work with HirId 2019-06-20 12:47:26 +02:00
Eduard-Mihai Burtescu
b25b466a88 rustc: remove 'x: 'y bounds (except from comments/strings). 2019-06-18 18:10:21 +03:00
ljedrz
d996c4d5a3 remove _by_hir_id if there is no NodeId counterpart 2019-06-17 18:57:21 +02:00
ljedrz
61964d9732 replace some uses of NodeId with HirId 2019-06-17 18:57:20 +02:00
Eduard-Mihai Burtescu
f3f9d6dfd9 Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +03:00
Eduard-Mihai Burtescu
fff08cb043 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-12 13:38:28 +03:00
Eduard-Mihai Burtescu
17cdd356da rustc: replace TyCtxt<'tcx, 'gcx, 'tcx> with TyCtxt<'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
2441253508 Fix fallout from deny(unused_lifetimes). 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
37799a5552 rustc: replace TyCtxt<'a, 'gcx, 'tcx> with TyCtxt<'tcx, 'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Fabian Drinck
b18de52080 Declare DefIndex with the newtype_index macro 2019-05-18 13:19:33 +02:00
Vadim Petrochenkov
a5b3f33cb9 Eliminate comments::Literal 2019-05-11 14:24:21 +03:00
Vadim Petrochenkov
ee6d315200 cleanup: Remove DefIndexAddressSpace 2019-05-09 00:46:38 +03:00
John Kåre Alsaker
df5a0111be Optimize HIR map 2019-05-08 12:18:09 +02:00
Fabian Drinck
164988c129 Remove def_path_from_id, node_id_to_string 2019-05-04 10:02:59 +02:00
Taiki Endo
24a0caec83 librustc_driver => 2018 2019-03-27 05:35:18 +09:00
Matthew Jasper
64303189f0 Use a valid name for graphviz graphs 2019-03-17 10:36:10 +00:00
Eduard-Mihai Burtescu
27ddf2cec8 rustc: replace node_path_str with uses of def_path_str. 2019-03-15 13:25:10 +02:00
John Kåre Alsaker
51938c61f6 Make the rustc driver and interface demand driven 2019-03-10 04:49:45 +01:00
ljedrz
50b8bc8c8c hir: remove NodeId from Pat and FieldPat 2019-03-02 07:48:52 +01:00
ljedrz
77fa041fc1 hir: remove NodeId from Item 2019-03-02 07:48:52 +01:00
John Kåre Alsaker
23a51f91c9 Introduce rustc_interface and move some methods there 2019-02-28 19:30:31 +01:00
ljedrz
d7ced1dd5a hir: remove NodeId from Expr 2019-02-24 17:09:37 +01:00
ljedrz
021a140dcd hir: remove NodeId from Block 2019-02-24 17:09:26 +01: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
Mazdak Farrokhzad
bce56888e9
Rollup merge of #57598 - h-michael:unpretty-help, r=oli-obk
Add missing unpretty option help message

There are some missing help messages that is printed `ructc -Zunpretty help` and receiving invalid option.

related with #16419, #45721, #21085, #31916
2019-01-19 14:21:19 +01:00
Igor Matuszewski
6f1d06d219 Querify glob map usage (last use of CrateAnalysis) 2019-01-17 10:40:22 +01:00
Hirokazu Hata
260fb31fd5 Add missing unpretty option help message 2019-01-15 18:32:18 +09:00
Vadim Petrochenkov
4ac592516f Get rid of Block::recovered 2018-12-27 15:51:36 +03:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
John Kåre Alsaker
1f1c575c5f Make the 'a lifetime on TyCtxt useless 2018-12-13 02:54:43 +01:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
John Kåre Alsaker
a70babed03 Use a function to access the Hir map to be able to turn it into a query later 2018-12-06 17:24:36 +01:00
Nicholas Nethercote
787959c20d Use Cow in Token::String.
`Printer::word` takes a `&str` and converts it into a `String`, which
causes an allocation. But that allocation is rarely necessary, because
`&str` is almost always a `&'static str` or a `String` that won't be
used again.

This commit changes `Token::String` so it holds a `Cow<'static, str>`
instead of a `String`, which avoids a lot of allocations.
2018-11-29 17:12:18 +11:00
Oliver Scherer
a1d89266e5 Turn HirLocalId into a newtype_index 2018-11-12 10:29:53 +01:00
Oliver Scherer
39a0969e64 Make NodeId a newtype_index to enable niche optimizations 2018-11-12 10:29:53 +01:00