summary refs log tree commit diff
path: root/src/libsyntax_ext
AgeCommit message (Collapse)AuthorLines
2017-09-21only set non-ADT derive error once per attribute, not per traitZack M. Davis-4/+7
A slight eccentricity of this change is that now non-ADT-derive errors prevent derive-macro-not-found errors from surfacing (see changes to the gating-of-derive compile-fail tests). Resolves #43927.
2017-09-10Use rvalue promotion to 'static instead of static items.Eduard-Mihai Burtescu-36/+3
2017-09-04Produce expansion info for more builtin macrosOliver Schneider-1/+4
2017-08-30Make fields of `Span` privateVadim Petrochenkov-19/+17
2017-08-27Move unused-extern-crate to late passTatsuyuki Ishi-2/+0
2017-08-25*: remove crate_{name,type} attributesTamir Duberstein-3/+0
Fixes #41701.
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-1/+1
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-72/+72
Like #43008 (f668999), but _much more aggressive_.
2017-08-15Fix typos & us spellingsFourchaux-1/+1
2017-08-12syntax: #[allow_internal_unsafe] bypasses the unsafe_code lint in macros.Eduard-Mihai Burtescu-2/+13
2017-08-10Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1bors-1/+1
Fixed mutable vars being marked used when they weren't #### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue. Fixes #43526, Fixes #30280, Fixes #25049 ### Issue Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings ``` fn do_thing<T>(mut arg : &mut T) { ... // don't touch arg - just deref it to access the T } ``` ### Fix Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables. #### Why not on things other than local variables? * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted. * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-10Add a feature gateest31-1/+1
@alexcrichton figured out a way how to do it :)
2017-08-08Avoid calling the column!() macro in panicest31-0/+1
2017-08-01Fixed extra cases found in better checking.Isaac van Bakel-1/+1
2017-08-01Auto merge of #43533 - nrc:macro-save, r=jseyfried,bors-3/+5
Three small fixes for save-analysis First commit does some naive deduplication of macro uses. We end up with lots of duplication here because of the weird way we get this data (we extract a use for every span generated by a macro use). Second commit is basically a typo fix. Third commit is a bit interesting, it partially reverts a change from #40939 where temporary variables in format! (and thus println!) got a span with the primary pointing at the value stored into the temporary (e.g., `x` in `println!("...", x)`). If `format!` had a definition it should point at the temporary in the macro def, but since it is built-in, that is not possible (for now), so `DUMMY_SP` is the best we can do (using the span in the callee really breaks save-analysis because it thinks `x` is a definition as well as a reference). There aren't a test for this stuff because: the deduplication is filtered by any of the users of save-analysis, so it is purely an efficiency change. I couldn't actually find an example for the second commit that we have any machinery to test, and the third commit is tested by the RLS, so there will be a test once I update the RLS version and and uncomment the previously failing tests). r? @jseyfried
2017-07-29Rollup merge of #43501 - topecongiro:span-to-whereclause, r=nrcMark Simulacrum-0/+1
Add Span to ast::WhereClause This PR adds `Span` field to `ast::WhereClause`. The motivation here is to make rustfmt's life easier when recovering comments before and after where clause. r? @nrc
2017-07-28syntax: Capture a `TokenStream` when parsing itemsAlex Crichton-0/+2
This is then later used by `proc_macro` to generate a new `proc_macro::TokenTree` which preserves span information. Unfortunately this isn't a bullet-proof approach as it doesn't handle the case when there's still other attributes on the item, especially inner attributes. Despite this the intention here is to solve the primary use case for procedural attributes, attached to functions as outer attributes, likely bare. In this situation we should be able to now yield a lossless stream of tokens to preserve span information.
2017-07-29Add Span to ast::WhereClausetopecongiro-0/+1
2017-07-28syntax: Add `tokens: Option<TokenStream>` to ItemAlex Crichton-0/+1
This commit adds a new field to the `Item` AST node in libsyntax to optionally contain the original token stream that the item itself was parsed from. This is currently `None` everywhere but is intended for use later with procedural macros.
2017-07-28format!: use a dummy span rather than callee span for the span base for ↵Nick Cameron-3/+5
temporary variables
2017-07-25Stabilize the `compile_error_macro` featureAlex Crichton-10/+0
Stabilizes: * `compile_error!` as a macro defined by rustc Closes #40872
2017-07-18Change the error message for multiple unused print paramsPerry Fraser-2/+6
2017-07-05Merge remote-tracking branch 'origin/master' into proc_macro_apiAlex Crichton-8/+9
2017-06-28Auto merge of #42709 - stepancheg:discriminant-hash, r=jseyfriedbors-8/+9
deriv(Hash) for single-variant enum should not hash discriminant Fixes #39137
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-19/+20
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-23Removed as many "```ignore" as possible.kennytm-10/+17
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-21Rollup merge of #42620 - wesleywiser:compile_error, r=brsonCorey Farwell-0/+42
Add compile_error! Related to #40872
2017-06-19Bump version and stage0 compilerAlex Crichton-4/+0
2017-06-19Add compile_error!Wesley Wiser-0/+42
Related to #40872
2017-06-16deriv(Hash) for single-variant enum should not hash discriminantStepan Koltsov-8/+9
Fixes #39137
2017-05-25Hygienize lifetimes.Jeffrey Seyfried-12/+11
2017-05-25Hygienize `librustc_resolve`.Jeffrey Seyfried-2/+2
2017-05-13Auto merge of #41919 - nrc:save-crate, r=eddybbors-1/+1
Include the crate's root module in save-analysis r? @eddyb
2017-05-13Auto merge of #41965 - Mark-Simulacrum:rollup, r=Mark-Simulacrumbors-6/+0
Rollup of 15 pull requests - Successful merges: #41820, #41860, #41876, #41896, #41912, #41916, #41918, #41921, #41923, #41934, #41935, #41940, #41942, #41943, #41951 - Failed merges:
2017-05-12Remove some unused macros from the rust codebaseest31-6/+0
Removes unused macros from: * libcore * libcollections The last use of these two macros was removed in commit b64c9d56700e2c41207166fe8709711ff02488ff when the char_range_at_reverse function was been removed. * librustc_errors Their last use was removed by commits 2f2c3e178325dc1837badcd7573c2c0905fab979 and 11dc974a38fd533aa692cea213305056cd3a6902. * libsyntax_ext * librustc_trans Also, put the otry macro in back/msvc/mod.rs under the same cfg argument as the places that use it.
2017-05-11rustc: Remove #![unstable] annotationAlex Crichton-3/+4
These are now no longer necessary with `-Z force-unstable-if-unmarked`
2017-05-12Pass crate attributes in visit.rsNick Cameron-1/+1
2017-04-24support `default impl` for specializationGianni Ciccarelli-0/+1
this commit implements the first step of the `default impl` feature: all items in a `default impl` are (implicitly) `default` and hence specializable. In order to test this feature I've copied all the tests provided for the `default` method implementation (in run-pass/specialization and compile-fail/specialization directories) and moved the `default` keyword from the item to the impl. See referenced issue for further info
2017-04-21Implementation of repr struct alignment RFC 1358.Cameron Hart-1/+1
The main changes around rustc::ty::Layout::struct and rustc_trans:adt: * Added primitive_align field which stores alignment before repr align * Always emit field padding when generating the LLVM struct fields * Added methods for adjusting field indexes from the layout index to the LLVM struct field index The main user of this information is rustc_trans::adt::struct_llfields which determines the LLVM fields to be used by LLVM, including padding fields.
2017-04-12Replace ExpnId with SyntaxContextA.J. Gardner-1/+0
2017-04-12First attempt at global_asm! macroA.J. Gardner-0/+68
2017-03-29Refactor how spans are combined in the parser.Jeffrey Seyfried-11/+4
2017-03-29Merge `ExpnId` and `SyntaxContext`.Jeffrey Seyfried-48/+27
2017-03-23Remove internal liblogAlex Crichton-1/+1
This commit deletes the internal liblog in favor of the implementation that lives on crates.io. Similarly it's also setting a convention for adding crates to the compiler. The main restriction right now is that we want compiler implementation details to be unreachable from normal Rust code (e.g. requires a feature), and by default everything in the sysroot is reachable via `extern crate`. The proposal here is to require that crates pulled in have these lines in their `src/lib.rs`: #![cfg_attr(rustbuild, feature(staged_api, rustc_private))] #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] This'll mean that by default they're not using these attributes but when compiled as part of the compiler they do a few things: * Mark themselves as entirely unstable via the `staged_api` feature and the `#![unstable]` attribute. * Allow usage of other unstable crates via `feature(rustc_private)` which is required if the crate relies on any other crates to compile (other than std).
2017-03-19Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrcbors-10/+12
`TokenStream`-based attributes, paths in attribute and derive macro invocations This PR - refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. - supports macro invocation paths for attribute procedural macros. - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;` - supports macro invocation paths for derive procedural macros. - e.g. `#[derive(foo::Bar, super::Baz)] struct S;` - supports arbitrary tokens as arguments to attribute procedural macros. - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;` - supports using arbitrary tokens in "inert attributes" with derive procedural macros. - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);` where `#[proc_macro_derive(Foo, attributes(inert))]` r? @nrc
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-10/+12
2017-03-12Rollup merge of #40369 - petrochenkov:segspan, r=eddybCorey Farwell-1/+1
Give spans to individual path segments in AST And use these spans in path resolution diagnostics. The spans are spans of identifiers in segments, not whole segments. I'm not sure what spans are more useful in general, but identifier spans are a better fit for resolve errors. HIR still doesn't have spans. Fixes https://github.com/rust-lang/rust/pull/38927#discussion_r95336667 https://github.com/rust-lang/rust/pull/38890#issuecomment-271731008 r? @nrc @eddyb
2017-03-10Give spans to individual path segments in ASTVadim Petrochenkov-1/+1
2017-03-10Refactor out `ast::ItemKind::MacroDef`.Jeffrey Seyfried-8/+12
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-1/+1