Commit Graph

8279 Commits

Author SHA1 Message Date
bors
3315728c06 Auto merge of #57944 - estebank:unclosed-delim-the-quickening, r=oli-obk
Deduplicate mismatched delimiter errors

Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently.

Second attempt at #54029, follow up to #53949. Fix #31528.
2019-02-09 20:15:57 +00:00
bors
618f5a08a1 Auto merge of #57617 - mark-i-m:multiple-matcher-bindings, r=petrochenkov
Error on duplicate matcher bindings

fix  #57593

This should not be merged without a crater run and maybe an FCP. Discussion is ongoing at  #57593.

TODO:
- [x] write tests
- [x] crater run
- [x] ~maybe need edition gating?~ not for 1 regression /centril

r? @petrochenkov
2019-02-09 09:48:41 +00:00
bors
43e04fb552 Auto merge of #58191 - varkor:const-generics-ast, r=petrochenkov
Add const generics to the AST

This is mostly split out from https://github.com/rust-lang/rust/pull/53645 in an effort to make progress merging const generics piecewise instead of in one go.

cc @yodaldevoid, @petrochenkov

r? @eddyb
2019-02-08 05:50:16 +00:00
Mark Mansi
802b256283 Make it an incompatibility lint for now 2019-02-07 12:17:27 -06:00
mark
1b41c9a42e error on duplicate matcher bindings 2019-02-07 12:15:31 -06:00
Esteban Küber
c54b230fa1 Add fixme 2019-02-07 06:20:23 -08:00
varkor
4e0e188999 Make name resolution handle consts in GenericParamsFromOuterFunction properly 2019-02-07 15:03:20 +01:00
varkor
451f128783 Parse negative literals in const generic arguments 2019-02-07 15:03:20 +01:00
varkor
9ad04b9960 Add warning for a parameter list with an attribute but no parameters 2019-02-07 15:03:20 +01:00
varkor
b3015abfa0 Fix update to 2018 edition 2019-02-07 15:03:20 +01:00
varkor
bbdcc4e7ce Adjust parser generic parameter errors 2019-02-07 15:02:17 +01:00
varkor
2fec52bf58 Add lowering errors for const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07 15:02:17 +01:00
varkor
ea0d99829d Add resolution errors for const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07 15:02:17 +01:00
varkor
b4ef753e8f Add pretty-printing for const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07 15:02:16 +01:00
varkor
d7695abb76 Support const generics in derive
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07 15:02:16 +01:00
varkor
0a8d98a270 Parse const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07 15:02:16 +01:00
varkor
8d83521f0b Add const_generics feature flag
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07 15:02:16 +01:00
varkor
751dcdf606 Add Const kind to AST
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07 15:02:16 +01:00
Guillaume Gomez
8b886e07f5 Remove images' url to make it work even without internet connection 2019-02-07 11:06:19 +01:00
Esteban Küber
6e62129b36 add doc comment and revert angle bracket change 2019-02-07 01:42:54 -08:00
Esteban Küber
336c48cc7b tweak wording based on in person feedback 2019-02-07 01:42:54 -08:00
Esteban Küber
cba96613de fix test 2019-02-07 01:42:54 -08:00
Esteban Küber
80c0b326d6 Remove unused match 2019-02-07 01:42:54 -08:00
Esteban Küber
60459429c5 Add missing trailing newline 2019-02-07 01:42:54 -08:00
Esteban Küber
1495d30448 Remove spurious complaint about missing expression for bare semicolons 2019-02-07 01:42:54 -08:00
Esteban Küber
99be87aac3 unify error handling to single method 2019-02-07 01:42:54 -08:00
Esteban Küber
7451cd8dc0 Deduplicate mismatched delimiter errors
Delay unmatched delimiter errors until after the parser has run to
deduplicate them when parsing and attempt recovering intelligently.
2019-02-07 01:41:30 -08:00
bors
825f355c74 Auto merge of #57998 - niklasf:align-enum, r=nagisa
Allow #[repr(align(x))] on enums (#57996)

Tracking issue: #57996

Implements an extension of [RFC 1358](https://github.com/rust-lang/rfcs/blob/master/text/1358-repr-align.md) behind a feature flag (`repr_align_enum`). Originally introduced here for structs: #39999.

It seems like only HIR-level changes are required, since enums are already aware of their alignment (due to alignment of their limbs).

cc @bitshifter
2019-02-07 04:26:08 +00:00
Taiki Endo
7bb082d27f libsyntax => 2018 2019-02-07 02:33:01 +09:00
bors
2596bc1368 Auto merge of #58061 - nnethercote:overhaul-syntax-Folder, r=petrochenkov
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-06 06:01:37 +00:00
Nicholas Nethercote
bfcbd235a2 Rename fold.rs as mut_visit.rs. 2019-02-06 09:10:05 +11: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
kennytm
757c4407db
Rollup merge of #58116 - topecongiro:wrong-span-assignment, r=petrochenkov
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-06 00:29:02 +09:00
kennytm
a1ec22f6dd
Rollup merge of #58001 - 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-06 00:28:46 +09:00
bors
b2c6b8c29f Auto merge of #57973 - davidtwco:issue-52891, r=estebank
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-05 05:14:15 +00:00
Nicholas Nethercote
970b5d189a Various improvements in Folder impls. 2019-02-05 15:18:29 +11:00
Nicholas Nethercote
372fe84a83 Streamline Folder some more.
By eliminating some unnecessary methods, and moving/renaming some
functions that look like they might be methods but aren't.
2019-02-05 15:13:12 +11:00
Nicholas Nethercote
473095345b Neaten up fold_crate. 2019-02-05 15:12:15 +11:00
Nicholas Nethercote
8909f70a32 Change fold_qpath to fold_qself.
It's simpler that way.
2019-02-05 15:11:52 +11:00
Nicholas Nethercote
f97e896fd6 Simplify fold_attribute.
It doesn't need to return an `Option`.
2019-02-05 15:11:27 +11:00
Nicholas Nethercote
eea2dfe76f Fold some overlooked spans. 2019-02-05 15:11:10 +11:00
Nicholas Nethercote
faa82eb46c Streamline Folder.
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-05 15:10:04 +11:00
Nicholas Nethercote
b9686416c6 Remove some unnecessary ast:: and fold:: qualifiers. 2019-02-05 15:09:23 +11:00
topecongiro
9851a29688 Add the span of attributes of the lhs to the span of the assignment expression 2019-02-04 00:35:12 +09:00
Mazdak Farrokhzad
7754eb05c4 fix stabilization order of uniform_paths. 2019-02-02 07:42:27 +01:00
bors
741a3d42cb Auto merge of #58002 - oli-obk:deprecated_sugg, r=zackmdavis
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-02-01 01:06:15 +00:00
David Wood
1595163356
Add suggestion for duplicated import.
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-31 12:01:28 +01:00
Mazdak Farrokhzad
bb91a192c0
Rollup merge of #57999 - jethrogb:jb/movbe-feature, r=alexcrichton
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-31 02:10:49 +01:00
Mazdak Farrokhzad
ab844daadb
Rollup merge of #57008 - 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-31 02:10:40 +01:00
Oliver Scherer
4056b575e2 Add suggestions to deprecation lints 2019-01-30 17:49:04 +01:00