about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-02-06Auto merge of #58061 - nnethercote:overhaul-syntax-Folder, r=petrochenkovbors-1924/+1700
Overhaul `syntax::fold::Folder`. This PR 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`. This makes the code faster and more concise.
2019-02-06Rename `fold.rs` as `mut_visit.rs`.Nicholas Nethercote-1/+1
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-1436/+1326
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-05allow shorthand syntax for deprecation reasonAndy Russell-63/+78
2019-02-06Rollup merge of #58116 - topecongiro:wrong-span-assignment, r=petrochenkovkennytm-0/+8
Include the span of attributes of the lhs to the span of the assignment expression This PR adds the span of attributes of the lhs to the span of the assignment expression. Currently with the following code, `#[attr]` is not included to the span of the assignment (`foo = true`). ```rust #[attr] foo = true; ``` The rational behind this change is that as libsyntax user I expect the span of the parent node includes every span of child nodes. cc https://github.com/rust-lang/rustfmt/issues/3313, https://github.com/rust-lang/rust/issues/15701.
2019-02-06Rollup merge of #58001 - ↵kennytm-1/+7
pnkfelix:issue-57735-proc-macro-with-large-tokenstream-slow, r=eddyb proc_macro: make `TokenStream::from_streams` pre-allocate its vector. This requires a pre-pass over the input streams. But that is cheap compared to the quadratic blowup associated with reallocating the accumulating vector on-the-fly. Fix #57735
2019-02-05Auto merge of #57973 - davidtwco:issue-52891, r=estebankbors-0/+7
Add suggestion for duplicated import. Fixes #52891. This PR adds a suggestion when a import is duplicated (ie. the same name is used twice trying to import the same thing) to remove the second import.
2019-02-05Various improvements in `Folder` impls.Nicholas Nethercote-46/+18
2019-02-05Streamline `Folder` some more.Nicholas Nethercote-43/+39
By eliminating some unnecessary methods, and moving/renaming some functions that look like they might be methods but aren't.
2019-02-05Neaten up `fold_crate`.Nicholas Nethercote-24/+15
2019-02-05Change `fold_qpath` to `fold_qself`.Nicholas Nethercote-14/+8
It's simpler that way.
2019-02-05Simplify `fold_attribute`.Nicholas Nethercote-15/+9
It doesn't need to return an `Option`.
2019-02-05Fold some overlooked spans.Nicholas Nethercote-11/+16
2019-02-05Streamline `Folder`.Nicholas Nethercote-77/+20
Specifically: - Remove dead methods: fold_usize, fold_meta_items, fold_opt_bounds. - Remove useless methods: fold_global_asm, fold_range_end. - Inline and remove unnecessary methods: fold_item_simple, fold_foreign_item_simple.
2019-02-05Remove some unnecessary `ast::` and `fold::` qualifiers.Nicholas Nethercote-46/+37
2019-02-04Add the span of attributes of the lhs to the span of the assignment expressiontopecongiro-0/+8
2019-02-02fix stabilization order of uniform_paths.Mazdak Farrokhzad-2/+2
2019-02-01Auto merge of #58002 - oli-obk:deprecated_sugg, r=zackmdavisbors-1/+4
Add suggestions to deprecation lints Clippy used to do this suggestion, but the clippy lints happen after the deprecation lints so we ended up never seeing the structured suggestions.
2019-01-31Add suggestion for duplicated import.David Wood-0/+7
This commit adds a suggestion when a import is duplicated (ie. the same name is used twice trying to import the same thing) to remove the second import.
2019-01-31Rollup merge of #57999 - jethrogb:jb/movbe-feature, r=alexcrichtonMazdak Farrokhzad-0/+1
Add MOVBE x86 CPU feature I have no idea if this is correct. I basically copied the ADX feature. I verified the feature is also called `movbe` in LLVM. I marked this to become stable immediately, as part of the RFC 2045. r? @alexcrichton
2019-01-31Rollup merge of #57008 - ↵Mazdak Farrokhzad-1/+6
Knium:misleading-try-adding-parentheses-in-match-with-comma, r=oli-obk suggest `|` when `,` founds in invalid match value Issue #54807 I get stuck on (what | how) I should implement...
2019-01-30Add suggestions to deprecation lintsOliver Scherer-1/+4
2019-01-30Add MOVBE featureJethro Beekman-0/+1
2019-01-30proc_macro: make `TokenStream::from_streams` pre-allocate its vector.Felix S. Klock II-1/+7
This requires a pre-pass over the input streams. But that is cheap compared to the quadratic blowup associated with reallocating the accumulating vector on-the-fly.
2019-01-30Allow #[repr(align(x))] on enums (#57996)Niklas Fiekas-0/+14
2019-01-30Suggest to add each of `|` and `()` when unexpected `,` is found in patternKnium_-1/+6
2019-01-28Rollup merge of #57915 - petrochenkov:notto-disu, r=zackmdavisMazdak Farrokhzad-18/+5
Pretty print `$crate` as `crate` or `crate_name` in more cases So, people do parse output of `--pretty=expanded` (sigh), so covering only the legacy proc-macro case (like it was done in https://github.com/rust-lang/rust/pull/57155) is not enough. This PRs resolves all `$crate`s produced by macros, so they are all printed in the parseable form `$crate::foo` -> `crate::foo` or `crate_name::foo`. Fixes https://github.com/rust-lang/rust/issues/38016#issuecomment-455851334 Fixes https://github.com/rust-lang/rust/pull/57155#issuecomment-455807195
2019-01-26remove `_with_applicability` from suggestion fnsAndy Russell-65/+65
2019-01-26Auto merge of #57918 - Centril:rollup, r=Centrilbors-3/+2
Rollup of 7 pull requests Successful merges: - #57407 (Stabilize extern_crate_self) - #57703 (Make MutexGuard's Debug implementation more useful.) - #57764 (Fix some minor warnings) - #57825 (un-deprecate mem::zeroed) - #57827 (Ignore aarch64 in simd-intrinsic-generic-reduction) - #57908 (resolve: Fix span arithmetics in the import conflict error) - #57913 (Change crate-visibility-modifier issue number in The Unstable Book) Failed merges: r? @ghost
2019-01-26Rollup merge of #57407 - mehcode:stabilize-extern-crate-self, r=CentrilMazdak Farrokhzad-3/+2
Stabilize extern_crate_self Fixes #56409
2019-01-26Auto merge of #57852 - davidtwco:issue-57819, r=estebankbors-8/+190
Suggest removing leading left angle brackets. Fixes #57819. This PR adds errors and accompanying suggestions as below: ``` bar::<<<<<T as Foo>::Output>(); ^^^ help: remove extra angle brackets ``` r? @estebank
2019-01-26Pretty print `$crate` as `crate` or `crate_name` in more casesVadim Petrochenkov-18/+5
2019-01-26Auto merge of #55641 - nagisa:optimize-attr, r=pnkfelixbors-2/+18
Implement optimize(size) and optimize(speed) attributes This PR implements both `optimize(size)` and `optimize(speed)` attributes. While the functionality itself works fine now, this PR is not yet complete: the code might be messy in places and, most importantly, the compiletest must be improved with functionality to run tests with custom optimization levels. Otherwise the new attribute cannot be tested properly. Oh, and not all of the RFC is implemented – attribute propagation is not implemented for example. # TODO * [x] Improve compiletest so that tests can be written; * [x] Assign a proper error number (E9999 currently, no idea how to allocate a number properly); * [ ] Perhaps reduce the duplication in LLVM attribute assignment code…
2019-01-25Resolve breakageSimonas Kazlauskas-1/+1
2019-01-25Rollup merge of #57886 - davidtwco:issue-57385, r=estebankMazdak Farrokhzad-27/+107
Add suggestion for moving type declaration before associated type bindings in generic arguments. Fixes #57385. r? @estebank
2019-01-25Rollup merge of #57645 - nikomatsakis:issue-56877-abi-aggregates, r=eddybMazdak Farrokhzad-0/+7
distinguish "no data" from "heterogeneous" in ABI Ignore zero-sized types when computing whether something is a homogeneous aggregate, except be careful of VLA. cc #56877 r? @arielb1 cc @eddyb
2019-01-25distinguish "no data" from "heterogeneous" for ABI purposesNiko Matsakis-0/+7
Also, add a testing infrastructure and tests that lets us dump layout.
2019-01-25Combining move lifetime and type suggestions.David Wood-30/+73
This commit combines the move lifetime and move type suggestions so that when rustfix applies them they don't conflict with each other.
2019-01-25Suggestion moving types before associated types.David Wood-15/+52
This commit extends existing suggestions to move lifetimes before types in generic arguments to also suggest moving types behind associated type bindings.
2019-01-24Auto merge of #57879 - Centril:rollup, r=Centrilbors-1/+17
Rollup of 9 pull requests Successful merges: - #57380 (Fix Instant/Duration math precision & associativity on Windows) - #57606 (Get rid of the fake stack frame for reading from constants) - #57803 (Several changes to libunwind for SGX target) - #57846 (rustdoc: fix ICE from loading proc-macro stubs) - #57860 (Add os::fortanix_sgx::ffi module) - #57861 (Don't export table by default in wasm) - #57863 (Add suggestion for incorrect field syntax.) - #57867 (Fix std::future::from_generator documentation) - #57873 (Stabilize no_panic_pow) Failed merges: r? @ghost
2019-01-24Implement optimize(size) and optimize(speed)Simonas Kazlauskas-2/+18
2019-01-24Rollup merge of #57863 - davidtwco:issue-57684, r=estebankMazdak Farrokhzad-1/+17
Add suggestion for incorrect field syntax. Fixes #57684. This commit adds a suggestion when a `=` character is used when specifying the value of a field in a struct constructor incorrectly instead of a `:` character. r? @estebank
2019-01-24Auto merge of #51285 - Mark-Simulacrum:remove-quote_apis, r=Manishearthbors-921/+19
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. Fixes #26994. r? @Manishearth
2019-01-24Remove quote_*! macros and associated APIsMark Simulacrum-921/+19
2019-01-24Rollup merge of #57817 - davidtwco:issue-54521, r=estebankMazdak Farrokhzad-1/+147
Add error for trailing angle brackets. Fixes #54521. This PR adds a error (and accompanying machine applicable suggestion) for trailing angle brackets on function calls with a turbofish. r? @estebank
2019-01-24Rollup merge of #57795 - estebank:did-you-mean, r=zackmdavisMazdak Farrokhzad-3/+10
Use structured suggestion in stead of notes
2019-01-24Rollup merge of #57779 - estebank:recover-struct-fields, r=davidtwcoMazdak Farrokhzad-10/+84
Recover from parse errors in literal struct fields and incorrect float literals Fix #52496.
2019-01-23Add suggestion for incorrect field syntax.David Wood-1/+17
This commit adds a suggestion when a `=` character is used when specifying the value of a field in a struct constructor incorrectly instead of a `:` character.
2019-01-23Optimize snapshot usage.David Wood-68/+57
This commit implements a suggestion from @estebank that optimizes the use of snapshots. Instead of creating a snapshot for each recursion in `parse_path_segment` and then replacing `self` with them until the first invocation where if leading angle brackets are detected, `self` is not replaced and instead the snapshot is used to inform how parsing should continue. Now, a snapshot is created in the first invocation that acts as a backup of the parser state before any generic arguments are parsed (and therefore, before recursion starts). This backup replaces `self` if after all parsing of generic arguments has concluded we can determine that there are leading angle brackets. Parsing can then proceed from the backup state making use of the now known number of unmatched leading angle brackets to recover.
2019-01-23Suggest removing leading left angle brackets.David Wood-8/+201
This commit adds errors and accompanying suggestions as below: ``` bar::<<<<<T as Foo>::Output>(); ^^^ help: remove extra angle brackets ```