Commit Graph

131 Commits

Author SHA1 Message Date
Mazdak Farrokhzad 0a5b38f9c3 move Attribute::with_desugared_doc to librustdoc 2019-10-25 04:38:42 +02:00
Nicholas Nethercote ac6daed384 Remove many unnecessary trait derivations. 2019-10-21 20:59:18 +11:00
Nicholas Nethercote e4ec4a6da3 Change MetaItem::tokens() to MetaItem::token_trees_and_joints().
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-18 13:25:17 +11:00
Nicholas Nethercote 212ae58f36 Change Lit::tokens() to Lit::token_tree().
Because most of the call sites have an easier time working with a
`TokenTree` instead of a `TokenStream`.
2019-10-18 13:25:17 +11: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 c189565edc syntax: reduce visibilities 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad 41bfe94d40 syntax: extract parse_cfg_attr 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad 7d7969d065 syntax: extract parse_derive_paths 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
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
Vadim Petrochenkov 957986d056 syntax: Support modern attribute syntax in the meta matcher 2019-09-30 22:58:22 +03:00
Vadim Petrochenkov 535d4743a4 syntax: Split ast::Attribute into container and inner parts 2019-09-30 22:36:25 +03:00
varkor 38121173e2 Rename MetaItem.node to MetaItem.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 17726f6b52 Rename Lit.node to Lit.kind 2019-09-26 18:21:09 +01:00
Oliver Scherer 7767e7fb16 Stabilize str::len, [T]::len, is_empty and str::as_bytes as const fn 2019-09-24 12:56:44 +02:00
Mazdak Farrokhzad 4ea77975ab Rollup merge of #64066 - petrochenkov:softstab, r=matthewjasper
Support "soft" feature-gating using a lint

Use it for feature-gating `#[bench]`.

Closes https://github.com/rust-lang/rust/issues/63798.
2019-09-08 00:07:31 +02:00
Vadim Petrochenkov f7434aef26 Support "soft" feature-gating using a lint
Use it for feature-gating `#[bench]`
2019-09-07 21:37:51 +03:00
Alexander Regueiro 49d2fd1725 Aggregation of cosmetic changes made during work on REPL PRs: libsyntax 2019-09-07 16:29:04 +01:00
Vadim Petrochenkov 3dde650efa Move injection of attributes from command line to libsyntax_ext 2019-09-06 23:46:16 +03:00
Kevin Per e0ce9f8c0a Cleanup: Consistently use Param instead of Arg #62426 2019-08-27 14:07:41 +02:00
Vadim Petrochenkov 6cb28b6617 Ident::with_empty_ctxt -> Ident::with_dummy_span
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
2019-08-15 20:39:26 +03:00
Vadim Petrochenkov 73d2da0894 Remove Spanned from mk_name_value_item_str and expr_to_spanned_string 2019-08-15 11:44:22 +03:00
Caio 6a42b0b28d Merge Variant and Variant_ 2019-08-14 14:47:01 -03:00
Mark Rousskov 8849149745 Make mk_attr_id private to libsyntax 2019-08-05 08:48:22 -04:00
Mark Rousskov 24a491f40c Drop explicit span argument from mk_name_value_item 2019-08-05 08:48:22 -04:00
Mark Rousskov ab3fb1e775 Drop span argument from mk_list_item 2019-08-05 08:45:00 -04:00
Mark Rousskov 0f985817bd Replace AstBuilder with inherent methods 2019-07-31 08:55:37 -04:00
Mark Rousskov f78bf50dec Remove span argument from mk_attr_{inner,outer}
Always the same as the passed MetaItem
2019-07-31 08:55:37 -04:00
Mark Rousskov b2c5065b04 Remove Span argument from ExtCtxt::attribute
MetaItem.span was always equivalent
2019-07-31 08:55:37 -04:00
Mark Rousskov 0a42badd4c Remove AttrId from Attribute constructors 2019-07-31 08:55:37 -04:00
Mark Rousskov 804f0f3c20 Unify spanned and non-spanned Attribute ctors
There is no difference in the code/arguments, so go with the shorter
name throughout the code.
2019-07-31 08:55:36 -04:00
Mazdak Farrokhzad e1de70b045 Rollup merge of #62735 - petrochenkov:galloc, r=alexcrichton
Turn `#[global_allocator]` into a regular attribute macro

It was a 99% macro with exception of some diagnostic details.

As a result of the change, `#[global_allocator]` now works in nested modules and even in nameless blocks.

Fixes https://github.com/rust-lang/rust/issues/44113
Fixes https://github.com/rust-lang/rust/issues/58072
2019-07-25 23:21:00 +02:00
Vadim Petrochenkov 6e4f16173c Demote template check error to a lint for #[test] and #[bench] 2019-07-24 12:29:45 +03:00
Vadim Petrochenkov 76b1ffaf6c syntax_ext: Reuse built-in attribute template checking for macro attributes 2019-07-24 12:29:45 +03:00
Samy Kacimi 2083a123a5 Normalize use of backticks in compiler messages for libsyntax/*
https://github.com/rust-lang/rust/issues/60532
2019-07-23 20:03:20 +02:00
Vadim Petrochenkov 1ee0ce82cb syntax: Migrate built-in macros to the regular stability checking 2019-07-07 13:04:07 +03:00
Vadim Petrochenkov 3542995ff9 syntax: Keep full Stability in SyntaxExtension 2019-07-07 13:04:07 +03:00
Vadim Petrochenkov 920a17a60c privacy: Only opaque macros leak private things 2019-07-06 16:59:08 +03:00
Mazdak Farrokhzad 485a084b45 Rollup merge of #61545 - flip1995:internal_lints, r=oli-obk
Implement another internal lints

cc #49509

This adds ~~two~~ one internal lint~~s~~:
1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc #59669
2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in #49509~~

~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~

TODO (not directly relevant for review):
- [ ] https://github.com/rust-lang/rust/pull/59316#discussion_r280186517 (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb)
- [x] https://github.com/rust-lang/rust/pull/61735#discussion_r292389870
- [x] Check explicitly for the `{declare,impl}_lint_pass!` macros

r? @oli-obk
2019-07-05 20:26:51 +02:00
Jeremy Stucki 87e8613fd4 Remove needless lifetimes 2019-07-03 10:00:23 +02:00
flip1995 8e087cdd98 Use symbols in lint tool list 2019-06-24 18:14:04 +02:00
flip1995 7de6f54728 Turn internal lints into tool lints 2019-06-24 10:45:21 +02:00
bors 3f511ade5b Auto merge of #60669 - c410-f3r:attrs-fn, r=petrochenkov
Allow attributes in formal function parameters

Implements https://github.com/rust-lang/rust/issues/60406.

This is my first contribution to the compiler and since this is a large and complex project, I am not fully aware of the consequences of the changes I have made.

**TODO**

- [x] Forbid some built-in attributes.
- [x] Expand cfg/cfg_attr
2019-06-12 07:38:01 +00:00
Caio 1eaaf440d5 Allow attributes in formal function parameters 2019-06-09 07:58:40 -03:00
Vadim Petrochenkov 0ca3c2f881 syntax: Move most of the TokenKind methods to Token 2019-06-08 22:38:12 +03:00
Vadim Petrochenkov 3da094319c parser: self.span -> self.token.span 2019-06-07 13:51:23 +03:00