Commit Graph

811 Commits

Author SHA1 Message Date
Esteban Küber
bd813bf1ac review comment: span bug label 2019-10-18 08:38:08 -07:00
Esteban Küber
11011013f2 Refer to "associated functions" instead of "static methods" 2019-10-17 19:03:36 -07:00
Mazdak Farrokhzad
d420d719c4 move syntax::ext to new crate syntax_expand 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad
7ec38a9ae3 attr: remove dep on ExtCtxt 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad
ae156a56d4 syntax::parse::sess -> syntax::sess 2019-10-15 09:41:58 +02:00
Tyler Mandry
6d28ed1ae6
Rollup merge of #65261 - nnethercote:rm-Option-from-TokenStream, r=petrochenkov
Remove `Option` from `TokenStream`

A code simplification.

r? @petrochenkov
2019-10-14 17:52:35 -07:00
Mazdak Farrokhzad
2800bc240e
Rollup merge of #65363 - Centril:less-pprust, r=Mark-Simulacrum
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-14 07:36:57 +02:00
Nicholas Nethercote
5c93492da9 Remove the Option in TokenStream.
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-14 09:14:39 +11:00
Mazdak Farrokhzad
742ec4b9bf ast: remove implicit pprust dependency via Display.
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-13 06:58:51 +02:00
bors
80b861bed1 Auto merge of #64873 - popzxc:prettify-test-time, r=wesleywiser
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-12 23:47:27 +00:00
Tyler Mandry
c8e3c51782
Rollup merge of #65310 - da-x:issue-56195, r=petrochenkov
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-11 15:10:00 -07:00
Dan Aloni
a32aec021e 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, #55417.
2019-10-11 16:38:47 +03:00
bors
d4f7f974b8 Auto merge of #64716 - jonhoo:stabilize-mem-take, r=SimonSapin
Stabilize mem::take (mem_take)

Tracking issue: https://github.com/rust-lang/rust/issues/61129

r? @matklad
2019-10-11 12:45:20 +00:00
Jon Gjengset
45aca119a6
Stabilize mem::take (mem_take)
Tracking issue: https://github.com/rust-lang/rust/issues/61129
2019-10-08 18:04:18 -04:00
Mark Rousskov
e068cec13e Warn if include macro fails to include entire file 2019-10-07 19:47:53 -04:00
Vadim Petrochenkov
957986d056 syntax: Support modern attribute syntax in the meta matcher 2019-09-30 22:58:22 +03:00
Igor Aleksanov
75a297573f Enhance report-time option 2019-09-29 21:22:30 +03:00
bors
06c68947ad Auto merge of #64158 - tmandry:libtest-panic-abort, r=alexcrichton
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-29 13:53:08 +00:00
Tyler Mandry
3f0254e3cf Put panic=abort test support behind -Z panic_abort_tests 2019-09-28 13:52:18 -07:00
Tyler Mandry
8ae1ec60cc Spawn one subprocess per unit test when panic=abort 2019-09-28 13:52:18 -07:00
Mazdak Farrokhzad
d9168e4cfa
Rollup merge of #64793 - immunant:format_spans, r=matthewjasper
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-28 22:12:04 +02:00
varkor
7bc94cc3c2 Rename Item.node to Item.kind 2019-09-26 18:21:48 +01:00
varkor
21bf983acb Rename Stmt.node to Stmt.kind 2019-09-26 18:21:10 +01:00
varkor
c3d8791373 Rename Ty.node to Ty.kind 2019-09-26 18:21:10 +01:00
varkor
17726f6b52 Rename Lit.node to Lit.kind 2019-09-26 18:21:09 +01:00
varkor
ce6aabbaa1 Rename ImplItem.node to ImplItem.kind 2019-09-26 18:21:09 +01:00
varkor
95f6d72a60 Rename Expr.node to Expr.kind
For both `ast::Expr` and `hir::Expr`.
2019-09-26 18:21:09 +01:00
Stephen Crane
0ec4513d5f 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 which has an expansion context, not the span of the format string
which does not.
2019-09-25 17:45:15 -07:00
Mazdak Farrokhzad
9e12827d56
Rollup merge of #64702 - sinkuu:deps, r=jonas-schievink
Remove unused dependencies
2019-09-24 23:45:27 +02:00
Mazdak Farrokhzad
f70665a846 cleanup librustc_errors Handler code. 2019-09-23 22:28:14 +02:00
Shotaro Yamada
0423c2a7a3 Remove unused dependencies 2019-09-23 15:25:00 +09:00
Mazdak Farrokhzad
da58e11d02
Rollup merge of #64670 - Mark-Simulacrum:ext-build-simplify, r=petrochenkov
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-23 00:36:34 +02:00
Mark Rousskov
8417ac67c3 Inline attribute constructors 2019-09-21 16:14:10 -04:00
Mark Rousskov
67d88f607e Remove constraints argument from path_all
It was never used
2019-09-21 15:01:39 -04:00
gaolei
1ab5593f95 factor out pluralisation remains after #64280 2019-09-20 00:25:27 +08:00
Aaron Hill
3daa8bd2e4
Generate proc macro harness in AST order.
This ensures that we match the order used by proc macro metadata
serialization.

Fixes #64251
2019-09-17 19:10:10 -04:00
Matthew Jasper
8ab67c8f56 Remove with_legacy_ctxt 2019-09-15 09:15:38 +01:00
Matthew Jasper
5ae3830d58 Give more Idents spans 2019-09-15 09:15:38 +01:00
Matthew Jasper
57a45e9cbd Avoid some unnecessary &str to Ident conversions 2019-09-15 09:15:37 +01:00
bors
457666860c Auto merge of #64080 - estebank:parse-format-comma, r=zackmdavis
Be accurate on `format!` parse error expectations

Fix https://github.com/rust-lang/rust/issues/57277.
2019-09-14 06:10:08 +00:00
Caio
63a5f399ae Resolve attributes in several places
Arm, Field, FieldPat, GenericParam, Param, StructField and Variant
2019-09-09 09:27:15 -03:00
Mazdak Farrokhzad
89a69fd76d
Rollup merge of #64139 - Mark-Simulacrum:strip-legacy-proc-macro, r=petrochenkov
Migrate internal diagnostic registration to macro_rules

Review is best done commit-by-commit.

Fixes #64132.
2019-09-07 20:01:44 +02:00
Mazdak Farrokhzad
3d4cb50312
Rollup merge of #64243 - petrochenkov:cmdattr, r=alexcrichton
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-07 08:06:17 +02:00
Mazdak Farrokhzad
d5caeac096
Rollup merge of #64233 - varkor:correct-pluralisation, r=estebank
Correct pluralisation of various diagnostic messages
2019-09-07 08:06:11 +02:00
Mazdak Farrokhzad
db493ef613
Rollup merge of #63919 - matthewjasper:remove-gensymmed, r=petrochenkov
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-07 08:06:04 +02:00
Vadim Petrochenkov
3dde650efa Move injection of attributes from command line to libsyntax_ext 2019-09-06 23:46:16 +03:00
varkor
f6481ed1c3 Correct pluralisation of various diagnostic messages 2019-09-06 19:21:20 +01:00
Mazdak Farrokhzad
3c1630aa38
Rollup merge of #64111 - Centril:ast-only-patkind-or, r=petrochenkov
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-06 09:36:39 +02:00
Matthew Jasper
3f3fc52bfa Simplify std lib injection 2019-09-05 22:48:03 +01:00
Mark Rousskov
41b39fce98 Remove rustc_diagnostic_macros feature 2019-09-05 12:35:18 -04:00