Commit Graph

316 Commits

Author SHA1 Message Date
Mikhail Babenko
ab6ea2bba7 add regression test 2020-02-07 18:18:07 +03:00
Mazdak Farrokhzad
00f0b0cd3a pretty: print attrs in struct expr 2020-02-02 09:25:54 +01:00
Tomasz Miąsko
2fd6c4a18a Remove unused ignore-license directives
The tidy check was removed in rust-lang/rust#53617
2020-01-24 00:00:00 +00:00
Mazdak Farrokhzad
19db2d2fed ast_stmt_expr_attr -> pretty & ui tests 2019-12-20 22:53:40 +01:00
Matthew Jasper
6dcc78997f Add more tests for raw_ref_op 2019-12-18 20:30:00 +00:00
Mazdak Farrokhzad
e9840d94b9 Print the visibility in print_variant. 2019-12-07 05:59:41 +01:00
Jon Gjengset
31fc42b7f7 Merge branch 'master' into format-temporaries 2019-11-02 11:12:42 -04:00
Patryk Wychowaniec
e188e2db84
Fix a previously forgotten pretty-printing test after a change to the pretty-printing mechanism. 2019-10-28 18:43:59 +01:00
Jon Gjengset
8990f7d627 Update pretty-print test with new format! impl 2019-09-28 09:55:26 -04:00
Matthew Jasper
b4ef99f4a6 Print visibility of macro items 2019-09-15 10:22:13 +01:00
Vadim Petrochenkov
5b7df0922e pprust: Do not print spaces before some tokens 2019-08-25 21:23:17 +03:00
sd234678
56ebd57960 Remove meaningless comments in src/test 2019-08-16 10:54:20 +01:00
Vadim Petrochenkov
fa7fe19601 resolve: Remove remaining special cases from built-in macros 2019-08-10 21:50:56 +03:00
Vadim Petrochenkov
0cdd18d0a7 pprust: Support macro macros 2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
a2a1cd1864 pprust: Fix formatting regressions from the previous commits
Fix some remaining cases of bad formatting
Update some failing tests
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
75896011dc pprust: Do not convert attributes into MetaItems for printing
Fixes https://github.com/rust-lang/rust/issues/62628
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
11585b598c pprust: Use print_mac_common for delimited token groups 2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
500b00127b pprust: Use print_mac_common for macro_rules definitions 2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
65a714a6a0 pprust: Move some methods to the PrintState trait
So that path and macro argument printing code can be shared
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
ea4ad555d7 Introduce #[rustc_dummy] attribute and use it in tests
Unlike other built-in attributes, this attribute accepts any input
2019-06-08 23:55:25 +03:00
varkor
59762baf8a Move async/await tests to test/ui/async-await 2019-05-24 21:49:34 +01:00
Eduard-Mihai Burtescu
3e1cef7007 rustc: pass Option<&Substs> and Namespace around in ty::item_path. 2019-03-15 13:25:10 +02:00
Alexander Regueiro
fe30743c79 Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
Alexander Regueiro
379cd29d1c Nit 2019-03-03 02:58:09 +00:00
Dan Robertson
04d0a8cb83
Fix C-variadic function printing
There is no longer a need to append the string `", ..."` to a functions
args as `...` is parsed as an argument and will appear in the functions
arguments.
2019-03-02 15:03:09 +00:00
Vadim Petrochenkov
c375333362 Pretty print $crate as crate or crate_name in more cases 2019-01-26 17:11:28 +03:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Vadim Petrochenkov
69c66286a9 Reintroduce special pretty-printing for $crate when it's necessary for proc macros 2018-12-19 23:17:54 +03:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Eduard-Mihai Burtescu
3369929ddb tests: use force-host and no-prefer-dynamic in all proc_macro tests. 2018-11-30 06:15:20 +02:00
Eduard-Mihai Burtescu
d3ab4a74ef tests: remove ignore-stage1 where possible in proc_macro tests. 2018-11-30 06:15:20 +02:00
Zack M. Davis
1081bbbfc5 abolish ICE when pretty-printing async block
Joshua Netterfield reported an ICE when the unused-parentheses lint
triggered around an async block (#54752). In order to compose an
autofixable suggestion, the lint invokes the pretty-printer on the
unnecessarily-parenthesized expression. (One wonders why the lint
doesn't just use `SourceMap::span_to_snippet` instead, to preserve the
formatting of the original source?—but for that, you'd have to ask the
author of 5c9f806d.)

But then the pretty-printer panics when trying to call `<pprust::State
as PrintState>::end` when `State.boxes` is empty. Empirically, the
problem would seem to be solved if we start some "boxes" beforehand in
the `ast::ExprKind::Async` arm of the big match in
`print_expr_outer_attr_style`, exactly like we do in the
immediately-preceding match arm for `ast::ExprKind::Block`—it would
seem pretty ("pretty") reasonable for the pretty-printing of async
blocks to work a lot like the pretty-printing of ordinary non-async
blocks, right??

Of course, it would be shamefully cargo-culty to commit code on the
basis of this kind of mere reasoning-by-analogy (in contrast to
understanding the design of the pretty-printer in such detail that the
correctness of the patch is comprehended with all the lucid certainty
of mathematical proof, rather than being merely surmised by
intuition). But maybe we care more about fixing the bug with high
probability today, than with certainty in some indefinite hypothetical
future?  Maybe the effort is worth a fifth of a shirt??

Humbly resolves #54752.
2018-10-02 23:02:51 -07:00
Tinco Andringa
b985e91e43 update result of issue 12590 test 2018-09-10 15:44:42 +02:00
Felix S. Klock II
9478190afc Fixed the test to match the compiler's output. 2018-09-10 12:33:38 +02:00
Tinco Andringa
23ee94e92b Correctly close indentation blocks when pretty printing non-inline module 2018-09-10 12:33:38 +02:00
Tinco Andringa
81a8ee8fc4 pretty=expanded should expand mod declarations 2018-09-10 12:33:38 +02:00
Tinco Andringa
c3afb16e16 Track whether module declarations are inline (fixes #12590) 2018-09-10 12:33:37 +02:00
Sergio Benitez
ed0bd38cac Stabilize 'attr_literals' feature. 2018-08-23 19:06:07 -07:00
Eduard-Mihai Burtescu
cd47831bf0 syntax: gensym the injected std/core extern crates in the Rust 2018 edition. 2018-08-14 07:06:46 +03:00
Vadim Petrochenkov
50886115d7 Address review comments
Adjust a few fulldeps and pretty-printing tests
Fix rebase
2018-08-06 23:55:53 +03:00
Tinco Andringa
b96deed121 fix expected output of pretty/cast-lt and issue-4264 tests 2018-07-12 01:19:27 +02:00
Aidan Hobson Sayers
9b5859aea1 Remove all unstable placement features
Closes #22181, #27779
2018-04-03 11:02:34 +02:00
Matthias Krüger
4452446292 fix more typos found by codespell. 2018-02-17 17:38:49 +01:00
Vadim Petrochenkov
7a95e716c7 Fix whitespacing issues in pretty-printing of bounds 2017-12-20 00:23:18 +03:00
Jeffrey Seyfried
8dbe79ae5e Fix fallout in tests. 2017-12-12 13:15:03 -08:00
kennytm
0d53ecd0c7
Rollup merge of #45784 - harpocrates:fix/print-parens-cast-lt, r=kennytm
Pretty print parens around casts on the LHS of `<`/`<<`

When pretty printing a cast expression occuring on the LHS of a `<` or `<<` expression, we should add parens around the cast. Otherwise, the `<`/`<<` gets interpreted as the beginning of the generics for the type on the RHS of the cast.

Consider:

    $ cat parens_cast.rs
    macro_rules! negative {
        ($e:expr) => { $e < 0 }
    }

    fn main() {
        negative!(1 as i32);
    }

Before this PR, the output of the following is not valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { 1 as i32 < 0; }

After this PR, the output of the following is valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { (1 as i32) < 0; }

I've gone through several README/wiki style documents but I'm still not sure where to test this though. I'm not even sure if this sort of thing is tested...
2017-11-07 22:40:20 +08:00
Alec Theriault
aa38a1ee50 Update comments in cast-lt.pp 2017-11-06 22:18:14 -08:00
Alec Theriault
3761c0d246 Fix comments 2017-11-05 20:53:46 -08:00
Alec Theriault
005d14d5c8 Added tests 2017-11-05 12:27:46 -08:00
leonardo.yvens
5190abb941 Fix unsafe auto trait pretty print.
It was being printed wrong as auto unsafe trait
2017-11-03 16:13:23 -02:00