about summary refs log tree commit diff
path: root/src/libsyntax/util
AgeCommit message (Collapse)AuthorLines
2019-02-07fix testEsteban Küber-2/+5
2019-02-07libsyntax => 2018Taiki Endo-22/+23
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-21/+8
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-01-24Remove quote_*! macros and associated APIsMark Simulacrum-1/+1
2018-12-27AST/HIR: Introduce `ExprKind::Err` for better error recovery in the front-endVadim Petrochenkov-1/+3
2018-12-25Remove licensesMark Rousskov-49/+0
2018-12-12Remove `RcVec` and `RcSlice`.Nicholas Nethercote-154/+0
They're both unused now.
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-2/+2
2018-12-07Rollup merge of #56516 - frewsxcv:frewsxcv-eq, r=Mark-Simulacrumkennytm-1/+1
Replace usages of `..i + 1` ranges with `..=i`. Before this change we were using old computer code techniques. After this change we use the new and improved computer code techniques.
2018-12-04Replace usages of `..i + 1` ranges with `..=i`.Corey Farwell-1/+1
2018-12-04Fix testShotaro Yamada-1/+2
2018-10-28Provide specific label for patern parsing errorEsteban Küber-1/+1
2018-09-26Remove OneVectorljedrz-2/+2
2018-09-11Add some unit tests for find_best_match_for_namePhilipp Hansch-2/+40
There were only some UI tests that covered this function. Since there's more diagnostic work going on, I think it makes sense to have this unit tested.
2018-08-23Auto merge of #52602 - scottmcm:tryblock-expr, r=nikomatsakisbors-2/+2
Implement try block expressions I noticed that `try` wasn't a keyword yet in Rust 2018, so... ~~Fix​es https://github.com/rust-lang/rust/issues/52604~~ That was fixed by PR https://github.com/rust-lang/rust/pull/53135 cc https://github.com/rust-lang/rust/issues/31436 https://github.com/rust-lang/rust/issues/50412
2018-08-19Rename `Catch` variants to `TryBlock`Scott McMurray-2/+2
(Not `Try` since `QuestionMark` is using that.)
2018-08-19mv codemap() source_map()Donato Sciarra-1/+1
2018-08-19mv (mod) codemap source_mapDonato Sciarra-1/+1
2018-08-19mv filemap source_fileDonato Sciarra-3/+3
2018-08-16Auto merge of #53304 - dtolnay:extend, r=dtolnaybors-0/+90
TokenStream::extend Two new insta-stable impls in libproc_macro: ```rust impl Extend<TokenTree> for TokenStream impl Extend<TokenStream> for TokenStream ``` `proc_macro::TokenStream` already implements `FromIterator<TokenTree>` and `FromIterator<TokenStream>` so I elected to support the same input types for `Extend`. **This commit reduces compile time of Serde derives by 60% (takes less than half as long to compile)** as measured by building our test suite: ```console $ git clone https://github.com/serde-rs/serde $ cd serde/test_suite $ cargo check --tests --features proc-macro2/nightly $ rm -f ../target/debug/deps/libtest_*.rmeta $ time cargo check --tests --features proc-macro2/nightly Before: 20.8 seconds After: 8.6 seconds ``` r? @alexcrichton
2018-08-13Address review of RcVecDavid Tolnay-10/+5
2018-08-13Move SmallVec and ThinVec out of libsyntaxljedrz-143/+2
2018-08-12TokenStream::extendDavid Tolnay-0/+95
2018-07-14Remove some tests using AST comparisons, fix other testsVadim Petrochenkov-8/+0
2018-07-14Remove most of `PartialEq` impls from AST and HIR structuresVadim Petrochenkov-17/+3
2018-06-21async await desugaring and testsTaylor Cramer-0/+2
2018-06-20Rename ParamBound(s) to GenericBound(s)varkor-1/+1
2018-06-20Use ParamBounds in WhereRegionPredicatevarkor-2/+2
2018-06-20Lift bounds into GenericParamvarkor-1/+1
2018-06-20Rename structures in astvarkor-1/+1
2018-06-20Rename ast::GenericParam and ast::GenericArgvarkor-1/+1
It's so confusing to have everything having the same name, at least while refactoring.
2018-06-20Rename PathParameter(s) to GenericArg(s)varkor-2/+2
2018-05-24restore emplacement syntax (obsolete)Niko Matsakis-5/+11
2018-04-12AST/HIR: Merge field access expressions for named and numeric fieldsVadim Petrochenkov-3/+0
2018-04-06Remove more duplicated spansVadim Petrochenkov-2/+2
2018-04-03Remove all unstable placement featuresAidan Hobson Sayers-10/+4
Closes #22181, #27779
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-3/+3
2018-01-15Move `ExprPrecedence` to `libsyntax/util/parser.rs`Esteban Küber-0/+126
2018-01-15Use single source of truth for expr precedenceEsteban Küber-61/+1
Introduce a new unified type that holds the expression precedence for both AST and HIR nodes.
2017-12-21Add GenericParam, refactor Generics in ast, hir, rustdocJonas Platte-4/+4
The Generics now contain one Vec of an enum for the generic parameters, rather than two separate Vec's for lifetime and type parameters. Additionally, places that previously used Vec<LifetimeDef> now use Vec<GenericParam> instead.
2017-12-14Use PathBuf instead of String where applicableOliver Schneider-2/+4
2017-12-02Auto merge of #46347 - raventid:did-you-mean-increase-accuracy, r=estebankbors-5/+27
Add case insensitive comparison, besides Levenstein for DYM Closes #46332 Draft version. The idea is that Levenstein does not work for some cases when we have multiple equal weights for strings. I didn't understand the case with `if found != name => Some(found)` so it means that new code does not work correctly yet. At least now I think that we might return all maximal weights from levenstein and think about next cases in priority order: 1) There is exact match -> None 2) There is exact match, but case insensitive -> Some(match) 3) There is some match from levenstein -> Some(matches.take_any) 4) There is no match -> None @estebank WDYT?
2017-12-01move comparator into +find_best_match_name+ functionJulian Kulesh-5/+27
2017-11-30Implement RFC 2128 (use_nested_groups)Pietro Albini-2/+2
This commit adds support for nested groups inside `use` declarations, such as `use foo::{bar, sub::{baz::Foo, *}};`.
2017-11-06Using `...` in expressions is now an errorBadel2-1/+2
2017-09-22Add support for `..=` syntaxAlex Burka-8/+9
Add ..= to the parser Add ..= to libproc_macro Add ..= to ICH Highlight ..= in rustdoc Update impl Debug for RangeInclusive to ..= Replace `...` to `..=` in range docs Make the dotdoteq warning point to the ... Add warning for ... in expressions Updated more tests to the ..= syntax Updated even more tests to the ..= syntax Updated the inclusive_range entry in unstable book
2017-09-07pprust: increase precedence of block-like exprsStuart Pernsteiner-11/+9
2017-09-06pprust: fix parenthesization of exprsStuart Pernsteiner-1/+105
2017-06-26Update and fix a few testsAlex Crichton-1/+1
2017-06-26Implement `quote!` and other `proc_macro` API.Jeffrey Seyfried-1/+9