about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-10-14Remove the `Option` in `TokenStream`.Nicholas Nethercote-144/+100
It means an allocation is required to create an empty `TokenStream`, but all other operations are simpler and marginally faster due to not having to check for `None`. Overall it simplifies the code for a negligible performance effect. The commit also removes `TokenStream::empty` by implementing `Default`, which is now possible.
2019-10-13token: extract Nonterminal::to_tokenstream to parser.Mazdak Farrokhzad-139/+138
2019-10-13Rollup merge of #65214 - Amanieu:cfg_atomic, r=alexcrichtonMazdak Farrokhzad-0/+1
Split non-CAS atomic support off into target_has_atomic_load_store This PR implements my proposed changes in https://github.com/rust-lang/rust/issues/32976#issuecomment-518542029 by removing `target_has_atomic = "cas"` and splitting `target_has_atomic` into two separate `cfg`s: * `target_has_atomic = 8/16/32/64/128`: This indicates the largest width that the target can atomically CAS (which implies support for all atomic operations). * ` target_has_atomic_load_store = 8/16/32/64/128`: This indicates the largest width that the target can support loading or storing atomically (but may not support CAS). cc #32976 r? @alexcrichton
2019-10-13syntax: consolidate function parsing in `item.rs`Mazdak Farrokhzad-487/+491
2019-10-13Rollup merge of #65360 - Centril:mbrpt, r=petrochenkovMazdak Farrokhzad-25/+27
mbe: reduce panictry! uses. Extracted from https://github.com/rust-lang/rust/pull/65324. r? @petrochenkov
2019-10-13Rollup merge of #65359 - Centril:sil, r=davidtwcoMazdak Farrokhzad-9/+7
simplify integer_lit Extracted from https://github.com/rust-lang/rust/pull/65324. r? @davidtwco
2019-10-13Rollup merge of #65358 - Centril:smsf, r=davidtwcoMazdak Farrokhzad-14/+8
simplify maybe_stage_features Extracted from https://github.com/rust-lang/rust/pull/65324. r? @estebank
2019-10-13Rollup merge of #65357 - Centril:simplify-maybe-annotate-with-ascription, ↵Mazdak Farrokhzad-9/+11
r=davidtwco syntax: simplify maybe_annotate_with_ascription Split out from https://github.com/rust-lang/rust/pull/65324. r? @estebank
2019-10-13Collect occurrences of for mismatched braces diagnosticwangxiangqing-1/+4
Change-Id: I20ba0b62308370ee961141fa1aefc4b9c9f0cb3a
2019-10-13Collect occurrences of for mismatched braces diagnosticwangxiangqing-3/+17
Change-Id: I20ba0b62308370ee961141fa1aefc4b9c9f0cb3a
2019-10-13tokenstream: don't depend on pprustMazdak Farrokhzad-11/+7
2019-10-13ast: remove implicit pprust dependency via Display.Mazdak Farrokhzad-25/+44
Instead just use `pprust::path_to_string(..)` where needed. This has two benefits: a) The AST definition is now independent of printing it. (Therefore we get closer to extracting a data-crate.) b) Debugging should be easier as program flow is clearer.
2019-10-13ast: don't use pprust in DebugMazdak Farrokhzad-41/+6
2019-10-13mbe: reduce panictry! uses.Mazdak Farrokhzad-25/+27
2019-10-13simplify integer_litMazdak Farrokhzad-9/+7
2019-10-13simplify maybe_stage_featuresMazdak Farrokhzad-14/+8
2019-10-13syntax: simplify maybe_annotate_with_ascriptionMazdak Farrokhzad-9/+11
2019-10-12compress the function, remove the assert check.Guanqun Lu-11/+2
2019-10-12replace the hand-written binary search with the library oneGuanqun Lu-13/+5
2019-10-11Auto merge of #64716 - jonhoo:stabilize-mem-take, r=SimonSapinbors-1/+0
Stabilize mem::take (mem_take) Tracking issue: https://github.com/rust-lang/rust/issues/61129 r? @matklad
2019-10-09Auto merge of #65198 - nnethercote:fix-65080, r=Mark-Simulacrumbors-61/+80
Speed up `TokenStream` concatenation This PR fixes the quadratic behaviour identified in #65080. r? @Mark-Simulacrum
2019-10-09Rollup merge of #65037 - anp:track-caller, r=oli-obkMazdak Farrokhzad-0/+5
`#[track_caller]` feature gate (RFC 2091 1/N) RFC text: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md Tracking issue: https://github.com/rust-lang/rust/issues/47809 I started with @ayosec's commit to add the feature gate with tests and rebased it onto current master. I fixed up some tidy lints and added a test.
2019-10-08Stabilize mem::take (mem_take)Jon Gjengset-1/+0
Tracking issue: https://github.com/rust-lang/rust/issues/61129
2019-10-08Rollup merge of #64284 - Mark-Simulacrum:include-warn, r=petrochenkovMazdak Farrokhzad-0/+1
Warn if include macro fails to include entire file This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such. This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning. r? @petrochenkov cc https://github.com/rust-lang/rust/issues/35560
2019-10-08Split non-CAS atomic support off into target_has_atomic_load_storeAmanieu d'Antras-0/+1
2019-10-08Rollup merge of #64918 - GuillaumeGomez:long-err-explanation-E0551, r=oli-obkMazdak Farrokhzad-1/+19
Add long error explanation for E0551 Part of #61137
2019-10-08Optimize `TokenStreamBuilder::push`.Nicholas Nethercote-51/+43
Currently, when two tokens must be glued together, this function duplicates large chunks of the existing streams. This can cause quadratic behaviour. This commit changes the function so that it overwrites the last token with a glued token, which avoids the quadratic behaviour. This removes the need for `TokenStreamBuilder::push_all_but_{first,last}_tree`. The commit also restructures `push` somewhat, by removing `TokenStream::{first_tree_and_joint,last_tree_if_joint}` in favour of more pattern matching and some comments. This makes the code shorter, and in my opinion, more readable.
2019-10-08Optimize `TokenStream::from_streams`.Nicholas Nethercote-10/+37
Currently, this function creates a new empty stream, and then appends the elements from each given stream onto that stream. This can cause quadratic behaviour. This commit changes the function so that it modifies the first stream (which can be long) by extending it with the elements from the subsequent streams (which are almost always short), which avoids the quadratic behaviour.
2019-10-08Rollup merge of #65040 - Centril:items-cleanup, r=estebankMazdak Farrokhzad-214/+198
syntax: more cleanups in item and function signature parsing Follow up to https://github.com/rust-lang/rust/pull/64910. Best read commit-by-commit. r? @estebank
2019-10-07Warn if include macro fails to include entire fileMark Rousskov-0/+1
2019-10-07Mark #![feature(track_caller)] as incomplete.Adam Perry-0/+1
2019-10-07track_caller feature gate starts in 1.40.0.Adam Perry-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-10-07track_caller run-pass test, lint cleanup, PR review.Adam Perry-5/+2
2019-10-07[RFC 2091] Add #[track_caller] attribute.Ayose-0/+7
- The attribute is behind a feature gate. - Error if both #[naked] and #[track_caller] are applied to the same function. - Error if #[track_caller] is applied to a non-function item. - Error if ABI is not "rust" - Error if #[track_caller] is applied to a trait function. Error codes and descriptions are pending.
2019-10-07Fix compilation error after rebase.Charles Lew-1/+1
2019-10-07syntax: refactor with new `fn parse_use_tree_glob_or_nested`.Mazdak Farrokhzad-10/+11
2019-10-07syntax: use `parse_extern_abi` more.Mazdak Farrokhzad-8/+1
2019-10-07Address review comments.Charles Lew-4/+3
2019-10-07Add feature gate for raw_dylib.Charles Lew-1/+10
2019-10-07syntax: unify and simplify fn signature parsing.Mazdak Farrokhzad-91/+74
2019-10-07syntax: unify trait parsing a bit.Mazdak Farrokhzad-17/+12
2019-10-07syntax: further item parsing cleanupMazdak Farrokhzad-24/+35
2019-10-07syntax: de-dups in item parsing.Mazdak Farrokhzad-50/+44
2019-10-07syntax: cleanup associated const parsing.Mazdak Farrokhzad-32/+39
2019-10-07Auto merge of #64906 - Aaron1011:feature/extern-const-fn, r=Centrilbors-19/+49
Add support for `const unsafe? extern fn` This works just as you might expect - an `const extern fn` is a `const fn` that is callable from foreign code. Currently, panicking is not allowed in `const`s. When https://github.com/rust-lang/rfcs/pull/2345 (https://github.com/rust-lang/rust/issues/51999) is stabilized, then panicking in an `const extern fn` will produce a compile-time error when invoked at compile time, and an abort when invoked at runtime. Since this is extending the language (we're allowing the `const` keyword in a new context), I believe that this will need an FCP. However, it's a very minor change, so I didn't think that filing an RFC was necessary. This will allow libc (and other FFI crates) to make many functions `const`, without having to give up on making them `extern` as well. Tracking issue: https://github.com/rust-lang/rust/issues/64926.
2019-10-05Rollup merge of #65123 - Centril:mac-invoc-in-mut-pat, r=estebankTyler Mandry-1/+5
Account for macro invocation in `let mut $pat` diagnostic. Fixes https://github.com/rust-lang/rust/issues/65122. r? @estebank
2019-10-05Rollup merge of #64909 - estebank:turbofish-reloaded, r=CentrilTyler Mandry-14/+153
When encountering chained operators use heuristics to recover from bad turbofish
2019-10-05Account for macro invocation in `let mut $pat` diagnostic.Mazdak Farrokhzad-1/+5
2019-10-03Rollup merge of #65055 - GuillaumeGomez:long-err-explanation-E0556, ↵Tyler Mandry-1/+19
r=petrochenkov Add long error explanation for E0556 Part of #61137
2019-10-03Rollup merge of #64690 - petrochenkov:mixed, r=dtolnayTyler Mandry-0/+11
proc_macro API: Expose `macro_rules` hygiene Proc macros do not have direct access to our oldest and most stable hygiene kind - `macro_rules` hygiene. To emulate it macro authors have to go through two steps - first generate a temporary `macro_rules` item (using a derive, at least until https://github.com/rust-lang/rust/pull/64035 is merged), then generate a macro call to that item. Popular crates like [proc_macro_hack](https://crates.io/crates/proc-macro-hack) use this trick to generate hygienic identifiers from proc macros. I'd say that these workarounds with nested macro definitions have more chances to hit some corner cases in our hygiene system, in which we don't have full confidence. So, let's provide a direct access to `macro_rules` hygiene instead. This PR does that by adding a new method `Span::mixed_site` (bikeshedding is welcome) in addition to existing `Span::call_site` (stable) and `Span::def_site` (unstable). Identifiers with this span resolve at def-site in for local variables, labels and `$crate`, and resolve at call-site for everything else, i.e. exactly like identifiers produced by `macro_rules`. This API addition opens the way to stabilizing proc macros in expression positions (https://github.com/rust-lang/rust/issues/54727), for which use of call-site hygiene or workarounds with temporary items would be quite unfortunate. (`macro_rules` expanded in expression position, on the other hand, are stable since 1.0 and widely used.) r? @dtolnay @alexcrichton