about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2018-07-16rustc: Stabilize much of the `proc_macro` featureAlex Crichton-30/+15
This commit stabilizes some of the `proc_macro` language feature as well as a number of APIs in the `proc_macro` crate as [previously discussed][1]. This means that on stable Rust you can now define custom procedural macros which operate as attributes attached to items or `macro_rules!`-like bang-style invocations. This extends the suite of currently stable procedural macros, custom derives, with custom attributes and custom bang macros. Note though that despite the stabilization in this commit procedural macros are still not usable on stable Rust. To stabilize that we'll need to stabilize at least part of the `use_extern_macros` feature. Currently you can define a procedural macro attribute but you can't import it to call it! A summary of the changes made in this PR (as well as the various consequences) is: * The `proc_macro` language and library features are now stable. * Other APIs not stabilized in the `proc_macro` crate are now named under a different feature, such as `proc_macro_diagnostic` or `proc_macro_span`. * A few checks in resolution for `proc_macro` being enabled have switched over to `use_extern_macros` being enabled. This means that code using `#![feature(proc_macro)]` today will likely need to move to `#![feature(use_extern_macros)]`. It's intended that this PR, once landed, will be followed up with an attempt to stabilize a small slice of `use_extern_macros` just for procedural macros to make this feature 100% usable on stable. [1]: https://internals.rust-lang.org/t/help-stabilize-a-subset-of-macros-2-0/7252
2018-07-15Auto merge of #52383 - petrochenkov:pmns, r=alexcrichtonbors-1/+4
resolve: Functions introducing procedural macros reserve a slot in the macro namespace as well Similarly to https://github.com/rust-lang/rust/pull/52234, this gives us symmetry between internal and external views of a crate, but in this case it's always an error to call a procedural macro in the same crate in which it's defined. Closes https://github.com/rust-lang/rust/issues/52225
2018-07-15Update clippy and rlsOliver Schneider-3/+3
2018-07-14Functions introducing procedural macros reserve a slot in the macro ↵Vadim Petrochenkov-1/+4
namespace as well
2018-07-14Address commentsVadim Petrochenkov-4/+5
2018-07-14Remove some tests using AST comparisons, fix other testsVadim Petrochenkov-214/+30
2018-07-14Remove most of `Hash` impls from AST and HIR structuresVadim Petrochenkov-122/+106
2018-07-14Remove most of `PartialEq` impls from AST and HIR structuresVadim Petrochenkov-148/+152
2018-07-13Add the `amdgpu-kernel` ABI.Richard Diamond-0/+6
Technically, there are requirements imposed by the LLVM `AMDGPUTargetMachine` on functions with this ABI (eg, the return type must be void), but I'm unsure exactly where this should be enforced.
2018-07-11Rollup merge of #52224 - ljedrz:dyn_libsyntax, r=oli-obkMark Rousskov-73/+76
Deny bare trait objects in in src/libsyntax Enforce `#![deny(bare_trait_objects)]` in `src/libsyntax`.
2018-07-11Rollup merge of #51952 - petrochenkov:transmark, r=alexcrichtonMark Rousskov-12/+6
hygiene: Decouple transparencies from expansion IDs And remove fallback to parent modules during resolution of names in scope. This is a breaking change for users of unstable macros 2.0 (both procedural and declarative), code like this: ```rust #![feature(decl_macro)] macro m($S: ident) { struct $S; mod m { type A = $S; } } fn main() { m!(S); } ``` or equivalent ```rust #![feature(decl_macro)] macro m($S: ident) { mod m { type A = $S; } } fn main() { struct S; m!(S); } ``` stops working due to module boundaries being properly enforced. For proc macro derives this is still reported as a compatibility warning to give `actix_derive`, `diesel_derives` and `palette_derive` time to fix their issues. Fixes https://github.com/rust-lang/rust/issues/50504 in accordance with [this comment](https://github.com/rust-lang/rust/issues/50504#issuecomment-399764767).
2018-07-10Pacify tidyljedrz-1/+2
2018-07-10Deny bare trait objects in in src/libsyntaxljedrz-73/+75
2018-07-10Auto merge of #52191 - SimonSapin:alloc_error_handler, r=alexcrichtonbors-0/+8
Implement #[alloc_error_handler] This to-be-stable attribute is equivalent to `#[lang = "oom"]`. It is required when using the `alloc` crate without the `std` crate. It is called by `handle_alloc_error`, which is in turned called by "infallible" allocations APIs such as `Vec::push`.
2018-07-10Auto merge of #52168 - nikomatsakis:nll-region-name, r=estebankbors-0/+9
find and highlight the `&` or `'_` in `region_name` Before: ``` --> $DIR/dyn-trait-underscore.rs:18:5 | LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { - | ----- lifetime `'1` appears in this argument LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime | ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static` ``` After: ``` --> $DIR/dyn-trait-underscore.rs:18:5 | LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { + | - let's call the lifetime of this reference `'1` LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime | ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static` ``` Not intended as the final end point necessarily in any sense. I intentionally left some to-do points to fill in later: - Does not apply to upvars in closures yet (should be relatively easy) - Does not handle the case where we can't find a precise match very well - And of course we can still tweak wording but shows the basic idea of how to make the `Ty` and `hir::Ty` to find a good spot to highlight. r? @estebank cc @davidtwco
2018-07-09Implement #[alloc_error_handler]Simon Sapin-0/+8
This to-be-stable attribute is equivalent to `#[lang = "oom"]`. It is required when using the alloc crate without the std crate. It is called by `handle_alloc_error`, which is in turned called by "infallible" allocations APIs such as `Vec::push`.
2018-07-09find and highlight the `&` or `'_` in `region_name`Niko Matsakis-0/+9
2018-07-08hygiene: Decouple transparencies from expansion IDsVadim Petrochenkov-12/+6
2018-07-08Auto merge of #51955 - zackmdavis:item_semi, r=oli-obkbors-0/+16
clarify why we're suggesting removing semicolon after braced items Previously (issue #46186, pull-request #46258), a suggestion was added to remove the semicolon after we fail to parse an item, but issue #51603 complains that it's still insufficiently obvious why. Let's add a note. Resolves #51603.
2018-07-07fix perf issue in macro parserMichael Lamparski-1/+8
For a fuller description of the performance issue fixed by this: https://github.com/rust-lang/rust/issues/51754#issuecomment-403242159
2018-07-06Auto merge of #52018 - flip1995:rfc2103, r=oli-obkbors-0/+15
Implementation of tool lints. Tracking issue: #44690
2018-07-05rustc: Update tracking issue for wasm_import_moduleAlex Crichton-1/+1
It's now https://github.com/rust-lang/rust/issues/52090
2018-07-04Improving span of unknown lint tool error messageflip1995-6/+8
2018-07-04Implementation of tool lintsflip1995-0/+13
2018-07-03Rollup merge of #51958 - euclio:attr-refactor, r=petrochenkovPietro Albini-678/+740
Show known meta items in unknown meta items error This PR adds a label to E0541. It also factors built-in attribute parsing into a submodule of `attr` for ease of future refactoring. Fixes #51469.
2018-07-02Auto merge of #51866 - zackmdavis:hir_making_each_day_of_the_year, ↵bors-1/+4
r=petrochenkov add modifier keyword spans to hir::Visibility; improve unreachable-pub, private-no-mangle lint suggestions #50455 pointed out that the unreachable-pub suggestion for brace-grouped `use`s was bogus; #50476 partially ameliorated this by marking the suggestion as `Applicability::MaybeIncorrect`, but this is the actual fix. Meanwhile, another application of having spans available in `hir::Visibility` is found in the private-no-mangle lints, where we can now issue a suggestion to use `pub` if the item has a more restricted visibility marker (this seems much less likely to come up in practice than not having any visibility keyword at all, but thoroughness is a virtue). While we're there, we can also add a helpful note if the item does have a `pub` (but triggered the lint presumably because enclosing modules were private). ![hir_vis](https://user-images.githubusercontent.com/1076988/42018064-ca830290-7a65-11e8-9c4c-48bc846f861f.png) r? @nrc cc @Manishearth
2018-07-01Auto merge of #51883 - estebank:placement-suggestion, r=varkorbors-0/+10
Suggest correct comparison against negative literal When parsing as emplacement syntax (`x<-1`), suggest the correct syntax for comparison against a negative value (`x< -1`). Fix #45651.
2018-06-30choose a less arbitrary span when parsing the empty visibility modifierZack M. Davis-1/+4
Visibility spans were added to the AST in #47799 (d6bdf296) as a `Spanned<_>`—which means that we need to choose a span even in the case of inherited visibility (what you get when there's no `pub` &c. keyword at all). That initial implementation's choice is pretty counterintuitive, which could matter if we want to use it as a site to suggest inserting a visibility modifier, &c. (The phrase "Schelling span" in the comment is meant in analogy to the game-theoretic concept of a "Schelling point", a value that is chosen simply because it's what one can expect to agree upon with other agents in the absence of explicit coördination.)
2018-06-30add label to unknown meta item errorAndy Russell-11/+33
2018-06-30factor built-in attribute parsing into submoduleAndy Russell-678/+718
2018-06-30clarify why we're suggesting removing semicolon after braced itemsZack M. Davis-0/+16
Previously (issue #46186, pull-request #46258), a suggestion was added to remove the semicolon after we fail to parse an item, but issue #51603 complains that it's still insufficiently obvious why. Let's add a note. Resolves #51603.
2018-06-30Auto merge of #51762 - petrochenkov:oh-hi-mark, r=oli-obkbors-39/+56
hygiene: Implement transparent marks and use them for call-site hygiene in proc-macros Fixes https://github.com/rust-lang/rust/issues/50050
2018-06-30Auto merge of #51806 - oli-obk:lowering_cleanups1, r=cramertjbors-25/+54
Lowering cleanups [1/N]
2018-06-30Fortify dummy span checkingVadim Petrochenkov-19/+19
2018-06-30hygiene: Implement transparent marksVadim Petrochenkov-1/+12
2018-06-30expansion: Give names to some fields of `SyntaxExtension`Vadim Petrochenkov-20/+26
2018-06-28Suggest correct comparison against negative literalEsteban Küber-0/+10
When parsing as emplacement syntax (`x<-1`), suggest the correct syntax for comparison against a negative value (`x< -1`).
2018-06-28Auto merge of #50997 - michaelwoerister:pre-analyze-filemaps, r=Mark-Simulacrumbors-126/+47
Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable. This PR removes most of the interior mutability from `FileMap`, which should be beneficial, especially in a multithreaded setting. This is achieved by initializing the state in question when the filemap is constructed instead of during lexing. Hopefully this doesn't degrade performance. cc @wesleywiser
2018-06-28Fix FileMap::line_begin_pos().Michael Woerister-2/+4
The method relied on the FileMap still being under construction in order for it to do what the name promises. It's now independent of the current state.
2018-06-28Use `Ident`s in a number of structures in HIRVadim Petrochenkov-1/+1
Namely: labels, type parameters, bindings in patterns, parameter names in functions without body. All of these do not need hygiene after lowering to HIR, only span locations.
2018-06-28Rollup merge of #51799 - mark-i-m:lower_case_feature_gate, r=mark-i-mkennytm-4/+4
Lower case some feature gate error messages
2018-06-27syntax_pos: Store multibyte char size as u8 instead of u32.Michael Woerister-2/+2
2018-06-27Use u32 instead of usize of encoding byte count of multi-byte chars.Michael Woerister-3/+3
2018-06-27Update CodeMap tests after changing FileMap construction.Michael Woerister-61/+10
2018-06-27Remove the now redundant CodeMap::new_filemap_with_lines() method.Michael Woerister-17/+13
2018-06-27Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable.Michael Woerister-43/+17
2018-06-27Implement `#[macro_export(local_inner_macros)]`Vadim Petrochenkov-1/+22
2018-06-27Add a convenience method for getting the impl Trait `NodeId` of an `IsAysnc`Oliver Schneider-0/+7
2018-06-27Generate `DefId`s for the impl trait of `async` functionsOliver Schneider-19/+37
2018-06-27Generate the `NodeId` for `existential type` in the ASTOliver Schneider-6/+10