about summary refs log tree commit diff
path: root/src/libsyntax_ext
AgeCommit message (Collapse)AuthorLines
2019-04-03Deny internal lints on non conflicting cratesflip1995-0/+1
- libarena - librustc_allocator - librustc_borrowck - librustc_codegen_ssa - librustc_codegen_utils - librustc_driver - librustc_errors - librustc_incremental - librustc_metadata - librustc_passes - librustc_privacy - librustc_resolve - librustc_save_analysis - librustc_target - librustc_traits - libsyntax - libsyntax_ext - libsyntax_pos
2019-03-27Visit path in `walk_mac`varkor-1/+1
2019-03-27Auto merge of #55780 - ogoffart:span_source_text, r=petrochenkovbors-0/+3
Introduce proc_macro::Span::source_text A function to extract the actual source behind a Span. Background: I would like to use `syn` in a `build.rs` script to parse the rust code, and extract part of the source code. However, `syn` only gives access to proc_macro2::Span, and i would like to get the source code behind that. I opened an issue on proc_macro2 bug tracker for this feature https://github.com/alexcrichton/proc-macro2/issues/110 and @alexcrichton said the feature should first go upstream in proc_macro. So there it is! Since most of the Span API is unstable anyway, this is guarded by the same `proc_macro_span` feature as everything else.
2019-03-25Auto merge of #59256 - petrochenkov:derval2, r=Zoxcbors-3/+4
Make meta-item API compatible with `LocalInternedString::get` soundness fix r? @Zoxc
2019-03-24Remove methods is_struct/is_tuple/is_unit from VariantDataVadim Petrochenkov-53/+51
2019-03-17Make meta-item API compatible with `LocalInternedString::get` soundness fixVadim Petrochenkov-3/+4
2019-03-16Refactor away `NestedMetaItemKind`Vadim Petrochenkov-8/+8
Remove methods `Attribute::span` and `MetaItem::span` duplicating public fields
2019-03-16syntax: Introduce `Ident::can_be_raw`Vadim Petrochenkov-8/+4
2019-03-16syntax_ext: Validate `#[proc_macro_derive]` input betterVadim Petrochenkov-4/+14
Tweak some error wording
2019-03-16syntax: Do not accidentally treat multi-segment meta-items as single-segmentVadim Petrochenkov-28/+32
2019-03-06Simplify codeEsteban Küber-5/+2
2019-03-06Emit missing unclosed delimiter errorsEsteban Küber-2/+2
2019-02-27Rollup merge of #58678 - doctorn:refuse-async-fn-2015-edition, r=varkorMazdak Farrokhzad-1/+1
Deny `async fn` in 2015 edition This commit prevents code using `async fn` from being compiled in Rust 2015 edition. Compiling code of the form: ```rust async fn foo() {} ``` Will now result in the error: ``` error[E0670]: `async fn` is not permitted in the 2015 edition --> async.rs:1:1 | 1 | async fn foo() {} | ^^^^^ error: aborting due to error For more information about an error, try `rustc --explain E0670`. ``` This resolves #58652 and also resolves #53714. r? @varkor
2019-02-24Deny `async fn` in 2015 editionNathan Corbyn-1/+1
Fix style issues and update diagnostic messages Update src/librustc_passes/diagnostics.rs Co-Authored-By: doctorn <me@nathancorbyn.com> Deny nested `async fn` in Rust 2015 edition Deny nested `async fn` in Rust 2015 edition Deny nested `async fn` in Rust 2015 edition
2019-02-24Use ? in some macrosTaiki Endo-1/+1
2019-02-18Make `interpolated_to_tokenstream` a method on `Nonterminal`.Nicholas Nethercote-1/+1
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-1/+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-18Change `Token::interpolated_to_tokenstream()`.Nicholas Nethercote-2/+2
It is currently a method of `Token`, but it only is valid to call if `self` is a `Token::Interpolated`. This commit eliminates the possibility of misuse by changing it to an associated function that takes a `Nonterminal`, which also simplifies the call sites. This requires splitting out a new function, `nonterminal_to_string`.
2019-02-13Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasperMazdak Farrokhzad-13/+10
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-12Auto merge of #58051 - SimonSapin:str_escape, r=alexcrichtonbors-1/+0
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-12Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnikbors-15/+15
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-13Cleanup importsTaiki Endo-2/+2
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-13/+10
2019-02-12Auto merge of #58098 - oli-obk:maybe_allow_internal_unstable, r=petrochenkovbors-9/+27
Require a list of features in `#[allow_internal_unstable]` The blanket-permission slip is not great and will likely give us trouble some point down the road.
2019-02-12Stabilize str::escape_* methodsSimon Sapin-1/+0
FCP: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2019-02-11Use `Rc<[Symbol]>` instead of `Vec<Symbol>` to reduce # of allocsOliver Scherer-14/+15
2019-02-11Require a list of features to allow in `allow_internal_unstable`Oliver Scherer-9/+26
2019-02-10rustc: doc commentsAlexander Regueiro-15/+15
2019-02-10Revert removed #![feature(nll)]Taiki Endo-0/+1
2019-02-09Auto merge of #57944 - estebank:unclosed-delim-the-quickening, r=oli-obkbors-2/+5
Deduplicate mismatched delimiter errors Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently. Second attempt at #54029, follow up to #53949. Fix #31528.
2019-02-08Auto merge of #58191 - varkor:const-generics-ast, r=petrochenkovbors-1/+15
Add const generics to the AST This is mostly split out from https://github.com/rust-lang/rust/pull/53645 in an effort to make progress merging const generics piecewise instead of in one go. cc @yodaldevoid, @petrochenkov r? @eddyb
2019-02-07Support const generics in derivevarkor-1/+15
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07Remove images' url to make it work even without internet connectionGuillaume Gomez-3/+1
2019-02-07unify error handling to single methodEsteban Küber-2/+5
2019-02-07Deduplicate mismatched delimiter errorsEsteban Küber-1/+1
Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently.
2019-02-07Rollup merge of #58133 - taiki-e:libsyntax_ext-2018, r=Centrilkennytm-268/+269
libsyntax_ext => 2018 Transitions `libsyntax_ext` to Rust 2018; cc #58099 r? @Centril
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-8/+8
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-04libsyntax_ext => 2018Taiki Endo-268/+269
2019-01-28Conditionally skip two passes if their related attributes were not foundJohn Kåre Alsaker-2/+5
2019-01-26remove `_with_applicability` from suggestion fnsAndy Russell-2/+2
2019-01-24Remove quote_*! macros and associated APIsMark Simulacrum-21/+1
2019-01-22Rollup merge of #57537 - sinkuu:fmt_perf, r=alexcrichtonMazdak Farrokhzad-1/+4
Small perf improvement for fmt Added benchmark is based on #10761
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-35/+8
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-14Auto merge of #57387 - euclio:nonstandard-style-suggestions, r=oli-obkbors-2/+2
Use structured suggestions for nonstandard style lints This PR modifies the lints in the nonstandard_style group to use structured suggestions. Note that there's a bit of tricky span calculation going on for the `crate_name` attribute. It also simplifies the code a bit: I don't think the "fallback" suggestions for these lints can actually be triggered. Fixes #48103. Fixes #52414.
2019-01-14Remove `TokenStream::Tree` variant.Nicholas Nethercote-1/+1
`TokenStream::Stream` can represent a token stream containing any number of token trees. `TokenStream::Tree` is the special case representing a single token tree. The latter doesn't occur all that often dynamically, so this commit removes it, which simplifies the code quite a bit. This change has mixed performance effects. - The size of `TokenStream` drops from 32 bytes to 8 bytes, and there is one less case for all the match statements. - The conversion of a `TokenTree` to a `TokenStream` now requires two allocations, for the creation of a single element Lrc<Vec<_>>. (But a subsequent commit in this PR will reduce the main source of such conversions.)
2019-01-13Rollup merge of #57004 - nnethercote:TS-change-Stream, r=petrochenkovMazdak Farrokhzad-6/+7
Make `TokenStream` less recursive. `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.
2019-01-13Implement basic input validation for built-in attributesVadim Petrochenkov-35/+8