Commit graph

8926 commits

Author SHA1 Message Date
Mark Rousskov
56a9237b59 File is now short enough for tidy 2019-07-10 07:13:59 -04:00
Mark Rousskov
096cb4137d Remove writer function from PrintState 2019-07-10 07:13:57 -04:00
Mark Rousskov
73c1752b8e Use constant instead of magic number 2019-07-10 07:13:22 -04:00
Mark Rousskov
63fdf1a527 Remove needless indent arguments
We're always indenting by INDENT_UNIT anyway
2019-07-10 07:13:22 -04:00
Mark Rousskov
cab453250a Move pp::Printer helpers to direct impl 2019-07-10 07:13:20 -04:00
Mark Rousskov
e91dbc5916 Rename is_bol -> is_beginning_of_line
Also moves it to pp::Printer from PrintState.
2019-07-10 07:12:29 -04:00
Mark Rousskov
39aa9bf730 Remove needless indirection in bclose 2019-07-10 07:12:29 -04:00
Mark Rousskov
04b80a5f5d Drop length from Token::String
It was always set to the string's length
2019-07-10 07:12:29 -04:00
Mark Rousskov
5879146392 Rename pretty_print_* to scan_* to follow naming in the paper
This is also easier to understand because the scan and print "tasks" are
separate, but previously were both called "print" or "pretty print."
2019-07-10 07:12:29 -04:00
Mark Rousskov
4783d9eaa5 Remove is_begin/is_end functions from PrintState
These are somewhat ambiguous (beginning/end of what?) so it's better to
inline their one use into the code.
2019-07-10 07:12:29 -04:00
Mark Rousskov
57cf7a2e57 Simplify print_end
Presumably the code was from an older age of Rust and can now be written
much simpler.
2019-07-10 07:12:29 -04:00
Mark Rousskov
55a6a761b9 Simplify check_stack implementation 2019-07-10 07:12:29 -04:00
Mark Rousskov
cd2d8326a5 Move BufEntry assignment into scan_push 2019-07-10 07:12:28 -04:00
Mark Rousskov
ccf279d9c3 Remove useless call to indent 2019-07-10 07:12:28 -04:00
Mark Rousskov
4c58fc32ae Fully privatize (vs. crate visibility) functions 2019-07-10 07:12:28 -04:00
Mark Rousskov
00ca508608 Move pp::Printer out field to owned String
This enforces that eof() must be called to get the String out, and
generally is better from an API perspective. No users of pretty printing
pre-allocate the buffer.
2019-07-10 07:12:28 -04:00
Mark Rousskov
e0ffa7c3d2 Inline State::new_from_input in pprust
This function took too many arguments and are simple on the inside;
inlining them makes complexity go down.

hir::print's copy is unfortunately used from librustc_driver so inlining
it is not as straightforward.
2019-07-10 07:12:28 -04:00
Mark Rousskov
e0db2e606c print_crate returns String instead of taking an out pointer 2019-07-10 07:12:28 -04:00
Mark Rousskov
7e3791469f Replace src: &mut dyn Read with String 2019-07-10 07:12:28 -04:00
Mark Rousskov
0eb2e566c1 Combine comment-handling logic into struct
This also permits sharing the underlying code between pprust and
hir::print.
2019-07-10 07:12:28 -04:00
Mark Rousskov
9b5e39723d Inline State::new
There was only one callsite for each and this removes the
unwrap_or_default's on the comments argument
2019-07-10 07:12:28 -04:00
Mark Rousskov
59b161c7c8 Stop Option-wrapping comments
We always check against the length before indexing anyway.
2019-07-10 07:12:28 -04:00
Mark Rousskov
a573d143a2 Remove unused boxes vector 2019-07-10 07:12:28 -04:00
Mark Rousskov
4483980285 Privatize and remove unused functions 2019-07-10 07:12:26 -04:00
Mark Rousskov
11d521676f Move lifetime_to_string to Display impl 2019-07-10 07:11:29 -04:00
Mark Rousskov
a440337e2b Remove unused arm_to_string 2019-07-10 07:11:29 -04:00
Mark Rousskov
0f10d114e4 Remove duplicate attr_to_string
attribute_to_string exists.
2019-07-10 07:11:29 -04:00
Mark Rousskov
9b0ebfa4e9 Move literal_to_string to fmt::Display 2019-07-10 07:11:29 -04:00
Mazdak Farrokhzad
fe26fc9a1c
Rollup merge of #62393 - petrochenkov:notto-disu, r=Mark-Simulacrum
Fix pretty-printing of `$crate` (take 4)

Pretty-print `$crate` as `crate` or `crate_name` in unstructured tokens like `a $crate c` in `foo!(a $crate c)`, but only if those tokens are printed as a part of AST pretty-printing, rather than as a standalone token stream.

Fixes https://github.com/rust-lang/rust/issues/62325
Previous iterations - https://github.com/rust-lang/rust/pull/56647, https://github.com/rust-lang/rust/pull/57155, https://github.com/rust-lang/rust/pull/57915.
2019-07-10 05:14:09 +02:00
Vadim Petrochenkov
3997507786 Resolve $crate in all hygienic contexts for pretty-pringing
Stop visiting AST to discover those contexts, just iterate through hygiene data instead
2019-07-09 22:17:44 +03:00
Vadim Petrochenkov
4344a90308 Pretty-print $crate as crate/::my_crate in tokens
...but only if those tokens are printed from inside of AST pretty-printing.
2019-07-09 22:17:44 +03:00
Samy Kacimi
41e71b0c93
normalize use of backticks in compiler messages for libsyntax/feature_gate
https://github.com/rust-lang/rust/issues/60532
2019-07-09 14:13:28 +02:00
Mazdak Farrokhzad
fe807fcf3e
Rollup merge of #62213 - QuietMisdreavus:cfg-doctest, r=GuillaumeGomez
rustdoc: set cfg(doctest) when collecting doctests

Note: This PR builds on top of https://github.com/rust-lang/rust/pull/61199; only the last commit is specific to this PR.

As discussed in https://github.com/rust-lang/rust/pull/61199, we want the ability to isolate items to only when rustdoc is collecting doctests, but we can't use `cfg(test)` because of libcore's `#![cfg(not(test))]`. This PR proposes a new cfg flag, `cfg(doctest)`, specific to this situation, rather than reusing an existing flag. I've isolated it behind a feature gate so that we can contain the effects to nightly only. (A stable workaround that can be used in lieu of `#[cfg(doctest)]` is `#[cfg(rustdoc)] #[doc(hidden)]`, at least once https://github.com/rust-lang/rust/pull/61351 lands.)

Tracking issue: https://github.com/rust-lang/rust/issues/62210
2019-07-07 17:00:18 +02:00
Mazdak Farrokhzad
3250b8ee59
Rollup merge of #62042 - petrochenkov:macstab, r=matthewjasper
Support stability and deprecation checking for all macros

RELNOTES: Deprecation attributes on macros now have effect.

Fixes https://github.com/rust-lang/rust/issues/34079
Fixes https://github.com/rust-lang/rust/issues/49912
Unblocks https://github.com/rust-lang/rust/pull/62086
Unblocks https://github.com/rust-lang/rust/pull/61000
2019-07-07 17:00:17 +02:00
Vadim Petrochenkov
b6d522a101 syntax: Pre-intern names of all built-in macros
They always end up interned anyway
2019-07-07 13:04:07 +03:00
Vadim Petrochenkov
1ee0ce82cb syntax: Migrate built-in macros to the regular stability checking 2019-07-07 13:04:07 +03:00
Vadim Petrochenkov
0817fc6c6c Support deprecation checking for macros 2019-07-07 13:04:07 +03:00
Vadim Petrochenkov
3542995ff9 syntax: Keep full Stability in SyntaxExtension 2019-07-07 13:04:07 +03:00
Vadim Petrochenkov
3b6370b4ab resolve/expand: Move macro stability checking to an earlier point 2019-07-07 13:04:07 +03:00
Vadim Petrochenkov
03ac05338c syntax: Remove NodeId from SyntaxExtension 2019-07-07 13:04:06 +03:00
QuietMisdreavus
bed54cf854 rustdoc: set cfg(doctest) when collecting doctests 2019-07-06 21:37:17 -05:00
Alex Crichton
345ba505ec rustc: Remove dylib crate type from most rustc crates
Now that procedural macros no longer link transitively to libsyntax,
this shouldn't be needed any more! This commit is an experiment in
removing all dynamic libraries from rustc except for librustc_driver
itself. Let's see how far we can get with that!
2019-07-07 03:23:00 +02:00
Vadim Petrochenkov
920a17a60c privacy: Only opaque macros leak private things 2019-07-06 16:59:08 +03:00
Vadim Petrochenkov
987be89db3 Fix tidy issues 2019-07-06 16:59:08 +03:00
Vadim Petrochenkov
22d6d8ac76 #[rustc_transparent_macro] -> #[rustc_macro_transparency = ...] 2019-07-06 16:59:08 +03:00
Vadim Petrochenkov
15042a3c1c #[rustc_doc_only_macro] -> #[rustc_builtin_macro] 2019-07-06 16:59:08 +03:00
Mazdak Farrokhzad
952ee77871
Rollup merge of #62329 - matklad:no-peeking, r=petrochenkov
Remove support for 1-token lookahead from the lexer

`StringReader` maintained `peek_token` and `peek_span_src_raw` for look ahead.

`peek_token` was used only by rustdoc syntax coloring. After moving peeking logic into highlighter, I was able to remove `peek_token` from the lexer. I tried to use `iter::Peekable`, but that wasn't as pretty as I hoped, due to buffered fatal errors. So I went with hand-rolled peeking.

After that I've noticed that the only peeking behavior left was for raw tokens to test tt jointness. I've rewritten it in terms of trivia tokens, and not just spans.

After that it became possible to simplify the awkward constructor of the lexer, which could return `Err` if the first peeked token contained error.
2019-07-06 02:38:01 +02:00
Mazdak Farrokhzad
0224532493
Rollup merge of #62133 - petrochenkov:norustc, r=eddyb
Feature gate `rustc` attributes harder

Fixes https://github.com/rust-lang/rust/issues/62116
2019-07-05 20:26:54 +02:00
Mazdak Farrokhzad
485a084b45
Rollup merge of #61545 - flip1995:internal_lints, r=oli-obk
Implement another internal lints

cc #49509

This adds ~~two~~ one internal lint~~s~~:
1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc #59669
2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in #49509~~

~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~

TODO (not directly relevant for review):
- [ ] https://github.com/rust-lang/rust/pull/59316#discussion_r280186517 (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb)
- [x] https://github.com/rust-lang/rust/pull/61735#discussion_r292389870
- [x] Check explicitly for the `{declare,impl}_lint_pass!` macros

r? @oli-obk
2019-07-05 20:26:51 +02:00
Mazdak Farrokhzad
84527e4676
Rollup merge of #62292 - Centril:split-async-closures, r=cramertj
Move `async || ...` closures into `#![feature(async_closure)]`

The `async || expr` syntax is moved out from `#![feature(async_await)]` into its own gate `#![feature(async_closure)]`.

New tracking issue: https://github.com/rust-lang/rust/issues/62290

Closes https://github.com/rust-lang/rust/issues/62214.

cc https://github.com/rust-lang/rust/issues/62149

r? @varkor
2019-07-05 13:53:06 +02:00