about summary refs log tree commit diff
path: root/src/libsyntax/attr
AgeCommit message (Collapse)AuthorLines
2019-04-23Add rustc_allow_const_fn_ptrTaylor Cramer-4/+14
2019-04-15Make check_name genericJohn Kåre Alsaker-24/+12
2019-04-15Use a proc macro to declare preallocated symbolsJohn Kåre Alsaker-0/+21
2019-03-17Make meta-item API compatible with `LocalInternedString::get` soundness fixVadim Petrochenkov-30/+30
2019-03-16Refactor away `NestedMetaItemKind`Vadim Petrochenkov-59/+48
Remove methods `Attribute::span` and `MetaItem::span` duplicating public fields
2019-03-16Rename `MetaItem::ident` to `MetaItem::path`Vadim Petrochenkov-25/+25
2019-03-16syntax: Do not accidentally treat multi-segment meta-items as single-segmentVadim Petrochenkov-90/+81
2019-02-27Mention `unwind(aborts)` in diagnostics for `#[unwind]`Vadim Petrochenkov-31/+17
Simplify input validation for `#[unwind]`, add tests
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-2/+2
It's present within `Token::Interpolated` as an optimization, so that if a nonterminal is converted to a `TokenStream` multiple times, the first-computed value is saved and reused. But in practice it's not needed. `interpolated_to_tokenstream()` is a cold function: it's only called a few dozen times while compiling rustc itself, and a few hundred times across the entire `rustc-perf` suite. Furthermore, when it is called, it is almost always the first conversion, so no benefit is gained from it. So this commit removes `LazyTokenStream`, along with the now-unnecessary `Token::interpolated()`. As well as a significant simplification, the removal speeds things up slightly, mostly due to not having to `drop` the `LazyTokenStream` instances.
2019-02-13Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasperMazdak Farrokhzad-1/+1
Rename rustc_errors dependency in rust 2018 crates I think this is a better solution than `use rustc_errors as errors` in `lib.rs` and `use crate::errors` in modules. Related: rust-lang/cargo#5653 cc #58099 r? @Centril
2019-02-13Rollup merge of #58166 - euclio:deprecation-shorthand, r=petrochenkovMazdak Farrokhzad-60/+69
allow shorthand syntax for deprecation reason Fixes #48271. Created based on discussion in #56896.
2019-02-12Auto merge of #58051 - SimonSapin:str_escape, r=alexcrichtonbors-1/+1
Stabilize str::escape_* methods with new return types… … that implement `Display` and `Iterator<Item=char>`, as proposed in FCP: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2019-02-13Cleanup importsTaiki Endo-1/+1
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-1/+1
2019-02-12New return types for str::escape_* that impl Display and Iterator<char>Simon Sapin-1/+1
As FCP’ed in the tracking issue: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2019-02-10rustc: doc commentsAlexander Regueiro-6/+6
2019-02-07libsyntax => 2018Taiki Endo-28/+31
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-27/+33
This commit changes `syntax::fold::Folder` from a functional style (where most methods take a `T` and produce a new `T`) to a more imperative style (where most methods take and modify a `&mut T`), and renames it `syntax::mut_visit::MutVisitor`. The first benefit is speed. The functional style does not require any reallocations, due to the use of `P::map` and `MoveMap::move_{,flat_}map`. However, every field in the AST must be overwritten; even those fields that are unchanged are overwritten with the same value. This causes a lot of unnecessary memory writes. The imperative style reduces instruction counts by 1--3% across a wide range of workloads, particularly incremental workloads. The second benefit is conciseness; the imperative style is usually more concise. E.g. compare the old functional style: ``` fn fold_abc(&mut self, abc: ABC) { ABC { a: fold_a(abc.a), b: fold_b(abc.b), c: abc.c, } } ``` with the imperative style: ``` fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) { visit_a(a); visit_b(b); } ``` (The reductions get larger in more complex examples.) Overall, the patch removes over 200 lines of code -- even though the new code has more comments -- and a lot of the remaining lines have fewer characters. Some notes: - The old style used methods called `fold_*`. The new style mostly uses methods called `visit_*`, but there are a few methods that map a `T` to something other than a `T`, which are called `flat_map_*` (`T` maps to multiple `T`s) or `filter_map_*` (`T` maps to 0 or 1 `T`s). - `move_map.rs`/`MoveMap`/`move_map`/`move_flat_map` are renamed `map_in_place.rs`/`MapInPlace`/`map_in_place`/`flat_map_in_place` to reflect their slightly changed signatures. - Although this commit renames the `fold` module as `mut_visit`, it keeps it in the `fold.rs` file, so as not to confuse git. The next commit will rename the file.
2019-02-05allow shorthand syntax for deprecation reasonAndy Russell-60/+69
2019-01-30Add suggestions to deprecation lintsOliver Scherer-1/+4
2019-01-26remove `_with_applicability` from suggestion fnsAndy Russell-3/+3
2019-01-24Implement optimize(size) and optimize(speed)Simonas Kazlauskas-2/+9
2019-01-20Auto merge of #57651 - JohnTitor:give-char-type, r=estebankbors-0/+1
Implement new literal type `Err` Fixes #57384 I removed `return Ok`, otherwise, two errors occur. Any solutions? r? @estebank
2019-01-20Mark incorrect recovered `char` literals as `TyErr` to avoid type errorsYuki Okushi-0/+1
2019-01-19Rollup merge of #57486 - nnethercote:simplify-TokenStream-more, r=petrochenkovMazdak Farrokhzad-1/+1
Simplify `TokenStream` some more These commits simplify `TokenStream`, remove `ThinTokenStream`, and avoid some clones. The end result is simpler code and a slight perf win on some benchmarks. r? @petrochenkov
2019-01-16Auto merge of #57321 - petrochenkov:atokens, r=nikomatsakisbors-22/+24
Implement basic input validation for built-in attributes Correct top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is enforced for built-in attributes, built-in attributes must also fit into the "meta-item" syntax (aka the "classic attribute syntax"). For some subset of attributes (found by crater run), errors are lowered to deprecation warnings. NOTE: This PR previously included https://github.com/rust-lang/rust/pull/57367 as well.
2019-01-14Remove `ThinTokenStream`.Nicholas Nethercote-1/+1
`TokenStream` is now almost identical to `ThinTokenStream`. This commit removes the latter, replacing it with the former.
2019-01-13Implement basic input validation for built-in attributesVadim Petrochenkov-22/+24
2019-01-08Make `TokenStream` less recursive.Nicholas Nethercote-3/+5
`TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
2018-12-25Remove licensesMark Rousskov-20/+0
2018-12-12Rename `TokenStream::concat` and remove `TokenStream::concat_rc_vec`.Nicholas Nethercote-3/+3
`TokenStream::new` is a better name for the former, and the latter is now just equivalent to `TokenStream::Stream`.
2018-12-10Remove `tokenstream::Delimited`.Nicholas Nethercote-7/+8
Because it's an extra type layer that doesn't really help; in a couple of places it actively gets in the way, and overall removing it makes the code nicer. It does, however, move `tokenstream::TokenTree` further away from the `TokenTree` in `quote.rs`. More importantly, this change reduces the size of `TokenStream` from 48 bytes to 40 bytes on x86-64, which is enough to slightly reduce instruction counts on numerous benchmarks, the best by 1.5%. Note that `open_tt` and `close_tt` have gone from being methods on `Delimited` to associated methods of `TokenTree`.
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-2/+2
2018-12-04updates all Filename variants to take a fingerprintMatthew Russo-1/+1
2018-10-31Fix feature gate only being checked on first repr attr.Cameron Hart-0/+5
2018-10-22optimize unsupported literal diag messagecsmoe-39/+70
2018-10-20update meta item checking testcsmoe-1/+3
2018-10-20suggest to trim prefix in nested meta itemscsmoe-3/+27
2018-10-20handle errors based on parse_sesscsmoe-31/+36
2018-10-20suggest to remove prefix `b` in lint stringcsmoe-45/+84
2018-10-05Stabilize `min_const_fn`Oliver Schneider-2/+1
2018-10-03Update error id to an unused oneOliver Schneider-1/+1
2018-10-03Only promote calls to `#[rustc_promotable]` const fnsOliver Schneider-1/+22
2018-09-09Auto merge of #53902 - dtolnay:group, r=petrochenkovbors-2/+2
proc_macro::Group::span_open and span_close Before this addition, every delimited group like `(`...`)` `[`...`]` `{`...`}` has only a single Span that covers the full source location from opening delimiter to closing delimiter. This makes it impossible for a procedural macro to trigger an error pointing to just the opening or closing delimiter. The Rust compiler does not seem to have the same limitation: ```rust mod m { type T = } ``` ```console error: expected type, found `}` --> src/main.rs:3:1 | 3 | } | ^ ``` On that same input, a procedural macro would be forced to trigger the error on the last token inside the block, on the entire block, or on the next token after the block, none of which is really what you want for an error like above. This commit adds `group.span_open()` and `group.span_close()` which access the Span associated with just the opening delimiter and just the closing delimiter of the group. Relevant to Syn as we implement real error messages for when parsing fails in a procedural macro: https://github.com/dtolnay/syn/issues/476. ```diff impl Group { fn span(&self) -> Span; + fn span_open(&self) -> Span; + fn span_close(&self) -> Span; } ``` Fixes #48187 r? @alexcrichton
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-2/+2
2018-09-06Validate syntax of `cfg` attributesVadim Petrochenkov-1/+15
2018-08-31Implement the `min_const_fn` feature gateOliver Schneider-15/+13
2018-08-19mv (mod) codemap source_mapDonato Sciarra-1/+1
2018-08-15syntax: Enforce attribute grammar in the parserVadim Petrochenkov-2/+2
2018-08-13Move SmallVec and ThinVec out of libsyntaxljedrz-1/+1