Skip to content

Commit 885b456

Browse files
authored
Rollup merge of rust-lang#125158 - Nilstrieb:block-indent, r=compiler-errors
hir pretty: fix block indent before: ```rust fn main() { { { ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"])); }; } } ``` after: ```rust fn main() { { { ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"])); }; } } ``` AST pretty does the same.
2 parents 6586ed7 + 7b1527f commit 885b456

File tree

9 files changed

+53
-53
lines changed

9 files changed

+53
-53
lines changed

compiler/rustc_hir_pretty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ impl<'a> State<'a> {
14541454
self.word_space(":");
14551455
}
14561456
// containing cbox, will be closed by print-block at `}`
1457-
self.cbox(INDENT_UNIT);
1457+
self.cbox(0);
14581458
// head-box, will be closed by print-block after `{`
14591459
self.ibox(0);
14601460
self.print_block(blk);

tests/pretty/issue-4264.pp

+23-23
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
fn foo(_: [i32; (3 as usize)]) ({ } as ())
1212

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

17-
let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
17+
let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
1818

19-
let _ =
20-
(((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3]) as
21-
&[i32; 3]) as *const _ as *const [i32; 3]) as
22-
*const [i32; (3 as usize)] as *const [i32; 3]);
19+
let _ =
20+
(((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3]) as &[i32; 3])
21+
as *const _ as *const [i32; 3]) as *const [i32; (3 as usize)]
22+
as *const [i32; 3]);
2323

2424

2525

@@ -29,17 +29,17 @@
2929

3030

3131

32-
({
33-
let res =
34-
((::alloc::fmt::format as
35-
for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const
36-
as
37-
fn(&[&'static str]) -> Arguments<'_> {Arguments::<'_>::new_const})((&([("test"
38-
as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>))
39-
as String);
40-
(res as String)
41-
} as String);
42-
} as ())
32+
({
33+
let res =
34+
((::alloc::fmt::format as
35+
for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const
36+
as
37+
fn(&[&'static str]) -> Arguments<'_> {Arguments::<'_>::new_const})((&([("test"
38+
as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>))
39+
as String);
40+
(res as String)
41+
} as String);
42+
} as ())
4343
type Foo = [i32; (3 as usize)];
4444
struct Bar {
4545
x: [i32; (3 as usize)],
@@ -48,9 +48,9 @@
4848
enum Baz { BazVariant([i32; (5 as usize)]), }
4949
fn id<T>(x: T) -> T ({ (x as T) } as T)
5050
fn use_id() ({
51-
let _ =
52-
((id::<[i32; (3 as usize)]> as
53-
fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1 as i32),
54-
(2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3]);
55-
} as ())
51+
let _ =
52+
((id::<[i32; (3 as usize)]> as
53+
fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1 as i32),
54+
(2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3]);
55+
} as ())
5656
fn main() ({ } as ())

tests/ui/match/issue-82392.stdout

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ extern crate std;
77
//@ check-pass
88

99
fn main() ({
10-
(if (true as bool)
11-
({ } as
12-
()) else if (let Some(a) =
13-
((Some as
14-
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
15-
Option<i32>) as bool) ({ } as ()) as ())
16-
} as ())
10+
(if (true as bool)
11+
({ } as
12+
()) else if (let Some(a) =
13+
((Some as
14+
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
15+
Option<i32>) as bool) ({ } as ()) as ())
16+
} as ())

tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ LL + let str::as_bytes;
2525
|
2626

2727
error[E0533]: expected unit struct, unit variant or constant, found associated function `str<{
28-
fn str() { let (/*ERROR*/); }
29-
}, T>::as_bytes`
28+
fn str() { let (/*ERROR*/); }
29+
}, T>::as_bytes`
3030
--> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:9
3131
|
3232
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;

tests/ui/type-alias-impl-trait/issue-60662.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ extern crate std;
1010
trait Animal { }
1111

1212
fn main() {
13-
type ServeFut = /*impl Trait*/;
14-
}
13+
type ServeFut = /*impl Trait*/;
14+
}

tests/ui/unpretty/bad-literal.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ extern crate std;
77

88
// In #100948 this caused an ICE with -Zunpretty=hir.
99
fn main() {
10-
<bad-literal>;
11-
}
10+
<bad-literal>;
11+
}

tests/ui/unpretty/box.stdout

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ::std::prelude::rust_2015::*;
88
extern crate std;
99

1010
fn main() {
11-
let _ =
12-
#[rustc_box]
13-
Box::new(1);
14-
}
11+
let _ =
12+
#[rustc_box]
13+
Box::new(1);
14+
}

tests/ui/unpretty/flattened-format-args.stdout

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ extern crate std;
66
//@ check-pass
77

88
fn main() {
9-
let x = 1;
10-
// Should flatten to println!("a 123 b {x} xyz\n"):
11-
{
12-
::std::io::_print(format_arguments::new_v1(&["a 123 b ",
13-
" xyz\n"], &[format_argument::new_display(&x)]));
14-
};
15-
}
9+
let x = 1;
10+
// Should flatten to println!("a 123 b {x} xyz\n"):
11+
{
12+
::std::io::_print(format_arguments::new_v1(&["a 123 b ", " xyz\n"],
13+
&[format_argument::new_display(&x)]));
14+
};
15+
}

tests/ui/unpretty/let-else-hir.stdout

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ extern crate std;
99

1010
fn foo(x:
1111
Option<u32>) {
12-
let Some(_) = x else
13-
{
12+
let Some(_) = x else
13+
{
1414

15-
{ ::std::rt::begin_panic("explicit panic") }
16-
};
17-
}
15+
{ ::std::rt::begin_panic("explicit panic") }
16+
};
17+
}
1818
fn main() { }

0 commit comments

Comments
 (0)