about summary refs log tree commit diff
path: root/src/libsyntax/attr/mod.rs
AgeCommit message (Collapse)AuthorLines
2019-03-17Make meta-item API compatible with `LocalInternedString::get` soundness fixVadim Petrochenkov-7/+7
2019-03-16Refactor away `NestedMetaItemKind`Vadim Petrochenkov-31/+20
Remove methods `Attribute::span` and `MetaItem::span` duplicating public fields
2019-03-16Rename `MetaItem::ident` to `MetaItem::path`Vadim Petrochenkov-16/+16
2019-03-16syntax: Do not accidentally treat multi-segment meta-items as single-segmentVadim Petrochenkov-42/+35
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 #58166 - euclio:deprecation-shorthand, r=petrochenkovMazdak Farrokhzad-0/+4
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-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-3/+3
2019-02-07libsyntax => 2018Taiki Endo-20/+22
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-0/+4
2019-01-24Implement optimize(size) and optimize(speed)Simonas Kazlauskas-2/+2
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-19/+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-19/+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-10/+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-20suggest to trim prefix in nested meta itemscsmoe-0/+9
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-2/+2
2018-08-31Implement the `min_const_fn` feature gateOliver Schneider-1/+1
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
2018-08-02Auto merge of #52841 - petrochenkov:premacro, r=alexcrichtonbors-14/+1
resolve: Implement prelude search for macro paths, implement tool attributes When identifier is macro path is resolved in scopes (i.e. the first path segment - `foo` in `foo::mac!()` or `foo!()`), scopes are searched in the same order as for non-macro paths - items in modules, extern prelude, tool prelude (see later), standard library prelude, language prelude, but with some extra shadowing restrictions (names from globs and macro expansions cannot shadow names from outer scopes). See the comment in `fn resolve_lexical_macro_path_segment` for more details. "Tool prelude" currently contains two "tool modules" `rustfmt` and `clippy`, and is searched immediately after extern prelude. This makes the [possible long-term solution](https://github.com/rust-lang/rfcs/blob/master/text/2103-tool-attributes.md#long-term-solution) for tool attributes exactly equivalent to the existing extern prelude scheme, except that `--extern=my_crate` making crate names available in scope is replaced with something like `--tool=my_tool` making tool names available in scope. The `tool_attributes` feature is still unstable and `#![feature(tool_attributes)]` now implicitly enables `#![feature(use_extern_macros)]`. `use_extern_macros` is a prerequisite for `tool_attributes`, so their stabilization will happen in the same order. If `use_extern_macros` is not enabled, then tool attributes are treated as custom attributes (this is temporary, anyway). Fixes https://github.com/rust-lang/rust/issues/52576 Fixes https://github.com/rust-lang/rust/issues/52512 Fixes https://github.com/rust-lang/rust/issues/51277 cc https://github.com/rust-lang/rust/issues/52269
2018-08-01Switch syntax attribute tracking to BitVectorMark Rousskov-28/+4
2018-08-01resolve: Implement prelude search for macro pathsVadim Petrochenkov-14/+1
resolve/expansion: Implement tool attributes
2018-07-27Add the -Zcrate-attr=foo nightly rustc flag to inject crate attributesPietro Albini-2/+32
2018-07-04Improving span of unknown lint tool error messageflip1995-6/+8
2018-07-04Implementation of tool lintsflip1995-0/+11
2018-06-30factor built-in attribute parsing into submoduleAndy Russell-0/+810