| Age | Commit message (Collapse) | Author | Lines |
|
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.
|
|
|
|
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.
|
|
|
|
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.
|
|
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
|
|
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.
|
|
|
|
By eliminating some unnecessary methods, and moving/renaming some
functions that look like they might be methods but aren't.
|
|
|
|
It's simpler that way.
|
|
It doesn't need to return an `Option`.
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
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
|
|
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...
|
|
|
|
|
|
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.
|
|
|
|
|
|
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
|
|
|
|
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
|
|
Stabilize extern_crate_self
Fixes #56409
|
|
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
|
|
|
|
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…
|
|
|
|
Add suggestion for moving type declaration before associated type bindings in generic arguments.
Fixes #57385.
r? @estebank
|
|
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
|
|
Also, add a testing infrastructure and tests that lets us dump layout.
|
|
This commit combines the move lifetime and move type suggestions so that
when rustfix applies them they don't conflict with each other.
|
|
This commit extends existing suggestions to move lifetimes before types
in generic arguments to also suggest moving types behind associated type
bindings.
|
|
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
|
|
|
|
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
|
|
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
|
|
|
|
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
|
|
Use structured suggestion in stead of notes
|
|
Recover from parse errors in literal struct fields and incorrect float literals
Fix #52496.
|
|
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.
|
|
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.
|
|
This commit adds errors and accompanying suggestions as below:
```
bar::<<<<<T as Foo>::Output>();
^^^ help: remove extra angle brackets
```
|