about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-27 16:39:04 +0000
committerbors <bors@rust-lang.org>2025-04-27 16:39:04 +0000
commitcb31a009e3e735ab08613cec2d8a5a754e65596f (patch)
tree226ee0d06349c975fdf102a23c87bd03402841f9 /tests
parent267cae5bdbd602dd13f3851b9c96ce93697e59a0 (diff)
parentfdfc7c0044fc1a912d89183262d9f7c58992c55f (diff)
downloadrust-cb31a009e3e735ab08613cec2d8a5a754e65596f.tar.gz
rust-cb31a009e3e735ab08613cec2d8a5a754e65596f.zip
Auto merge of #140366 - matthiaskrgr:rollup-zd3q1oy, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #140246 (Fix never pattern printing)
 - #140280 (Improve if/else pretty printing)
 - #140348 (Update lint-docs to default to Rust 2024)
 - #140358 (Use `search_for_cycle_permutation` to look for `variances_of`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/pretty/hir-if-else.pp39
-rw-r--r--tests/pretty/hir-if-else.rs59
-rw-r--r--tests/pretty/if-else.pp52
-rw-r--r--tests/pretty/if-else.rs65
-rw-r--r--tests/pretty/never-pattern.pp17
-rw-r--r--tests/pretty/never-pattern.rs16
-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.stdout14
-rw-r--r--tests/ui/proc-macro/quote/debug.stdout24
9 files changed, 314 insertions, 66 deletions
diff --git a/tests/pretty/hir-if-else.pp b/tests/pretty/hir-if-else.pp
new file mode 100644
index 00000000000..200e34ac4f5
--- /dev/null
+++ b/tests/pretty/hir-if-else.pp
@@ -0,0 +1,39 @@
+#[prelude_import]
+use ::std::prelude::rust_2015::*;
+#[macro_use]
+extern crate std;
+//@ pretty-compare-only
+//@ pretty-mode:hir
+//@ pp-exact:hir-if-else.pp
+
+fn f(x: u32,
+    y:
+        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 < 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; }
+    }
+}
+
+fn main() { f(3, 4); }
diff --git a/tests/pretty/hir-if-else.rs b/tests/pretty/hir-if-else.rs
new file mode 100644
index 00000000000..a1cc7504f89
--- /dev/null
+++ b/tests/pretty/hir-if-else.rs
@@ -0,0 +1,59 @@
+//@ pretty-compare-only
+//@ pretty-mode:hir
+//@ pp-exact:hir-if-else.pp
+
+fn f(x: u32, y: 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 < 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;
+        }
+    }
+}
+
+fn main() {
+    f(3, 4);
+}
diff --git a/tests/pretty/if-else.pp b/tests/pretty/if-else.pp
new file mode 100644
index 00000000000..d4ff02c5441
--- /dev/null
+++ b/tests/pretty/if-else.pp
@@ -0,0 +1,52 @@
+#![feature(prelude_import)]
+#![no_std]
+#[prelude_import]
+use ::std::prelude::rust_2015::*;
+#[macro_use]
+extern crate std;
+//@ pretty-compare-only
+//@ pretty-mode:expanded
+//@ pp-exact:if-else.pp
+
+fn f(x: u32, y: 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 < 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;
+    }
+
+    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); }
diff --git a/tests/pretty/if-else.rs b/tests/pretty/if-else.rs
new file mode 100644
index 00000000000..b4085ea5606
--- /dev/null
+++ b/tests/pretty/if-else.rs
@@ -0,0 +1,65 @@
+//@ pretty-compare-only
+//@ pretty-mode:expanded
+//@ pp-exact:if-else.pp
+
+fn f(x: u32, y: 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 < 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;
+    }
+
+    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);
+}
diff --git a/tests/pretty/never-pattern.pp b/tests/pretty/never-pattern.pp
new file mode 100644
index 00000000000..923ad9b82c7
--- /dev/null
+++ b/tests/pretty/never-pattern.pp
@@ -0,0 +1,17 @@
+#![feature(prelude_import)]
+#![no_std]
+//@ pretty-mode:expanded
+//@ pp-exact:never-pattern.pp
+//@ only-x86_64
+
+#![allow(incomplete_features)]
+#![feature(never_patterns)]
+#![feature(never_type)]
+#[prelude_import]
+use ::std::prelude::rust_2015::*;
+#[macro_use]
+extern crate std;
+
+fn f(x: Result<u32, !>) { _ = match x { Ok(x) => x, Err(!) , }; }
+
+fn main() {}
diff --git a/tests/pretty/never-pattern.rs b/tests/pretty/never-pattern.rs
new file mode 100644
index 00000000000..fe170bafc66
--- /dev/null
+++ b/tests/pretty/never-pattern.rs
@@ -0,0 +1,16 @@
+//@ pretty-mode:expanded
+//@ pp-exact:never-pattern.pp
+//@ only-x86_64
+
+#![allow(incomplete_features)]
+#![feature(never_patterns)]
+#![feature(never_type)]
+
+fn f(x: Result<u32, !>) {
+    _ = match x {
+        Ok(x) => x,
+        Err(!),
+    };
+}
+
+fn main() {}
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 8b7edabf004..a0d83d962e7 100644
--- a/tests/ui/match/issue-82392.stdout
+++ b/tests/ui/match/issue-82392.stdout
@@ -8,10 +8,10 @@ extern crate std;
 //@ edition:2015
 
 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) {
+    } else if (let Some(a) =
+            ((Some as
+                    fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
+                Option<i32>) as bool) {
+    } as ())
+} as ())
diff --git a/tests/ui/proc-macro/quote/debug.stdout b/tests/ui/proc-macro/quote/debug.stdout
index 6ebb3a37951..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);