about summary refs log tree commit diff
path: root/src/libsyntax_ext
AgeCommit message (Collapse)AuthorLines
2019-10-14Rollup merge of #65261 - nnethercote:rm-Option-from-TokenStream, r=petrochenkovTyler Mandry-1/+1
Remove `Option` from `TokenStream` A code simplification. r? @petrochenkov
2019-10-14Rollup merge of #65363 - Centril:less-pprust, r=Mark-SimulacrumMazdak Farrokhzad-8/+20
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-14Remove the `Option` in `TokenStream`.Nicholas Nethercote-1/+1
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-13ast: remove implicit pprust dependency via Display.Mazdak Farrokhzad-8/+20
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-12Auto merge of #64873 - popzxc:prettify-test-time, r=wesleywiserbors-0/+44
Enhance report-time option ## Short overview This PR is a follow-up to a previously closed #64714 PR. ## Changes introduced by this PR * `libtest` now retrieves the type of the test within `TestDesc` (available types are: `UnitTest`, `IntegrationTest`, `DocTest`, `Unknown`). * `--report-time` subcommand of the `libtest` now supports colored output (disabled by default). * Colorized output depends on the threshold values. Default values (proposed by @wesleywiser): - For unit-tests: 50ms warn/100ms critical, - For integration-tests: 500ms warn/1000ms critical, - For doctests: same as for integration tests, - For unknown tests: `TEST_WARN_TIMEOUT_S` warn/ `TEST_WARN_TIMEOUT_S * 2` critical (it will only applied single-threaded mode, because otherwise test will be interrupted after reaching `TEST_WARN_TIMEOUT_S`). - These values can be overrided by setting environment variables (since those thresholds are somewhat constant for every project, it's more flexible to use environment variables than command line arguments). * New optional flag `--ensure-test-time` for `libtest`. With this flag applied, exectuion time limit excesss will cause test failure. ## What have not been done There was a comment that it would be nice to have an entry in the Cargo book about it. However, changes introduced by this PR (and #64663 in which `report-time` flag was added) aren't related directly to `cargo`, it's more about `libtest` itself. I'm considering that [The Unstable Book](https://doc.rust-lang.org/unstable-book/) is more appropriate place, but not sure if I'm right (and if so, how exactly it should be described). As one possible option, this PR may be merged without denoting it in the documentation, and in the next PR adding support of this feature to the `cargo` itself, I'll add a note in the Cargo book. ## Scope of this PR Logical scope of this PR is `libtest` only. However, to get test types, I had to modify also `libsyntax_ext` and `librustdoc` for them to provide information about test type. ## Rationale Rationale for colored output was submitted in #64714 Providing the information about kind of test was also proposed in #64714, and as an additional benefit this information may be useful for the tools using `libtest` (e.g. `cargo`). Adding flag to treat time limits excess seems logical to me, so projects that do care about test execution time won't have to invent a wheel. ## Backward compatibility All the changes are completely backward compatible. ## Demo ![rustc_enhanced_time](https://user-images.githubusercontent.com/12111581/65818381-c04f6800-e219-11e9-9875-322463abe24f.gif) r? @wesleywiser
2019-10-11Rollup merge of #65310 - da-x:issue-56195, r=petrochenkovTyler Mandry-2/+2
deriving: avoid dummy Span on an artificial `type_ident` path The dummy Span pointed to the beginning of the source file instead to where the `#[derive]` is located. Later, it tripped the `in_derive_expansion(span)` check at `src/librustc/middle/stability.rs`, causing a span-less deprecation warning to be emitted. Fixes #56195, Fixes #55417.
2019-10-11deriving: avoid dummy Span on an artificial `type_ident` pathDan Aloni-2/+2
The dummy Span pointed to the beginning of the source file instead to where the `#[derive]` is located. Later, it tripped the `in_derive_expansion(span)` check at `src/librustc/middle/stability.rs`, causing a span-less deprecation warning to be emitted. Fixes #56195, #55417.
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-08Stabilize mem::take (mem_take)Jon Gjengset-1/+0
Tracking issue: https://github.com/rust-lang/rust/issues/61129
2019-10-07Warn if include macro fails to include entire fileMark Rousskov-1/+11
2019-09-30syntax: Support modern attribute syntax in the `meta` matcherVadim Petrochenkov-2/+2
2019-09-29Enhance report-time optionIgor Aleksanov-0/+44
2019-09-29Auto merge of #64158 - tmandry:libtest-panic-abort, r=alexcrichtonbors-2/+28
panic=abort support in libtest Add experimental support for tests compiled with panic=abort. Enabled with `-Z panic_abort_tests`. r? @alexcrichton cc @cramertj
2019-09-28Put panic=abort test support behind -Z panic_abort_testsTyler Mandry-0/+16
2019-09-28Spawn one subprocess per unit test when panic=abortTyler Mandry-2/+12
2019-09-28Rollup merge of #64793 - immunant:format_spans, r=matthewjasperMazdak Farrokhzad-6/+6
Fix format macro expansions spans to be macro-generated New Exprs generated as part of the format macro expansion should get the macro expansion span with an expansion context, rather than the span of the format string which does not.
2019-09-26Rename `Item.node` to `Item.kind`varkor-17/+17
2019-09-26Rename `Stmt.node` to `Stmt.kind`varkor-1/+1
2019-09-26Rename `Ty.node` to `Ty.kind`varkor-4/+4
2019-09-26Rename `Lit.node` to `Lit.kind`varkor-1/+1
2019-09-26Rename `ImplItem.node` to `ImplItem.kind`varkor-2/+2
2019-09-26Rename `Expr.node` to `Expr.kind`varkor-3/+3
For both `ast::Expr` and `hir::Expr`.
2019-09-25Fix format macro expansions spans to be macro-generatedStephen Crane-6/+6
New Exprs generated as part of the format macro expansion should get the macro expansion span which has an expansion context, not the span of the format string which does not.
2019-09-24Rollup merge of #64702 - sinkuu:deps, r=jonas-schievinkMazdak Farrokhzad-1/+0
Remove unused dependencies
2019-09-23cleanup librustc_errors Handler code.Mazdak Farrokhzad-2/+2
2019-09-23Remove unused dependenciesShotaro Yamada-1/+0
2019-09-23Rollup merge of #64670 - Mark-Simulacrum:ext-build-simplify, r=petrochenkovMazdak Farrokhzad-15/+18
Cleanup syntax::ext::build I suspect most of this code could be inlined but I only removed the bits where the inlining didn't really hurt readability (i.e., method call -> function call) or the completely unused code.
2019-09-21Inline attribute constructorsMark Rousskov-7/+10
2019-09-21Remove constraints argument from path_allMark Rousskov-8/+8
It was never used
2019-09-20factor out pluralisation remains after #64280gaolei-1/+2
2019-09-17Generate proc macro harness in AST order.Aaron Hill-47/+62
This ensures that we match the order used by proc macro metadata serialization. Fixes #64251
2019-09-15Remove `with_legacy_ctxt`Matthew Jasper-8/+10
2019-09-15Give more `Idents` spansMatthew Jasper-62/+66
2019-09-15Avoid some unnecessary `&str` to `Ident` conversionsMatthew Jasper-16/+14
2019-09-14Auto merge of #64080 - estebank:parse-format-comma, r=zackmdavisbors-4/+12
Be accurate on `format!` parse error expectations Fix https://github.com/rust-lang/rust/issues/57277.
2019-09-09Resolve attributes in several placesCaio-0/+1
Arm, Field, FieldPat, GenericParam, Param, StructField and Variant
2019-09-07Rollup merge of #64139 - Mark-Simulacrum:strip-legacy-proc-macro, r=petrochenkovMazdak Farrokhzad-6/+4
Migrate internal diagnostic registration to macro_rules Review is best done commit-by-commit. Fixes #64132.
2019-09-07Rollup merge of #64243 - petrochenkov:cmdattr, r=alexcrichtonMazdak Farrokhzad-0/+31
Move injection of attributes from command line to `libsyntax_ext` Just a tiny bit of code generation that wasn't moved into `libsyntax_ext` in https://github.com/rust-lang/rust/pull/62771.
2019-09-07Rollup merge of #64233 - varkor:correct-pluralisation, r=estebankMazdak Farrokhzad-1/+1
Correct pluralisation of various diagnostic messages
2019-09-07Rollup merge of #63919 - matthewjasper:remove-gensymmed, r=petrochenkovMazdak Farrokhzad-251/+194
Use hygiene for AST passes AST passes are now able to have resolve consider their expansions as if they were opaque macros defined either in some module in the current crate, or a fake empty module with `#[no_implicit_prelude]`. * Add an ExpnKind for AST passes. * Remove gensyms in AST passes. * Remove gensyms in`#[test]`, `#[bench]` and `#[test_case]`. * Allow opaque macros to define tests. * Move tests for unit tests to their own directory. * Remove `Ident::{gensym, is_gensymed}` - `Ident::gensym_if_underscore` still exists. cc #60869, #61019 r? @petrochenkov
2019-09-06Move injection of attributes from command line to `libsyntax_ext`Vadim Petrochenkov-0/+31
2019-09-06Correct pluralisation of various diagnostic messagesvarkor-1/+1
2019-09-06Rollup merge of #64111 - Centril:ast-only-patkind-or, r=petrochenkovMazdak Farrokhzad-13/+9
or-patterns: Uniformly use `PatKind::Or` in AST & Fix/Cleanup resolve Following up on work in https://github.com/rust-lang/rust/pull/63693 and https://github.com/rust-lang/rust/pull/61708, in this PR we: - Uniformly use `PatKind::Or(...)` in AST: - Change `ast::Arm.pats: Vec<P<Pat>>` => `ast::Arm.pat: P<Pat>` - Change `ast::ExprKind::Let.0: Vec<P<Pat>>` => `ast::ExprKind::Let.0: P<Pat>` - Adjust `librustc_resolve/late.rs` to correctly handle or-patterns at any level of nesting as a result. In particular, the already-bound check which rejects e.g. `let (a, a);` now accounts for or-patterns. The consistency checking (ensures no missing bindings and binding mode consistency) also now accounts for or-patterns. In the process, a bug was found in the current compiler which allowed: ```rust enum E<T> { A(T, T), B(T) } use E::*; fn foo() { match A(0, 1) { B(mut a) | A(mut a, mut a) => {} } } ``` The new algorithms took a few iterations to get right. I tried several clever schemes but ultimately a version based on a stack of hashsets and recording product/sum contexts was chosen since it is more clearly correct. - Clean up `librustc_resolve/late.rs` by, among other things, using a new `with_rib` function to better ensure stack dicipline. - Do not push the change in AST to HIR for now to avoid doing too much in this PR. To cope with this, we introduce a temporary hack in `rustc::hir::lowering` (clearly marked in the diff). cc https://github.com/rust-lang/rust/issues/54883 cc @dlrobertson @matthewjasper r? @petrochenkov
2019-09-05Simplify std lib injectionMatthew Jasper-120/+36
2019-09-05Remove rustc_diagnostic_macros featureMark Rousskov-1/+0
2019-09-05Replace diagnostic plugins with macro_rulesMark Rousskov-2/+0
2019-09-05Restrict error code length to 80 columnsMark Rousskov-3/+4
The global restriction is 100, but since error codes are printed out via --explain we want to restrict them to just 80 columns.
2019-09-05Document test harness generationMatthew Jasper-27/+55
Also ensure that we're consistently using the def-site span when appropriate.
2019-09-05Add `with_{def_site,call_site,legacy}_ctxt,` methods to `Span`Vadim Petrochenkov-8/+13
Use these to create call-site spans for AST passes when needed.
2019-09-05Make use of hygiene in AST passesMatthew Jasper-210/+204