about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-07-12Rollup merge of #62605 - estebank:emit-dropped-err, r=pnkfelixMazdak Farrokhzad-9/+10
Emit dropped unemitted errors to aid in ICE debugging
2019-07-11Correctly break out of recovery loopEsteban Küber-2/+3
2019-07-11Emit dropped unemitted errors to aid in ICE debuggingEsteban Küber-9/+10
2019-07-11Handle errors during error recovery gracefullyEsteban Küber-4/+7
2019-07-11Remove feature gate `dropck_parametricity` completelyLzu Tao-12/+2
Therefore we also remove `#[unsafe_destructor_blind_to_params]` attribute completly.
2019-07-11Address review commentsVadim Petrochenkov-9/+10
2019-07-11pretty-print: Merge `print_tts` and `print_tts_ext`Vadim Petrochenkov-10/+6
2019-07-11pretty-print: Do not lose the `$crate` printing flag in `print_tt`Vadim Petrochenkov-1/+1
2019-07-11Rollup merge of #62476 - petrochenkov:expref, r=matthewjasperMazdak Farrokhzad-348/+234
Continue refactoring macro expansion and resolution This PR continues the work started in https://github.com/rust-lang/rust/pull/62042. It contains a set of more or less related refactorings with the general goal of making things simpler and more orthogonal. Along the way most of the issues uncovered in https://github.com/rust-lang/rust/pull/62086 are fixed. The PR is better read in per-commit fashion with whitespace changes ignored. I tried to leave some more detailed commit messages describing the motivation behind the individual changes. Fixes https://github.com/rust-lang/rust/issues/44692 Fixes https://github.com/rust-lang/rust/issues/52363 Unblocks https://github.com/rust-lang/rust/pull/62086 r? @matthewjasper
2019-07-11expand: Move "derive containers" into a separate `InvocationKind` variantVadim Petrochenkov-14/+25
`InvocationKind::Attr { attr: None, .. }` meaning something entirely different from a regular attribute was confusing as hell.
2019-07-11expand: Merge `expand_{bang,attr,derive}_invoc` into a single functionVadim Petrochenkov-116/+78
It's more convenient to have all this highly related stuff together on one screen (for future refactorings). The `expand_invoc` function is compact enough now, after all the previous refactorings.
2019-07-11expand: It's always possible to create a dummy AST fragmentVadim Petrochenkov-44/+39
Remove a bunch of `Option`s that assumed that dummy fragment creation could fail. The test output changed due to not performing the expansion in `fn expand_invoc` in case of the recursion limit hit.
2019-07-11hygiene: Make sure each `Mark` has an associated expansion infoVadim Petrochenkov-2/+12
The root expansion was missing one. Expansions created for "derive containers" (see one of the next commits for the description) also didn't get expansion info.
2019-07-11hygiene: Introduce a helper method for creating new expansionsVadim Petrochenkov-40/+18
Creating a fresh expansion and immediately generating a span from it is the most common scenario. Also avoid allocating `allow_internal_unstable` lists for derive markers repeatedly. And rename `ExpnInfo::with_unstable` to `ExpnInfo::allow_unstable`, seems to be a better fitting name.
2019-07-11expand: Do not overwrite existing `ExpnInfo` when injecting derive markersVadim Petrochenkov-3/+4
Create a fresh expansion for them instead - this is the usual way to allow unstable features for generated/desugared code. Fixes https://github.com/rust-lang/rust/issues/52363
2019-07-11resolve/expand: Catch macro kind mismatches early in resolveVadim Petrochenkov-34/+5
This way we are processing all of them in a single point, rather than separately for each syntax extension kind. Also, the standard expected/found wording is used.
2019-07-11resolve/expand: `resolve_macro_invocation` no longer returns determinate errorsVadim Petrochenkov-71/+57
It either returns the indeterminacy error, or valid (but perhaps dummy) `SyntaxExtension`. With this change enum `Determinacy` is no longer used in libsyntax and can be moved to resolve. The regressions in diagnosics are fixed in the next commits.
2019-07-11resolve: Make proc macro stubs less stubbyVadim Petrochenkov-1/+21
Create real working and registered (even if dummy) `SyntaxExtension`s for them. This improves error recovery and allows to avoid all special cases for proc macro stubs (except for the error on use, of course). The introduced dummy `SyntaxExtension`s can be used for any other inappropriately resolved macros as well.
2019-07-11hygiene: Reuse `MacroKind` in `ExpnKind`Vadim Petrochenkov-19/+11
Orthogonality and reuse are good.
2019-07-11syntax: Make def-site span mandatory in ↵Vadim Petrochenkov-17/+12
ExpnInfo/MacroBacktrace/DiagnosticSpanMacroExpansion We have to deal with dummy spans anyway Remove def-site span from expander interfaces. It's not used by the expansion infra, only by specific expanders, which can keep it themselves if they want it.
2019-07-11expand: Get rid of `resolve_macro_path`Vadim Petrochenkov-14/+11
It was used to choose whether to apply derive markers like `#[rustc_copy_clone_marker]` or not, but it was called before all the data required for resolution is available, so it could work incorrectly in some corner cases (like user-defined derives name `Copy` or `Eq`). Delay the decision about markers until the proper resolution results are available instead.
2019-07-11Rename some things in `syntax_pos/hygiene`Vadim Petrochenkov-17/+15
More consistent with other naming: ExpnFormat -> ExpnKind ExpnKind::name -> ExpnKind::descr DesugaringKind::name -> DesugaringKind::descr Shorter, no tautology: CompilerDesugaring -> Desugaring CompilerDesugaringKind -> DesugaringKind
2019-07-11Move `MacroKind` into `libsyntax_pos`Vadim Petrochenkov-28/+1
So it can be eventually used in `ExpnInfo`
2019-07-11Remove `MacroKind::ProcMacroStub`Vadim Petrochenkov-3/+0
It's internal to resolve and always results in `Res::Err` outside of resolve. Instead put `DefKind::Fn`s themselves into the macro namespace, it's ok. Proc macro stubs are items placed into macro namespase for functions that define proc macros. https://github.com/rust-lang/rust/pull/52383 The rustdoc test is changed because the old test didn't actually reproduce the ICE it was supposed to reproduce.
2019-07-10File is now short enough for tidyMark Rousskov-2/+0
2019-07-10Remove writer function from PrintStateMark Rousskov-37/+32
2019-07-10Use constant instead of magic numberMark Rousskov-1/+1
2019-07-10Remove needless indent argumentsMark Rousskov-12/+9
We're always indenting by INDENT_UNIT anyway
2019-07-10Move pp::Printer helpers to direct implMark Rousskov-49/+51
2019-07-10Rename is_bol -> is_beginning_of_lineMark Rousskov-10/+9
Also moves it to pp::Printer from PrintState.
2019-07-10Remove needless indirection in bcloseMark Rousskov-6/+2
2019-07-10Drop length from Token::StringMark Rousskov-12/+15
It was always set to the string's length
2019-07-10Rename pretty_print_* to scan_* to follow naming in the paperMark Rousskov-11/+11
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-10Remove is_begin/is_end functions from PrintStateMark Rousskov-16/+4
These are somewhat ambiguous (beginning/end of what?) so it's better to inline their one use into the code.
2019-07-10Simplify print_endMark Rousskov-3/+1
Presumably the code was from an older age of Rust and can now be written much simpler.
2019-07-10Simplify check_stack implementationMark Rousskov-7/+7
2019-07-10Move BufEntry assignment into scan_pushMark Rousskov-12/+7
2019-07-10Remove useless call to indentMark Rousskov-1/+0
2019-07-10Fully privatize (vs. crate visibility) functionsMark Rousskov-18/+18
2019-07-10Move pp::Printer out field to owned StringMark Rousskov-26/+21
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-10Inline State::new_from_input in pprustMark Rousskov-18/+6
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-10print_crate returns String instead of taking an out pointerMark Rousskov-4/+5
2019-07-10Replace src: &mut dyn Read with StringMark Rousskov-7/+3
2019-07-10Combine comment-handling logic into structMark Rousskov-37/+57
This also permits sharing the underlying code between pprust and hir::print.
2019-07-10Inline State::newMark Rousskov-9/+1
There was only one callsite for each and this removes the unwrap_or_default's on the comments argument
2019-07-10Stop Option-wrapping commentsMark Rousskov-14/+10
We always check against the length before indexing anyway.
2019-07-10Remove unused boxes vectorMark Rousskov-12/+0
2019-07-10Privatize and remove unused functionsMark Rousskov-19/+9
2019-07-10Move lifetime_to_string to Display implMark Rousskov-5/+7
2019-07-10Remove unused arm_to_stringMark Rousskov-4/+0