about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-10-18Rollup merge of #65455 - ↵Tyler Mandry-36/+41
nnethercote:avoid-unnecessary-TokenTree-to-TokenStream-conversions, r=petrochenkov Avoid unnecessary `TokenTree` to `TokenStream` conversions A `TokenStream` contains any number of `TokenTrees`. Therefore, a single `TokenTree` can be promoted to a `TokenStream`. But doing so costs two allocations: one for the single-element `Vec`, and one for the `Lrc`. (An `IsJoint` value also must be added; the default is `NonJoint`.) The current code converts `TokenTree`s to `TokenStream`s unnecessarily in a few places. This PR removes some of these unnecessary conversions, both simplifying the code and speeding it up. r? @petrochenkov
2019-10-18Rollup merge of #65364 - XiangQingW:master, r=estebankTyler Mandry-3/+20
Collect occurrences of empty blocks for mismatched braces diagnostic Fix #63904
2019-10-18Clarify diagnostics when using `~` as a unary opYuki Okushi-1/+1
2019-10-18Change `MetaItem::tokens()` to `MetaItem::token_trees_and_joints()`.Nicholas Nethercote-21/+26
Likewise for `NestedMetaItem::tokens()`. Also, add `MetaItemKind::token_trees_and_joints()`, which `MetaItemKind::tokens()` now calls. This avoids some unnecessary `TokenTree` to `TokenStream` conversions, and removes the need for the clumsy `TokenStream::append_to_tree_and_joint_vec()`.
2019-10-18Change `Lit::tokens()` to `Lit::token_tree()`.Nicholas Nethercote-13/+13
Because most of the call sites have an easier time working with a `TokenTree` instead of a `TokenStream`.
2019-10-18Make `TokenStream::from_iter` less general and more efficient.Nicholas Nethercote-3/+3
The current code has this impl: ``` impl<T: Into<TokenStream>> iter::FromIterator<T> for TokenStream ``` If given an `IntoIterator<Item = TokenTree>`, it will convert each individual `TokenTree` to a `TokenStream` (at the cost of two allocations: a `Vec` and an `Lrc`). It will then merge those `TokenStream`s into a single `TokenStream`. This is inefficient. This commit changes the impl to this less general one: ``` impl iter::FromIterator<TokenTree> for TokenStream ``` It collects the `TokenTree`s into a single `Vec` first and then converts that to a `TokenStream` by wrapping it in a single `Lrc`. The previous generality was unnecessary; no other code needs changing. This change speeds up several benchmarks by up to 4%.
2019-10-18Remove two no-op `into()` calls.Nicholas Nethercote-2/+2
2019-10-17Plugins deprecation: don’t suggest simply removing the attributeSimon Sapin-2/+8
Building Servo with a recent Nightly produces: ```rust warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/issues/29597 --> components/script/lib.rs:14:1 | 14 | #![plugin(script_plugins)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | = note: `#[warn(deprecated)]` on by default ``` First, linking to https://github.com/rust-lang/rust/issues/29597 is not ideal since there is pretty much no discussion there of the deprecation and what can be used instead. This PR changes the link to the deprecation PR which does have more discussion. Second, the “remove this attribute” suggestion is rather unhelpful. Just because a feature is deprecated doesn’t mean that simply removing its use without a replacement is acceptable. In the case of custom lint, there is no replacement available. Prefixing a message with “help:” when telling users that they’re screwed honestly feels disrespectful. This PR also changes the message to be more factual.
2019-10-17Add long error explanation for E0584Guillaume Gomez-1/+27
2019-10-16panictry!(..) -> .unwrap()Mazdak Farrokhzad-2/+2
2019-10-16ui-fulldeps: make them pass again?Mazdak Farrokhzad-3/+3
2019-10-16make tidy happyMazdak Farrokhzad-3/+13
2019-10-16parser: leave a FIXME for laterMazdak Farrokhzad-0/+2
2019-10-16move SeqSep to parser.rsMazdak Farrokhzad-30/+31
2019-10-16move syntax::ext to new crate syntax_expandMazdak Farrokhzad-8391/+37
2019-10-16syntax::parse: don't depend on syntax::extMazdak Farrokhzad-6/+12
2019-10-16attr: remove dep on ExtCtxtMazdak Farrokhzad-9/+5
2019-10-16ast: use more direct importsMazdak Farrokhzad-9/+8
2019-10-16syntax: reduce visibilitiesMazdak Farrokhzad-101/+101
2019-10-16move diagnostics.rs into parser/Mazdak Farrokhzad-6/+7
2019-10-16syntax: extract parse_cfg_attrMazdak Farrokhzad-21/+22
2019-10-16syntax: extract parse_derive_pathsMazdak Farrokhzad-19/+20
2019-10-16move parse::attr -> parse::parser::attrMazdak Farrokhzad-1/+1
2019-10-15Rollup merge of #64623 - matthewjasper:underscore-imports, r=petrochenkovTyler Mandry-2/+1
Remove last uses of gensyms Underscore bindings now use unique `SyntaxContext`s to avoid collisions. This was the last use of gensyms in the compiler, so this PR also removes them. closes #49300 cc #60869 r? @petrochenkov
2019-10-15Remove some mentions of gensymsMatthew Jasper-2/+1
2019-10-15Collect occurrences of for mismatched braces diagnosticwangxiangqing-1/+1
Change-Id: I20ba0b62308370ee961141fa1aefc4b9c9f0cb3a
2019-10-15Remove unnecessary `use crate::sess::ParseSess;`.Mazdak Farrokhzad-1/+0
2019-10-15Rollup merge of #65428 - phansch:rename_db_var, r=CentrilMazdak Farrokhzad-15/+15
Refactor: Rename `db` locals to `diag` https://github.com/rust-lang/rust/pull/64272 replaced `DiagnosticBuilder` with `Diagnostic` in some places. This PR just renames the db variable from `db` to `diag` where it wasn't renamed. r? @Mark-Simulacrum
2019-10-15Rollup merge of #65426 - ↵Mazdak Farrokhzad-2/+2
nnethercote:rm-custom-LocalInternedString-PartialEq-impls, r=petrochenkov Remove custom `PartialEq` impls for `LocalInternedString`. This is on-trend with the recent changes simplifying `LocalInternedString` and reducing its use. r? @petrochenkov
2019-10-15Rollup merge of #65376 - Centril:syntax-extractions-1, r=petrochenkovMazdak Farrokhzad-368/+380
syntax: misc extractions Part of https://github.com/rust-lang/rust/pull/65324. r? @petrochenkov
2019-10-15syntax::parse::sess -> syntax::sessMazdak Farrokhzad-21/+32
2019-10-15move parse_lit to expr.rsMazdak Farrokhzad-177/+170
2019-10-15syntax: extract sess.rs for ParseSessMazdak Farrokhzad-119/+132
2019-10-15move maybe_report_invalid_custom_discriminants to feature_gateMazdak Farrokhzad-55/+50
2019-10-15Stabilize proc macros generating `macro_rules` itemsVadim Petrochenkov-45/+4
2019-10-15Refactor: Rename `db` locals to `diag`Philipp Hansch-15/+15
https://github.com/rust-lang/rust/pull/64272 replaced `DiagnosticBuilder` with `Diagnostic` in some places. This commit just renames the DB variable from `db` to `diag` where it wasn't renamed.
2019-10-15Remove custom `PartialEq` impls for `LocalInternedString`.Nicholas Nethercote-2/+2
This is on-trend with the recent changes simplifying `LocalInternedString` and reducing its use.
2019-10-14Rollup merge of #65410 - Centril:intersection-pat-recover, r=davidtwco,varkorTyler Mandry-1/+62
syntax: add parser recovery for intersection- / and-patterns `p1 @ p2` Fixes https://github.com/rust-lang/rust/issues/65400. The recovery comes in two flavors: 1. We know that `p2` is a binding so we can invert as `p2 @ p1`: ```rust error: pattern on wrong side of `@` --> $DIR/intersection-patterns.rs:13:9 | LL | Some(x) @ y => {} | -------^^^- | | | | | binding on the right, should be to the left | pattern on the left, should be to the right | help: switch the order: `y @ Some(x)` ``` 2. Otherwise we emit a generic diagnostic for the lack of support for intersection patterns: ```rust error: left-hand side of `@` must be a binding --> $DIR/intersection-patterns.rs:23:9 | LL | Some(x) @ Some(y) => {} | -------^^^------- | | | | | also a pattern | interpreted as a pattern, not a binding | = note: bindings are `x`, `mut x`, `ref x`, and `ref mut x` ``` For more on and-patterns, see e.g. https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/pattern-matching#and-pattern. r? @davidtwco cc @varkor @lzutao
2019-10-14Rollup merge of #65398 - estebank:capitalization-only, r=varkorTyler Mandry-1/+8
Bring attention to suggestions when the only difference is capitalization CC #65386.
2019-10-14Rollup merge of #65261 - nnethercote:rm-Option-from-TokenStream, r=petrochenkovTyler Mandry-153/+109
Remove `Option` from `TokenStream` A code simplification. r? @petrochenkov
2019-10-14pprust: `p1@p2` -> `p1 @ p2`Mazdak Farrokhzad-1/+2
2019-10-14recover_intersection_pat: adjust wordingMazdak Farrokhzad-3/+3
2019-10-14syntax: use `PatKind::Wild` as our `::Err` equivalent.Mazdak Farrokhzad-10/+10
2019-10-14syntax: add recovery for intersection patterns `p1 @ p2`Mazdak Farrokhzad-0/+60
2019-10-14Rollup merge of #65392 - Centril:nt-to-tt, r=Mark-SimulacrumMazdak Farrokhzad-139/+138
Move `Nonterminal::to_tokenstream` to parser & don't rely directly on parser in lowering Split out from https://github.com/rust-lang/rust/pull/65324. r? @petrochenkov
2019-10-14Rollup merge of #65363 - Centril:less-pprust, r=Mark-SimulacrumMazdak Farrokhzad-77/+57
Remove implicit dependencies on syntax::pprust Part of https://github.com/rust-lang/rust/pull/65324. The main goal here is to facilitate the eventual move of pprust out from libsyntax and because an AST definition typically should not depend on its pretty printer. r? @estebank
2019-10-14Rollup merge of #65362 - Centril:extract_fun, r=petrochenkovMazdak Farrokhzad-487/+491
syntax: consolidate function parsing in item.rs Extracted from https://github.com/rust-lang/rust/pull/65324. r? @estebank
2019-10-13Bring attention to suggestions when the only difference is capitalizationEsteban Küber-1/+8
2019-10-14Lazify some `mac_placeholder()` calls.Nicholas Nethercote-7/+7
This avoids some unnecessary creation of empty token streams.
2019-10-14Use `TokenStream::default()` in more places.Nicholas Nethercote-2/+2