Skip to content

hir pretty: fix block indent #125158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ impl<'a> State<'a> {
self.word_space(":");
}
// containing cbox, will be closed by print-block at `}`
self.cbox(INDENT_UNIT);
self.cbox(0);
// head-box, will be closed by print-block after `{`
self.ibox(0);
self.print_block(blk);
Expand Down
46 changes: 23 additions & 23 deletions tests/pretty/issue-4264.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
fn foo(_: [i32; (3 as usize)]) ({ } as ())

fn bar() ({
const FOO: usize = ((5 as usize) - (4 as usize) as usize);
let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
const FOO: usize = ((5 as usize) - (4 as usize) as usize);
let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);

let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);

let _ =
(((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3]) as
&[i32; 3]) as *const _ as *const [i32; 3]) as
*const [i32; (3 as usize)] as *const [i32; 3]);
let _ =
(((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3]) as &[i32; 3])
as *const _ as *const [i32; 3]) as *const [i32; (3 as usize)]
as *const [i32; 3]);



Expand All @@ -29,17 +29,17 @@



({
let res =
((::alloc::fmt::format as
for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const
as
fn(&[&'static str]) -> Arguments<'_> {Arguments::<'_>::new_const})((&([("test"
as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>))
as String);
(res as String)
} as String);
} as ())
({
let res =
((::alloc::fmt::format as
for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const
as
fn(&[&'static str]) -> Arguments<'_> {Arguments::<'_>::new_const})((&([("test"
as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>))
as String);
(res as String)
} as String);
} as ())
type Foo = [i32; (3 as usize)];
struct Bar {
x: [i32; (3 as usize)],
Expand All @@ -48,9 +48,9 @@
enum Baz { BazVariant([i32; (5 as usize)]), }
fn id<T>(x: T) -> T ({ (x as T) } as T)
fn use_id() ({
let _ =
((id::<[i32; (3 as usize)]> as
fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1 as i32),
(2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3]);
} as ())
let _ =
((id::<[i32; (3 as usize)]> as
fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1 as i32),
(2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3]);
} as ())
fn main() ({ } as ())
14 changes: 7 additions & 7 deletions tests/ui/match/issue-82392.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ extern crate std;
//@ check-pass

fn main() ({
(if (true as bool)
({ } as
()) else if (let Some(a) =
((Some as
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
Option<i32>) as bool) ({ } as ()) as ())
} as ())
(if (true as bool)
({ } as
()) else if (let Some(a) =
((Some as
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
Option<i32>) as bool) ({ } as ()) as ())
} as ())
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ LL + let str::as_bytes;
|

error[E0533]: expected unit struct, unit variant or constant, found associated function `str<{
fn str() { let (/*ERROR*/); }
}, T>::as_bytes`
fn str() { let (/*ERROR*/); }
}, T>::as_bytes`
--> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:9
|
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/type-alias-impl-trait/issue-60662.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ extern crate std;
trait Animal { }

fn main() {
type ServeFut = /*impl Trait*/;
}
type ServeFut = /*impl Trait*/;
}
4 changes: 2 additions & 2 deletions tests/ui/unpretty/bad-literal.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ extern crate std;

// In #100948 this caused an ICE with -Zunpretty=hir.
fn main() {
<bad-literal>;
}
<bad-literal>;
}
8 changes: 4 additions & 4 deletions tests/ui/unpretty/box.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ::std::prelude::rust_2015::*;
extern crate std;

fn main() {
let _ =
#[rustc_box]
Box::new(1);
}
let _ =
#[rustc_box]
Box::new(1);
}
14 changes: 7 additions & 7 deletions tests/ui/unpretty/flattened-format-args.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ extern crate std;
//@ check-pass

fn main() {
let x = 1;
// Should flatten to println!("a 123 b {x} xyz\n"):
{
::std::io::_print(format_arguments::new_v1(&["a 123 b ",
" xyz\n"], &[format_argument::new_display(&x)]));
};
}
let x = 1;
// Should flatten to println!("a 123 b {x} xyz\n"):
{
::std::io::_print(format_arguments::new_v1(&["a 123 b ", " xyz\n"],
&[format_argument::new_display(&x)]));
};
}
10 changes: 5 additions & 5 deletions tests/ui/unpretty/let-else-hir.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ extern crate std;

fn foo(x:
Option<u32>) {
let Some(_) = x else
{
let Some(_) = x else
{

{ ::std::rt::begin_panic("explicit panic") }
};
}
{ ::std::rt::begin_panic("explicit panic") }
};
}
fn main() { }
Loading