about summary refs log tree commit diff
path: root/src/libsyntax/attr.rs
AgeCommit message (Collapse)AuthorLines
2018-06-30factor built-in attribute parsing into submoduleAndy Russell-1478/+0
2018-06-20Fix HasAttrs support for GenericParamvarkor-10/+5
2018-06-02Deny #[cfg] and #[cfg_attr] on generic parameters.kennytm-2/+18
2018-05-20suggestion applicabilities for libsyntax and librustc, run-rustfix testsZack M. Davis-7/+13
Consider this a down payment on #50723. To recap, an `Applicability` enum was recently (#50204) added, to convey to Rustfix and other tools whether we think it's OK for them to blindly apply the suggestion, or whether to prompt a human for guidance (because the suggestion might contain placeholders that we can't infer, or because we think it has a sufficiently high probability of being wrong even though it's— presumably—right often enough to be worth emitting in the first place). When a suggestion is marked as `MaybeIncorrect`, we try to use comments to indicate precisely why (although there are a few places where we just say `// speculative` because the present author's subjective judgement balked at the idea that the suggestion has no false positives). The `run-rustfix` directive is opporunistically set on some relevant UI tests (and a couple tests that were in the `test/ui/suggestions` directory, even if the suggestions didn't originate in librustc or libsyntax). This is less trivial than it sounds, because a surprising number of test files aren't equipped to be tested as fixed even when they contain successfully fixable errors, because, e.g., there are more, not-directly-related errors after fixing. Some test files need an attribute or underscore to avoid unused warnings tripping up the "fixed code is still producing diagnostics" check despite the fixes being correct; this is an interesting contrast-to/inconsistency-with the behavior of UI tests (which secretly pass `-A unused`), a behavior which we probably ought to resolve one way or the other (filed issue #50926). A few suggestion labels are reworded (e.g., to avoid phrasing it as a question, which which is discouraged by the style guidelines listed in `.span_suggestion`'s doc-comment).
2018-05-13Macros: Add a 'literal' fragment specifierDan Aloni-1/+1
Implements RFC 1576. See: https://github.com/rust-lang/rfcs/blob/master/text/1576-macros-literal-matcher.md Changes are mostly in libsyntax, docs, and tests. Feature gate is enabled for 1.27.0. Many thanks to Vadim Petrochenkov for following through code reviews and suggestions. Example: ````rust macro_rules! test_literal { ($l:literal) => { println!("literal: {}", $l); }; ($e:expr) => { println!("expr: {}", $e); }; } fn main() { let a = 1; test_literal!(a); test_literal!(2); test_literal!(-3); } ``` Output: ``` expr: 1 literal: 2 literal: -3 ```
2018-05-03Auto merge of #50030 - flip1995:rfc2103, r=petrochenkovbors-49/+101
Implement tool_attributes feature (RFC 2103) cc #44690 This is currently just a rebased and compiling (hopefully) version of #47773. Let's see if travis likes this. I will add the implementation for `tool_lints` this week.
2018-05-03Auto merge of #50391 - nnethercote:escape_unicode, r=eddybbors-4/+1
Use escape_default() for strings in LitKind::token(). This avoids converting every char to \u{...} form, which bloats the resulting strings unnecessarily. It also provides consistency with the existing escape_default() calls in LitKind::token() used for raw string literals, char literals, and raw byte char literals. There are two benefits from this change. - Compilation is faster. Most of the rustc-perf benchmarks see a non-trivial speedup, particularly for incremental rebuilds, with the best speedup over 13%, and multiple others over 10%. - Generated rlibs are smaller. An extreme example is libfutures.rlib, which shrinks from 2073306 bytes to 1765927 bytes, a 15% reduction. r? @jseyfried <details><summary>Here are full numbers for all the rustc-perf runs where the improvement was > 1%.</summary> ``` regex-check avg: -11.1% min: -13.4% max: -5.5% futures-check avg: -7.6% min: -11.4% max: -3.5% futures-opt avg: -6.3% min: -10.3% max: -2.3% futures avg: -6.6% min: -10.3% max: -2.8% regex-opt avg: -4.7% min: -10.2% max: -0.4% regex avg: -5.3% min: -10.2% max: -1.2% hyper-check avg: -4.8% min: -6.6% max: -2.7% encoding-check avg: -4.1% min: -5.5% max: -2.5% issue-46449-check avg: -4.7% min: -5.2% max: -4.1% clap-rs-check avg: -2.9% min: -5.2% max: -1.1% hyper avg: -3.0% min: -5.1% max: -0.8% parser-check avg: -4.2% min: -4.9% max: -3.2% hyper-opt avg: -2.6% min: -4.9% max: -0.3% encoding-opt avg: -2.3% min: -4.6% max: -0.5% encoding avg: -2.5% min: -4.4% max: -0.6% issue-46449 avg: -2.3% min: -4.4% max: -1.8% issue-46449-opt avg: -1.7% min: -4.3% max: -0.9% clap-rs-opt avg: -1.6% min: -4.2% max: -0.2% serde-check avg: -1.4% min: -4.1% max: -0.2% clap-rs avg: -1.6% min: -3.9% max: -0.7% unify-linearly-check avg: -3.2% min: -3.7% max: -2.7% serde avg: -1.1% min: -3.5% max: -0.1% regression-31157-check avg: -2.6% min: -3.4% max: -1.6% helloworld-check avg: -2.5% min: -3.4% max: -0.6% serde-opt avg: -1.3% min: -3.3% max: -0.5% tokio-webpush-simple-check avg: -2.4% min: -3.2% max: -1.8% piston-image-check avg: -1.7% min: -3.2% max: -0.9% deeply-nested-opt avg: -1.5% min: -3.0% max: -0.6% deeply-nested-check avg: -1.9% min: -2.9% max: -0.4% deeply-nested avg: -1.9% min: -2.9% max: -1.2% syn-check avg: -1.8% min: -2.8% max: -0.6% coercions avg: -0.5% min: -2.8% max: 0.4% syn-opt avg: -0.9% min: -2.4% max: -0.1% syn avg: -1.1% min: -2.2% max: -0.3% parser-opt avg: -1.9% min: -2.1% max: -1.6% parser avg: -1.9% min: -2.1% max: -1.6% style-servo-check avg: -1.3% min: -2.0% max: -0.8% regression-31157-opt avg: -0.8% min: -2.0% max: 0.0% piston-image avg: -0.7% min: -1.8% max: -0.2% piston-image-opt avg: -0.6% min: -1.8% max: -0.0% regression-31157 avg: -1.0% min: -1.7% max: -0.3% html5ever-opt avg: -0.6% min: -1.5% max: -0.1% unify-linearly-opt avg: -1.3% min: -1.5% max: -1.1% unify-linearly avg: -1.3% min: -1.4% max: -1.2% tokio-webpush-simple-opt avg: -0.4% min: -1.2% max: -0.0% helloworld-opt avg: -1.0% min: -1.1% max: -0.6% helloworld avg: -1.0% min: -1.1% max: -0.7% inflate-opt avg: -0.3% min: -1.1% max: 0.1% html5ever-check avg: -0.6% min: -1.0% max: -0.3% inflate-check avg: -0.3% min: -1.0% max: -0.1% ``` </details>
2018-05-03Use escape_default() for strings in LitKind::token().Nicholas Nethercote-4/+1
This avoids converting every char to \u{...} form, which bloats the resulting strings unnecessarily. It also provides consistency with the existing escape_default() calls in LitKind::token() used for raw string literals, char literals, and raw byte char literals. There are two benefits from this change. - Compilation is faster. Most of the rustc-perf benchmarks see a non-trivial speedup, particularly for incremental rebuilds, with the best speedup over 13%, and multiple others over 10%. - Generated rlibs are smaller. An extreme example is libfutures.rlib, which shrinks from 2073306 bytes to 1765927 bytes, a 15% reduction.
2018-05-02fix testsflip1995-15/+15
2018-05-02make it compile againflip1995-51/+32
2018-05-02Change Attribute::name to return the last segmentSeiichi Uchida-4/+7
And fix some typos
2018-05-02Gate tool_attributes featureSeiichi Uchida-0/+10
2018-05-02Remove Option from the return type of Attribute::name()Seiichi Uchida-5/+4
2018-05-02Allow Path for name of MetaItemSeiichi Uchida-40/+99
2018-05-01Reduce the maximum alignment to repr(align(1 << 29))varkor-3/+3
This brings it into line with LLVM's maximum permitted alignment.
2018-04-29Add error when using repr(align=x) instead of repr(align(x))varkor-0/+24
2018-04-11Implementation of `#[repr(packed(n))]` RFC 1399.Cameron Hart-16/+30
2018-04-06Use `Ident` instead of `Name` in `MetaItem`Vadim Petrochenkov-63/+43
2018-04-06Remove more duplicated spansVadim Petrochenkov-3/+5
2018-04-06Get rid of `SpannedIdent`Vadim Petrochenkov-1/+1
2018-04-06Rename `PathSegment::identifier` to `ident`Vadim Petrochenkov-3/+3
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-6/+7
2018-03-14Remove syntax and syntax_pos thread localsJohn Kåre Alsaker-18/+17
2018-03-06Add `inline` to `TransFnAttrs`Wesley Wiser-45/+1
Part of #47320
2018-02-20make `#[unwind]` attribute specify expectations more clearlyNiko Matsakis-0/+45
You can now choose between the following: - `#[unwind(allowed)]` - `#[unwind(aborts)]` Per rust-lang/rust#48251, the default is `#[unwind(allowed)]`, though I think we should change this eventually.
2018-01-16Implement repr(transparent)Robin Kruppe-1/+4
2018-01-07Rename ReprExtern to ReprC, and similarily rename a few other fields and ↵Robin Kruppe-3/+2
locals that mentioned "extern repr"
2018-01-04rustc: use {U,I}size instead of {U,I}s shorthands.Eduard-Mihai Burtescu-2/+2
2017-12-21Make mk_attr_id thread safeJohn Kåre Alsaker-9/+7
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-8/+3
2017-11-21make with_unsugared_doc preserve is_sugared_docQuietMisdreavus-4/+6
2017-09-20Fix ICEscalexm-0/+14
2017-09-17rustc: Move some attr methods to queriesAlex Crichton-24/+0
Otherwise we may emit double errors related to the `#[export_name]` attribute, for example, and using a query should ensure that it's only emitted at most once.
2017-09-13honor #[rustc_const_unstable] attributesAlex Burka-14/+65
2017-09-03implement improved on_unimplemented directivesAriel Ben-Yehuda-7/+18
2017-08-30Make fields of `Span` privateVadim Petrochenkov-7/+7
2017-08-28feature error span on attr. for fn_must_use, SIMD/align, macro reëxportZack M. Davis-0/+4
There were several feature-gated attributes for which the feature-not-available error spans would point to the item annotated with the gated attribute, when it would make more sense for the span to point to the attribute itself: if the attribute is removed, the function/struct/&c. likely still makes sense and the program will compile. (Note that we decline to make the analogous change for the `main`, `start`, and `plugin_registrar` features, for in those cases it makes sense for the span to implicate the entire function, of which there is little hope of using without the gated attribute.)
2017-08-17Include the closing paren to the span of ast::NestedMetaItemSeiichi Uchida-11/+6
2017-08-17Use respan()Seiichi Uchida-3/+3
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-11/+11
Like #43008 (f668999), but _much more aggressive_.
2017-08-11Fix some typosBastien Orivel-1/+1
2017-07-08Lower alignment limit down to 2^31 - 1 (from LLVM)Lee Bousfield-3/+3
2017-07-08Raised alignment limit from 2^15 to 2^31Lee Bousfield-5/+5
2017-06-26Add `LazyTokenStream`.Jeffrey Seyfried-2/+2
2017-05-18Add an option to the parser to avoid parsing out of line modulesNick Cameron-1/+1
This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
2017-05-12Fix some clippy warnings in libsyntaxAndre Bogus-8/+9
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-05-08Remove need for &format!(...) or &&"" dances in `span_label` callsOliver Schneider-2/+1
2017-04-21Added feature gate, updated error messages and tests.Cameron Hart-4/+9
2017-04-21Implementation of repr struct alignment RFC 1358.Cameron Hart-6/+44
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-03-30Improve `Path` spans.Jeffrey Seyfried-3/+4