diff options
| author | kennytm <kennytm@gmail.com> | 2017-11-07 15:52:15 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2017-11-07 22:40:20 +0800 |
| commit | 0d53ecd0c788d5c492cf5023c8c76420ef349244 (patch) | |
| tree | 67cdcf6f5cf391b20eb76b4f09ac77b028a2e3b3 /src/test/incremental/thinlto | |
| parent | 1683b830a88c99c5072563150acb3f7feaac0d04 (diff) | |
| parent | aa38a1ee5092fb81e23b0cbd215535de08ae7b28 (diff) | |
| download | rust-0d53ecd0c788d5c492cf5023c8c76420ef349244.tar.gz rust-0d53ecd0c788d5c492cf5023c8c76420ef349244.zip | |
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...
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions
