about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2018-07-30Auto merge of #52722 - alexcrichton:more-identifier-lints, r=oli-obkbors-1/+1
Tweak the raw_identifiers lints in 2018 * Enable the `raw_identifiers` feature automatically in the 2018 preview * Only emit lint warnings if the `raw_identifiers` feature is activated cc rust-lang/cargo#5783
2018-07-29Auto merge of #52738 - ljedrz:push_to_extend, r=eddybbors-11/+3
Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible.
2018-07-29Replace push loops with collect() and extend() where possibleljedrz-11/+3
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-4/+4
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-29Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakisbors-6/+4
Misc cleanups
2018-07-28Auto merge of #52355 - pietroalbini:zfeature, r=eddybbors-2/+32
Add the -Zcrate-attr=foo unstable rustc option This PR adds a new unstable option to `rustc`: `-Zcrate-attr=foo`. The option can be used to inject crate-level attributes from the CLI, and it's meant to be used by tools like Crater that needs to add their own attributes to a crate without changing the source code. The exact reason I need this is to implement "edition runs" in Crater: we need to add the preview feature flag to every crate, and editing the crates' source code on the fly might produce unexpected results, while a compiler flag is more reliable. cc https://github.com/rust-lang-nursery/crater/issues/282 @Mark-Simulacrum
2018-07-28Auto merge of #52761 - toidiu:ak-static-infer-fg, r=nikomatsakisbors-0/+9
static infer feature gate https://github.com/rust-lang/rust/issues/44493 r? @nikomatsakis
2018-07-28Rollup merge of #52781 - ljedrz:avoid_vec_arguments, r=nikomatsakiskennytm-1/+1
Use a slice where a vector is not necessary
2018-07-28Rollup merge of #52740 - estebank:crate-name, r=petrochenkovkennytm-1/+35
Suggest underscore when using dashes in crate namet push fork Fix #48437.
2018-07-27review commentsEsteban Küber-11/+7
2018-07-27Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrumbors-2/+0
Rollup of bare_trait_objects PRs All deny attributes were moved into bootstrap so they can be disabled with a line of config. Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free. r? @Mark-Simulacrum cc @ljedrz @kennytm
2018-07-27Add the -Zcrate-attr=foo nightly rustc flag to inject crate attributesPietro Albini-2/+32
2018-07-27Use slices where a vector is not necessaryljedrz-1/+1
2018-07-27Use str::repeatShotaro Yamada-6/+4
2018-07-27Prefer to_string() to format!()ljedrz-4/+4
2018-07-26feature gate for inferring 'static lifetimestoidiu-0/+9
2018-07-26Tweak the raw_identifiers lints in 2018Alex Crichton-1/+1
* Enable the `raw_identifiers` feature automatically in the 2018 preview * Only emit lint warnings if the `raw_identifiers` feature is activated cc rust-lang/cargo#5783
2018-07-26Suggest underscore when using dashes in crate namet push forkEsteban Küber-3/+41
2018-07-25Deny bare_trait_objects globallyTatsuyuki Ishi-2/+0
2018-07-24Rollup merge of #52645 - oli-obk:existential_in_fn_body, r=dtolnayMark Rousskov-0/+6
Allow declaring existential types inside blocks fixes #52631 r? @dtolnay
2018-07-24Auto merge of #51587 - mark-i-m:at_most_once_rep_2018, r=alexcrichtonbors-81/+317
2018 edition `?` Kleene operator This is my first attempt at implementing the migration lint + 2018 behavior as discussed in #48075 r? @nikomatsakis
2018-07-24Allow declaring existential types inside blocksOliver Schneider-0/+6
2018-07-23Allow by default, fix testsmark-0/+1
2018-07-23dump lints _after_ parsing macrosmark-3/+3
2018-07-23make it a migration lintmark-3/+42
2018-07-23Fix test and errorsmark-266/+183
2018-07-23Implement 2015 vs 2018 `?` kleene op + testmark-257/+486
2018-07-23Extend ParseSess to support buffering lintsmark-2/+52
2018-07-24Auto merge of #52618 - alexcrichton:capture-more, r=petrochenkovbors-43/+77
rustc: Implement tokenization of nested items Ever plagued by #43081 the compiler can return surprising spans in situations related to procedural macros. This is exhibited by #47983 where whenever a procedural macro is invoked in a nested item context it would fail to have correct span information. While #43230 provided a "hack" to cache the token stream used for each item in the compiler it's not a full-blown solution. This commit continues to extend this "hack" a bit more to work for nested items. Previously in the parser the `parse_item` method would collect the tokens for an item into a cache on the item itself. It turned out, however, that nested items were parsed through the `parse_item_` method, so they didn't receive similar treatment. To remedy this situation the hook for collecting tokens was moved into `parse_item_` instead of `parse_item`. Afterwards the token collection scheme was updated to support nested collection of tokens. This is implemented by tracking `TokenStream` tokens instead of `TokenTree` to allow for collecting items into streams at intermediate layers and having them interleaved in the upper layers. All in all, this... Closes #47983
2018-07-23Rollup merge of #52581 - petrochenkov:bmacrodoc, r=alexcrichtonkennytm-1/+2
Avoid using `#[macro_export]` for documenting builtin macros Use a special `rustc_*` attribute instead. cc https://github.com/rust-lang/rust/pull/52234
2018-07-22rustc: Implement tokenization of nested itemsAlex Crichton-43/+77
Ever plagued by #43081 the compiler can return surprising spans in situations related to procedural macros. This is exhibited by #47983 where whenever a procedural macro is invoked in a nested item context it would fail to have correct span information. While #43230 provided a "hack" to cache the token stream used for each item in the compiler it's not a full-blown solution. This commit continues to extend this "hack" a bit more to work for nested items. Previously in the parser the `parse_item` method would collect the tokens for an item into a cache on the item itself. It turned out, however, that nested items were parsed through the `parse_item_` method, so they didn't receive similar treatment. To remedy this situation the hook for collecting tokens was moved into `parse_item_` instead of `parse_item`. Afterwards the token collection scheme was updated to support nested collection of tokens. This is implemented by tracking `TokenStream` tokens instead of `TokenTree` to allow for collecting items into streams at intermediate layers and having them interleaved in the upper layers. All in all, this... Closes #47983
2018-07-22Auto merge of #52394 - estebank:println, r=oli-obkbors-10/+20
Improve suggestion for missing fmt str in println Avoid using `concat!(fmt, "\n")` to improve the diagnostics being emitted when the first `println!()` argument isn't a formatting string literal. Fix #52347.
2018-07-21Gate `format_args_nll` behind feature flagEsteban Küber-0/+5
2018-07-21Auto merge of #52552 - eddyb:proc-macro-prep, r=alexcrichtonbors-6/+0
Prepare proc_macro for decoupling it from the rest of the compiler. This is #49219 up to the point where the bridge is introduced. Aside from moving some code around, the largest change is the rewrite of `proc_macro::quote` to be simpler and do less introspection. I'd like to also extend `quote!` with `${stmt;...;expr}` instead of just `$variable` (and maybe even `$(... $iter ...)*`), which seems pretty straight-forward now, but I don't know if/when I should. r? @alexcrichton or @dtolnay cc @jseyfried @petrochenkov
2018-07-21Auto merge of #52536 - alexcrichton:attr-spans, r=nikomatsakisbors-5/+44
proc_macro: Preserve spans of attributes on functions This commit updates the tokenization of items which are subsequently passed to `proc_macro` to ensure that span information is preserved on attributes as much as possible. Previously this area of the code suffered from #43081 where we haven't actually implemented converting an attribute to to a token tree yet, but a local fix was possible here. Closes #47941
2018-07-21Avoid using `#[macro_export]` for documenting builtin macrosVadim Petrochenkov-1/+2
2018-07-21Rollup merge of #52539 - alexcrichton:two-attrs, r=petrochenkovkennytm-0/+17
rustc: Fix two custom attributes with custom derive This commit fixes an issue where multiple custom attributes could not be fed into a custom derive in some situations with the `use_extern_macros` feature enabled. The problem was that the macro expander didn't consider that it was making progress when we were deducing that attributes should be lumped in with custom derive invocations. The fix applied here was to track in the expander if our attribute is changing (getting stashed away elsewhere and replaced with a new invocation). If it is swapped then it's considered progress, otherwise behavior should remain the same. Closes #52525
2018-07-20Auto merge of #52445 - alexcrichton:wasm-import-module, r=eddybbors-7/+0
rustc: Stabilize #[wasm_import_module] as #[link(...)] This commit stabilizes the `#[wasm_import_module]` attribute as `#[link(wasm_import_module = "...")]`. Tracked by #52090 this new directive in the `#[link]` attribute is used to configured the module name that the imports are listed with. The WebAssembly specification indicates two utf-8 names are associated with all imported items, one for the module the item comes from and one for the item itself. The item itself is configurable in Rust via its identifier or `#[link_name = "..."]`, but the module name was previously not configurable and defaulted to `"env"`. This commit ensures that this is also configurable. Closes #52090
2018-07-19Improve suggestion for missing fmt str in printlnEsteban Küber-10/+15
Avoid using `concat!(fmt, "\n")` to improve the diagnostics being emitted when the first `println!()` argument isn't a formatting string literal.
2018-07-20proc_macro: move some implementation details to a rustc module.Eduard-Mihai Burtescu-6/+0
2018-07-19Auto merge of #52024 - oli-obk:existential_parse, r=nikomatsakisbors-22/+116
Implement existential types (not for associated types yet) r? @nikomatsakis cc @Centril @varkor @alexreg
2018-07-19rustc: Fix two custom attributes with custom deriveAlex Crichton-0/+17
This commit fixes an issue where multiple custom attributes could not be fed into a custom derive in some situations with the `use_extern_macros` feature enabled. The problem was that the macro expander didn't consider that it was making progress when we were deducing that attributes should be lumped in with custom derive invocations. The fix applied here was to track in the expander if our attribute is changing (getting stashed away elsewhere and replaced with a new invocation). If it is swapped then it's considered progress, otherwise behavior should remain the same. Closes #52525
2018-07-19proc_macro: Preserve spans of attributes on functionsAlex Crichton-5/+44
This commit updates the tokenization of items which are subsequently passed to `proc_macro` to ensure that span information is preserved on attributes as much as possible. Previously this area of the code suffered from #43081 where we haven't actually implemented converting an attribute to to a token tree yet, but a local fix was possible here. Closes #47941
2018-07-18rustc: Stabilize #[wasm_import_module] as #[link(...)]Alex Crichton-7/+0
This commit stabilizes the `#[wasm_import_module]` attribute as `#[link(wasm_import_module = "...")]`. Tracked by #52090 this new directive in the `#[link]` attribute is used to configured the module name that the imports are listed with. The WebAssembly specification indicates two utf-8 names are associated with all imported items, one for the module the item comes from and one for the item itself. The item itself is configurable in Rust via its identifier or `#[link_name = "..."]`, but the module name was previously not configurable and defaulted to `"env"`. This commit ensures that this is also configurable. Closes #52090
2018-07-18Rollup merge of #52472 - alexcrichton:macros-edition-2018, r=petrochenkovkennytm-1/+1
rustc: Enable `use_extern_macros` in 2018 edition This was previously enabled via `proc_macro`, but since `proc_macro` is now stable this is no longer the case. Explicitly include it in the 2018 edition here.
2018-07-18Implement existential typesOliver Schneider-22/+116
2018-07-18Auto merge of #52353 - alexcrichton:wasm-custom-section, r=eddybbors-8/+0
rustc: Use link_section, not wasm_custom_section This commit transitions definitions of custom sections on the wasm target from the unstable `#[wasm_custom_section]` attribute to the already-stable-for-other-targets `#[link_section]` attribute. Mostly the same restrictions apply as before, except that this now applies only to statics. Closes #51088
2018-07-17rustc: Enable `use_extern_macros` in 2018 editionAlex Crichton-1/+1
This was previously enabled via `proc_macro`, but since `proc_macro` is now stable this is no longer the case. Explicitly include it in the 2018 edition here.
2018-07-17Auto merge of #52145 - ExpHP:drop-it-like-its-eof, r=nikomatsakisbors-1/+6
Fix macro parser quadratic complexity in small repeating groups Observed in #51754, and more easily demonstrated with the following: ```rust macro_rules! stress { ($($t:tt)+) => { }; } fn main() { stress!{ a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a // ... 65536 copies of "a" total ... a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a } } ``` which takes 50 seconds to compile prior to the fix and <1s after. I hope this has a visible impact on the compile times for real code. (I think it is most likely to affect incremental TT munchers that deal with large inputs, though it depends on how they are written) For a fuller description of the performance issue: https://github.com/rust-lang/rust/issues/51754#issuecomment-403242159 --- There is no test (yet) because I'm not sure how easily to measure this for regressions.
2018-07-16cleanup unnecessary elseMichael Lamparski-6/+4