summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-04-25 13:51:49 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2025-04-25 14:33:16 +1000
commite37c3674828a75ffdc2b94d9d273e9c02a9ee11f (patch)
tree12a729811c4bc54b7f0bde32a81f246cb1efe68b /tests
parentee43aa356aa228b5cc8da41622855f4f2c07f8ab (diff)
downloadrust-e37c3674828a75ffdc2b94d9d273e9c02a9ee11f.tar.gz
rust-e37c3674828a75ffdc2b94d9d273e9c02a9ee11f.zip
Improve pretty printing of if/else.
By removing some of the over-indenting. AST pretty printing now looks
correct. HIR pretty printing is better, but still over-indents some.
Diffstat (limited to 'tests')
-rw-r--r--tests/pretty/hir-if-else.pp62
-rw-r--r--tests/pretty/if-else.pp60
-rw-r--r--tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout94
-rw-r--r--tests/ui/match/issue-82392.stdout12
-rw-r--r--tests/ui/proc-macro/quote/debug.stdout24
5 files changed, 126 insertions, 126 deletions
diff --git a/tests/pretty/hir-if-else.pp b/tests/pretty/hir-if-else.pp
index 072e050d3e0..6626bf9cd28 100644
--- a/tests/pretty/hir-if-else.pp
+++ b/tests/pretty/hir-if-else.pp
@@ -12,37 +12,37 @@ fn f(x: u32,
     let mut a = 0;
     if x > y { a = 1; } else { a = 2; }
 
-            if x < 1
-                    {
-                        a = 1;
-                    } else if x < 2
-                        {
-                            a = 2;
-                        } else if x < 3
-                            {
-                                a = 3;
-                            } else if x < 4 { a = 4; } else { a = 5; }
+        if x < 1
+            {
+                a = 1;
+            } else if x < 2
+            {
+                a = 2;
+            } else if x < 3
+            {
+                a = 3;
+            } else if x < 4 { a = 4; } else { a = 5; }
 
-                                if x < y
-                                        {
-                                            a += 1;
-                                            a += 1;
-                                            a += 1;
-                                            a += 1;
-                                            a += 1;
-                                            a += 1;
-                                        } else { a += 1; a += 1; a += 1; a += 1; a += 1; a += 1; }
+            if x < y
+                {
+                    a += 1;
+                    a += 1;
+                    a += 1;
+                    a += 1;
+                    a += 1;
+                    a += 1;
+                } else { a += 1; a += 1; a += 1; a += 1; a += 1; a += 1; }
 
-                                        if x < 1
-                                                {
-                                                    if x < 2
-                                                            {
-                                                                if x < 3
-                                                                        {
-                                                                            a += 1;
-                                                                        } else if x < 4
-                                                                            { a += 1; if x < 5 { a += 1; } }
-                                                                            } else if x < 6 { a += 1; } }
-                                                                    }
+                if x < 1
+                    {
+                        if x < 2
+                            {
+                                if x < 3
+                                    {
+                                        a += 1;
+                                    } else if x < 4
+                                    { a += 1; if x < 5 { a += 1; } }
+                                    } else if x < 6 { a += 1; } }
+                                }
 
-                                                                fn main() { f(3, 4); }
+                                fn main() { f(3, 4); }
diff --git a/tests/pretty/if-else.pp b/tests/pretty/if-else.pp
index 14c715a8793..d4ff02c5441 100644
--- a/tests/pretty/if-else.pp
+++ b/tests/pretty/if-else.pp
@@ -13,40 +13,40 @@ fn f(x: u32, y: u32) {
     if x > y { a = 1; } else { a = 2; }
 
     if x < 1 {
-            a = 1;
-        } else if x < 2 {
-            a = 2;
-        } else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; }
+        a = 1;
+    } else if x < 2 {
+        a = 2;
+    } else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; }
 
     if x < y {
-            a += 1;
-            a += 1;
-            a += 1;
-        } else {
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-            a += 1;
-        }
+        a += 1;
+        a += 1;
+        a += 1;
+    } else {
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+        a += 1;
+    }
 
     if x < 1 {
-            if x < 2 {
-                    if x < 3 {
-                            a += 1;
-                        } else if x < 4 { a += 1; if x < 5 { a += 1; } }
-                } else if x < 6 { a += 1; }
-        }
+        if x < 2 {
+            if x < 3 {
+                a += 1;
+            } else if x < 4 { a += 1; if x < 5 { a += 1; } }
+        } else if x < 6 { a += 1; }
+    }
 }
 
 fn main() { f(3, 4); }
diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout
index 9300f610f8e..33193c78334 100644
--- a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout
+++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout
@@ -18,18 +18,18 @@ fn arbitrary_consuming_method_for_demonstration_purposes() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!(*{
-                                    (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                                    __local_bind0
-                                } as usize)) {
+                                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+                                __local_bind0
+                            } as usize)) {
 
 
 
 
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: elem as usize\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: elem as usize\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
 }
 fn addr_of() {
@@ -40,12 +40,12 @@ fn addr_of() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!&*__local_bind0) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: &elem\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: &elem\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
 }
 fn binary() {
@@ -56,12 +56,12 @@ fn binary() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!(*__local_bind0 == 1)) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: elem == 1\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: elem == 1\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
     {
         #[allow(unused_imports)]
@@ -69,12 +69,12 @@ fn binary() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!(*__local_bind0 >= 1)) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: elem >= 1\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: elem >= 1\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
     {
         #[allow(unused_imports)]
@@ -82,12 +82,12 @@ fn binary() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!(*__local_bind0 > 0)) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: elem > 0\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: elem > 0\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
     {
         #[allow(unused_imports)]
@@ -95,12 +95,12 @@ fn binary() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!(*__local_bind0 < 3)) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: elem < 3\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: elem < 3\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
     {
         #[allow(unused_imports)]
@@ -108,12 +108,12 @@ fn binary() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!(*__local_bind0 <= 3)) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: elem <= 3\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: elem <= 3\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
     {
         #[allow(unused_imports)]
@@ -121,12 +121,12 @@ fn binary() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!(*__local_bind0 != 3)) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: elem != 3\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: elem != 3\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
 }
 fn unary() {
@@ -137,12 +137,12 @@ fn unary() {
         let mut __capture0 = ::core::asserting::Capture::new();
         let __local_bind0 = &elem;
         if ::core::intrinsics::unlikely(!**__local_bind0) {
-                (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
-                {
-                    ::std::rt::panic_fmt(format_args!("Assertion failed: *elem\nWith captures:\n  elem = {0:?}\n",
-                            __capture0));
-                }
+            (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0);
+            {
+                ::std::rt::panic_fmt(format_args!("Assertion failed: *elem\nWith captures:\n  elem = {0:?}\n",
+                        __capture0));
             }
+        }
     };
 }
 fn main() {}
diff --git a/tests/ui/match/issue-82392.stdout b/tests/ui/match/issue-82392.stdout
index 34d2c7aa2ba..6a68bbdfd56 100644
--- a/tests/ui/match/issue-82392.stdout
+++ b/tests/ui/match/issue-82392.stdout
@@ -9,9 +9,9 @@ extern crate std;
 
 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 ())
+        ({ } 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 ())
diff --git a/tests/ui/proc-macro/quote/debug.stdout b/tests/ui/proc-macro/quote/debug.stdout
index b2a9f031b28..3acb472d9c0 100644
--- a/tests/ui/proc-macro/quote/debug.stdout
+++ b/tests/ui/proc-macro/quote/debug.stdout
@@ -32,12 +32,12 @@ fn main() {
                         let mut iter =
                             "\"world\"".parse::<crate::TokenStream>().unwrap().into_iter();
                         if let (Some(crate::TokenTree::Literal(mut lit)), None) =
-                                    (iter.next(), iter.next()) {
-                                lit.set_span(crate::Span::recover_proc_macro_span(2));
-                                lit
-                            } else {
-                                ::core::panicking::panic("internal error: entered unreachable code")
-                            }
+                                (iter.next(), iter.next()) {
+                            lit.set_span(crate::Span::recover_proc_macro_span(2));
+                            lit
+                        } else {
+                            ::core::panicking::panic("internal error: entered unreachable code")
+                        }
                     }), &mut ts);
         crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';',
                         crate::Spacing::Alone)), &mut ts);
@@ -51,12 +51,12 @@ fn main() {
                         let mut iter =
                             "r#\"raw\"literal\"#".parse::<crate::TokenStream>().unwrap().into_iter();
                         if let (Some(crate::TokenTree::Literal(mut lit)), None) =
-                                    (iter.next(), iter.next()) {
-                                lit.set_span(crate::Span::recover_proc_macro_span(5));
-                                lit
-                            } else {
-                                ::core::panicking::panic("internal error: entered unreachable code")
-                            }
+                                (iter.next(), iter.next()) {
+                            lit.set_span(crate::Span::recover_proc_macro_span(5));
+                            lit
+                        } else {
+                            ::core::panicking::panic("internal error: entered unreachable code")
+                        }
                     }), &mut ts);
         crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';',
                         crate::Spacing::Alone)), &mut ts);