diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/ui/unpretty | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/unpretty')
-rw-r--r-- | tests/ui/unpretty/box.rs | 9 | ||||
-rw-r--r-- | tests/ui/unpretty/box.stdout | 14 | ||||
-rw-r--r-- | tests/ui/unpretty/flattened-format-args.rs | 8 | ||||
-rw-r--r-- | tests/ui/unpretty/flattened-format-args.stdout | 16 | ||||
-rw-r--r-- | tests/ui/unpretty/mir-unpretty.rs | 5 | ||||
-rw-r--r-- | tests/ui/unpretty/mir-unpretty.stderr | 11 | ||||
-rw-r--r-- | tests/ui/unpretty/unpretty-expr-fn-arg.rs | 13 | ||||
-rw-r--r-- | tests/ui/unpretty/unpretty-expr-fn-arg.stdout | 17 |
8 files changed, 93 insertions, 0 deletions
diff --git a/tests/ui/unpretty/box.rs b/tests/ui/unpretty/box.rs new file mode 100644 index 000000000..81f5c88d7 --- /dev/null +++ b/tests/ui/unpretty/box.rs @@ -0,0 +1,9 @@ +// compile-flags: -Zunpretty=hir +// check-pass + +#![feature(stmt_expr_attributes, rustc_attrs)] + +fn main() { + let _ = #[rustc_box] + Box::new(1); +} diff --git a/tests/ui/unpretty/box.stdout b/tests/ui/unpretty/box.stdout new file mode 100644 index 000000000..0c6e012e6 --- /dev/null +++ b/tests/ui/unpretty/box.stdout @@ -0,0 +1,14 @@ +// compile-flags: -Zunpretty=hir +// check-pass + +#![feature(stmt_expr_attributes, rustc_attrs)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +fn main() { + let _ = + #[rustc_box] + Box::new(1); + } diff --git a/tests/ui/unpretty/flattened-format-args.rs b/tests/ui/unpretty/flattened-format-args.rs new file mode 100644 index 000000000..705dded16 --- /dev/null +++ b/tests/ui/unpretty/flattened-format-args.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunpretty=hir -Zflatten-format-args=yes +// check-pass + +fn main() { + let x = 1; + // Should flatten to println!("a 123 b {x} xyz\n"): + println!("a {} {}", format_args!("{} b {x}", 123), "xyz"); +} diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout new file mode 100644 index 000000000..a8fe8da00 --- /dev/null +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -0,0 +1,16 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// compile-flags: -Zunpretty=hir -Zflatten-format-args=yes +// check-pass + +fn main() { + let x = 1; + // Should flatten to println!("a 123 b {x} xyz\n"): + { + ::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["a 123 b ", + " xyz\n"], + &[<#[lang = "format_argument"]>::new_display(&x)])); + }; + } diff --git a/tests/ui/unpretty/mir-unpretty.rs b/tests/ui/unpretty/mir-unpretty.rs new file mode 100644 index 000000000..30620c69f --- /dev/null +++ b/tests/ui/unpretty/mir-unpretty.rs @@ -0,0 +1,5 @@ +// compile-flags: -Z unpretty=mir + +fn main() { + let x: () = 0; //~ ERROR: mismatched types +} diff --git a/tests/ui/unpretty/mir-unpretty.stderr b/tests/ui/unpretty/mir-unpretty.stderr new file mode 100644 index 000000000..3808f8583 --- /dev/null +++ b/tests/ui/unpretty/mir-unpretty.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/mir-unpretty.rs:4:17 + | +LL | let x: () = 0; + | -- ^ expected `()`, found integer + | | + | expected due to this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/unpretty/unpretty-expr-fn-arg.rs b/tests/ui/unpretty/unpretty-expr-fn-arg.rs new file mode 100644 index 000000000..6e1132a33 --- /dev/null +++ b/tests/ui/unpretty/unpretty-expr-fn-arg.rs @@ -0,0 +1,13 @@ +// Regression test for the ICE described in #82328. The pretty-printer for +// `-Zunpretty=hir,typed` would previously retrieve type-checking results +// when entering a body, which means that type information was not available +// for expressions occurring in function signatures, as in the `foo` example +// below, leading to an ICE. + +// check-pass +// compile-flags: -Zunpretty=hir,typed +#![allow(dead_code)] + +fn main() {} + +fn foo(-128..=127: i8) {} diff --git a/tests/ui/unpretty/unpretty-expr-fn-arg.stdout b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout new file mode 100644 index 000000000..b745b9886 --- /dev/null +++ b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout @@ -0,0 +1,17 @@ +// Regression test for the ICE described in #82328. The pretty-printer for +// `-Zunpretty=hir,typed` would previously retrieve type-checking results +// when entering a body, which means that type information was not available +// for expressions occurring in function signatures, as in the `foo` example +// below, leading to an ICE. + +// check-pass +// compile-flags: -Zunpretty=hir,typed +#![allow(dead_code)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +fn main() ({ } as ()) + +fn foo((-(128 as i8) as i8)...(127 as i8): i8) ({ } as ()) |