about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-09-22pull mbe token tree definition upAleksey Kladov-234/+243
2019-09-22docstring for mbe moduleAleksey Kladov-0/+5
2019-09-22move mbe module to a separate fileAleksey Kladov-7/+6
2019-09-22rename tt -> mbe, part 2Aleksey Kladov-17/+17
2019-09-22rename libsyntax::ext::tt to mbeAleksey Kladov-0/+0
mbe stands for macro-by-example
2019-09-22reduce visibility of a bunch of stuff in ext::ttAleksey Kladov-56/+48
2019-09-21review comments: wordingEsteban Küber-1/+1
2019-09-21Parse assoc type bounds in generic params and provide custom diagnosticEsteban Küber-38/+61
2019-09-21Inline attribute constructorsMark Rousskov-14/+0
2019-09-21Inline ty_inferMark Rousskov-5/+1
2019-09-21Remove unused codeMark Rousskov-291/+3
2019-09-21Rollup merge of #64664 - matklad:remove-ast-builder, r=Mark-SimulacrumMazdak Farrokhzad-3/+0
fully remove AstBuilder The mentioned Cargo test is fixed in https://github.com/rust-lang/cargo/pull/7210 I think this can be removed now?
2019-09-21Remove constraints argument from path_allMark Rousskov-6/+5
It was never used
2019-09-21fully remove AstBuilderAleksey Kladov-3/+0
The mentioned Cargo test is fixed in https://github.com/rust-lang/cargo/pull/7210
2019-09-21Rollup merge of #64342 - glorv:master, r=varkorMazdak Farrokhzad-13/+13
factor out pluralisation remains after #64280 there are two case that doesn't not match the original macro pattern at [here](https://github.com/rust-lang/rust/blob/master/src/librustc_lint/unused.rs#L146) and [here](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/diagnostics.rs#L539) as the provided param is already a bool or the check condition is not `x != 1`, so I change the macro accept a boolean expr instead of number to fit all the cases. @Centril please review Fixes #64238.
2019-09-21Rollup merge of #64136 - crgl:doc-from-parser-lhs, r=CentrilMazdak Farrokhzad-0/+7
Document From trait for LhsExpr in parser Add doc for From trait for converting P<Expr> and Option<ThinVec<Attribute>> to LhsExpr As part of issue rust-lang#51430 (cc @skade). Both of these should just be moving an address and setting a discriminant in an enum. The main thing I'm not sure about is whether it's worth documenting the branch in the From<Option<ThinVec<Attribute>>. As far as I can tell it doesn't seem like it is optimized away (although if the discriminant happened to work out you could just copy the pointer and the discriminant which might be cheaper, but that's not guaranteed). So it seems like if it's being called often, it's doubling the number of possible branch mispredictions on this Option, which could be a significant cost. Let me know if there's anything that needs fixing and I'll get to it as soon as possible!
2019-09-21Rollup merge of #64010 - c410-f3r:stabilize-attrs-fn, r=CentrilMazdak Farrokhzad-16/+5
Stabilize `param_attrs` in Rust 1.39.0 # Stabilization proposal I propose that we stabilize `#![feature(param_attrs)]`. Tracking issue: #60406 Version: 1.39 (2019-09-26 => beta, 2019-11-07 => stable). ## What is stabilized It is now possible to add outer attributes like `#[cfg(..)]` on formal parameters of functions, closures, and function pointer types. For example: ```rust fn len( #[cfg(windows)] slice: &[u16], #[cfg(not(windows))] slice: &[u8], ) -> usize { slice.len() } ``` ## What isn't stabilized * Documentation comments like `/// Doc` on parameters. * Code expansion of a user-defined `#[proc_macro_attribute]` macro used on parameters. * Built-in attributes other than `cfg`, `cfg_attr`, `allow`, `warn`, `deny`, and `forbid`. Currently, only the lints `unused_variables` and `unused_mut` have effect and may be controlled on parameters. ## Motivation The chief motivations for stabilizing `param_attrs` include: * Finer conditional compilation with `#[cfg(..)]` and linting control of variables. * Richer macro DSLs created by users. * External tools and compiler internals can take advantage of the additional information that the parameters provide. For more examples, see the [RFC][rfc motivation]. ## Reference guide In the grammar of function and function pointer, the grammar of variadic tails (`...`) and parameters are changed respectively from: ```rust FnParam = { pat:Pat ":" }? ty:Type; VaradicTail = "..."; ``` into: ```rust FnParam = OuterAttr* { pat:Pat ":" }? ty:Type; VaradicTail = OuterAttr* "..."; ``` The grammar of a closure parameter is changed from: ```rust ClosureParam = pat:Pat { ":" ty:Type }?; ``` into: ```rust ClosureParam = OuterAttr* pat:Pat { ":" ty:Type }?; ``` More generally, where there's a list of formal (value) parameters separated or terminated by `,` and delimited by `(` and `)`. Each parameter in that list may optionally be prefixed by `OuterAttr+`. Note that in all cases, `OuterAttr*` applies to the whole parameter and not just the pattern. This distinction matters in pretty printing and in turn for macros. ## History * On 2018-10-15, @Robbepop proposes [RFC 2565][rfc], "Attributes in formal function parameter position". * On 2019-04-30, [RFC 2565][rfc] is merged and the tracking issue is made. * On 2019-06-12, a partial implementation was completed. The implementation was done in [#60669][60669] by @c410-f3r and the PR was reviewed by @petrochenkov and @Centril. * On 2019-07-29, [#61238][61238] was fixed in [#61856][61856]. The issue fixed was that lint attributes on function args had no effect. The PR was written by @c410-f3r and reviewed by @matthewjasper, @petrochenkov, and @oli-obk. * On 2019-08-02, a bug [#63210][63210] was filed wherein the attributes on formal parameters would not be passed to macros. The issue was about forgetting to call the relevant method in `fn print_arg` in the pretty printer. In [#63212][63212], written by @Centril on 2019-08-02 and reviewed by @davidtwco, the issue aforementioned was fixed. * This PR stabilizes `param_attrs`. ## Tests * [On Rust 2018, attributes aren't permitted on function parameters without a pattern in trait definitions.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs) * [All attributes that should be allowed. This includes `cfg`, `cfg_attr`, and lints check attributes.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs) * [Built-in attributes, which should be forbidden, e.g., `#[test]`, are.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs) * [`cfg` and `cfg_attr` are properly evaluated.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs) * [`unused_mut`](https://github.com/rust-lang/rust/blob/46f405ec4d7c6bf16fc2eaafe7541019f1da2996/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs) and [`unused_variables`](https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/lint-unused-variables.rs) are correctly applied to parameter patterns. * [Pretty printing takes formal parameter attributes into account.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs) ## Possible future work * Custom attributes inside function parameters aren't currently supported but it is something being worked on internally. * Since documentation comments are syntactic sugar for `#[doc(...)]`, it is possible to allow literal `/// Foo` comments on function parameters. [rfc motivation]: https://github.com/rust-lang/rfcs/blob/master/text/2565-formal-function-parameter-attributes.md#motivation [rfc]: https://github.com/rust-lang/rfcs/pull/2565 [60669]: https://github.com/rust-lang/rust/pull/60669 [61856]: https://github.com/rust-lang/rust/pull/61856 [63210]: https://github.com/rust-lang/rust/issues/63210 [61238]: https://github.com/rust-lang/rust/issues/61238 [63212]: https://github.com/rust-lang/rust/pull/63212 This report is a collaborative work with @Centril.
2019-09-20factor out pluralisation remains after #64280gaolei-13/+13
2019-09-18Fix backticks in documentationJoshua Groves-2/+2
2019-09-17Rollup merge of #64486 - matthewjasper:hygiene-debugging, r=petrochenkovTyler Mandry-3/+9
Print out more information for `-Zunpretty=expanded,hygiene` I've found this helpful when trying to understand how hygiene works. Closes #16420
2019-09-17Print syntax contexts and marks when printing hygiene informationMatthew Jasper-0/+2
2019-09-17Remove unused methods from HandlerMark Rousskov-3/+0
2019-09-17Remove Handler::cancelMark Rousskov-12/+6
2019-09-17Privatize DiagnosticBuilder constructorsMark Rousskov-5/+5
2019-09-17Replace DiagnosticBuilder with Diagnostic when emitting errorMark Rousskov-8/+20
2019-09-16Document `From` trait for `LhsExpr`Charles Gleason-0/+7
2019-09-16Rollup merge of #64499 - nnethercote:use-Symbol-in-two-more-functions, ↵Mazdak Farrokhzad-22/+22
r=petrochenkov Use `Symbol` in two more functions. r? @petrochenkov
2019-09-16Use `Symbol` in two more functions.Nicholas Nethercote-22/+22
2019-09-15or-patterns: remove hack from lowering.Mazdak Farrokhzad-2/+0
2019-09-15Print visibility of `macro` itemsMatthew Jasper-3/+7
2019-09-15Auto merge of #64469 - matthewjasper:increase-hygiene-use, r=petrochenkovbors-12/+5
Cleanup handling of hygiene for built-in macros This makes most identifiers generated by built-in macros use def-site hygiene, not only the ones that previously used gensyms. * `ExtCtxt::ident_of` now takes a `Span` and is preferred to `Ident::{from_str, from_str_and_span}` * Remove `Span::with_legacy_ctxt` * `assert` now uses call-site hygiene because it needs to resolve `panic` unhygienically. * `concat_idents` now uses call-site hygiene because it wouldn't be very useful with def-site hygiene. * everything else is moved to def-site hygiene r? @petrochenkov
2019-09-15Remove `with_legacy_ctxt`Matthew Jasper-7/+0
2019-09-15Give more `Idents` spansMatthew Jasper-4/+4
2019-09-15Avoid some unnecessary `&str` to `Ident` conversionsMatthew Jasper-1/+1
2019-09-14feature_gate: Eliminate `check::Context`Vadim Petrochenkov-59/+51
Use `PostExpansionVisitor` directly instead
2019-09-14feature_gate: Merge various attribute gating functionsVadim Petrochenkov-95/+46
2019-09-14feature_gate: Remove dead code from attribute checkingVadim Petrochenkov-42/+8
Same checks are performed during name resolution, and all attributes go through name resolution now
2019-09-14Rollup merge of #64374 - nnethercote:box-DiagnosticBuilder, r=zackmdavisMazdak Farrokhzad-0/+7
Box `DiagnosticBuilder`. It's a large type -- 176 bytes on 64-bit. And it's passed around and returned from a lot of functions, including within `PResult`. This commit boxes it, which reduces memory traffic. In particular, `PResult` shrinks to 16 bytes in the best case; this reduces instruction counts by up to 2% on various workloads. The commit touches a lot of lines but it's almost all trivial plumbing changes.
2019-09-12Box `DiagnosticBuilder`.Nicholas Nethercote-0/+7
It's a large type -- 176 bytes on 64-bit. And it's passed around and returned from a lot of functions, including within PResult. This commit boxes it, which reduces memory traffic. In particular, `PResult` shrinks to 16 bytes in the best case; this reduces instruction counts by up to 2% on various workloads.
2019-09-11Stabilize `param_attrs` in Rust 1.39.0Caio-16/+5
2019-09-09Auto merge of #64313 - Centril:rollup-7w8b67g, r=Centrilbors-19/+541
Rollup of 5 pull requests Successful merges: - #63468 (Resolve attributes in several places) - #64121 (Override `StepBy::{try_fold, try_rfold}`) - #64278 (check git in bootstrap.py) - #64306 (Fix typo in config.toml.example) - #64312 (Unify escape usage) Failed merges: r? @ghost
2019-09-09Auto merge of #63118 - Centril:stabilize-bind-by-move, r=matthewjasperbors-4/+3
Stabilize `bind_by_move_pattern_guards` in Rust 1.39.0 Closes https://github.com/rust-lang/rust/issues/15287. After stabilizing `#![feature(bind_by_move_pattern_guards)]`, you can now use bind-by-move bindings in patterns and take references to those bindings in `if` guards of `match` expressions. For example, the following now becomes legal: ```rust fn main() { let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]); match array { nums // ---- `nums` is bound by move. if nums.iter().sum::<u8>() == 10 // ^------ `.iter()` implicitly takes a reference to `nums`. => { drop(nums); // --------- Legal as `nums` was bound by move and so we have ownership. } _ => unreachable!(), } } ``` r? @matthewjasper
2019-09-09Resolve attributes in several placesCaio-19/+541
Arm, Field, FieldPat, GenericParam, Param, StructField and Variant
2019-09-08Dont use gate bind_by_move_pattern_guards internally.Mazdak Farrokhzad-1/+1
2019-09-08Stabilize bind_by_move_pattern_guards in 1.39.0.Mazdak Farrokhzad-3/+2
2019-09-08Rollup merge of #64066 - petrochenkov:softstab, r=matthewjasperMazdak Farrokhzad-16/+12
Support "soft" feature-gating using a lint Use it for feature-gating `#[bench]`. Closes https://github.com/rust-lang/rust/issues/63798.
2019-09-07Support "soft" feature-gating using a lintVadim Petrochenkov-16/+12
Use it for feature-gating `#[bench]`
2019-09-07Rollup merge of #64226 - alexreg:rush-pr-3, r=centrilMazdak Farrokhzad-515/+528
Aggregation of cosmetic changes made during work on REPL PRs: libsyntax Factored out from hacking on rustc for work on the REPL. r? @Centril
2019-09-07Rollup merge of #64139 - Mark-Simulacrum:strip-legacy-proc-macro, r=petrochenkovMazdak Farrokhzad-235/+46
Migrate internal diagnostic registration to macro_rules Review is best done commit-by-commit. Fixes #64132.
2019-09-07Apply suggestions from code reviewAlexander Regueiro-18/+17