From 9a7db566d7b7bb534c5dc3bcfbd2ddd51d99a8d5 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 1 Jul 2025 02:45:14 +0500 Subject: [PATCH 1/2] moved tests --- .../output-slot-init-vs-noninit.rs} | 0 .../remark-flag-functionality.rs} | 0 .../shift-right-operand-mutation.rs} | 0 .../{out-pointer-aliasing.rs => codegen/sret-aliasing-rules.rs} | 0 tests/ui/{paren-span.rs => macros/macro-paren-span-diagnostic.rs} | 0 .../macro-paren-span-diagnostic.stderr} | 0 .../panic-during-display-formatting.rs} | 0 .../panic-handler-closures.rs} | 0 .../ufcs-return-unused-parens.fixed} | 0 .../ui/{path-lookahead.rs => parser/ufcs-return-unused-parens.rs} | 0 .../ufcs-return-unused-parens.stderr} | 0 .../partialeq-ref-mismatch-diagnostic.rs} | 0 .../partialeq-ref-mismatch-diagnostic.stderr} | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{output-slot-variants.rs => codegen/output-slot-init-vs-noninit.rs} (100%) rename tests/ui/{optimization-remark.rs => codegen/remark-flag-functionality.rs} (100%) rename tests/ui/{over-constrained-vregs.rs => codegen/shift-right-operand-mutation.rs} (100%) rename tests/ui/{out-pointer-aliasing.rs => codegen/sret-aliasing-rules.rs} (100%) rename tests/ui/{paren-span.rs => macros/macro-paren-span-diagnostic.rs} (100%) rename tests/ui/{paren-span.stderr => macros/macro-paren-span-diagnostic.stderr} (100%) rename tests/ui/{panic-while-printing.rs => panics/panic-during-display-formatting.rs} (100%) rename tests/ui/{panic_implementation-closures.rs => panics/panic-handler-closures.rs} (100%) rename tests/ui/{path-lookahead.fixed => parser/ufcs-return-unused-parens.fixed} (100%) rename tests/ui/{path-lookahead.rs => parser/ufcs-return-unused-parens.rs} (100%) rename tests/ui/{path-lookahead.stderr => parser/ufcs-return-unused-parens.stderr} (100%) rename tests/ui/{partialeq_help.rs => traits/partialeq-ref-mismatch-diagnostic.rs} (100%) rename tests/ui/{partialeq_help.stderr => traits/partialeq-ref-mismatch-diagnostic.stderr} (100%) diff --git a/tests/ui/output-slot-variants.rs b/tests/ui/codegen/output-slot-init-vs-noninit.rs similarity index 100% rename from tests/ui/output-slot-variants.rs rename to tests/ui/codegen/output-slot-init-vs-noninit.rs diff --git a/tests/ui/optimization-remark.rs b/tests/ui/codegen/remark-flag-functionality.rs similarity index 100% rename from tests/ui/optimization-remark.rs rename to tests/ui/codegen/remark-flag-functionality.rs diff --git a/tests/ui/over-constrained-vregs.rs b/tests/ui/codegen/shift-right-operand-mutation.rs similarity index 100% rename from tests/ui/over-constrained-vregs.rs rename to tests/ui/codegen/shift-right-operand-mutation.rs diff --git a/tests/ui/out-pointer-aliasing.rs b/tests/ui/codegen/sret-aliasing-rules.rs similarity index 100% rename from tests/ui/out-pointer-aliasing.rs rename to tests/ui/codegen/sret-aliasing-rules.rs diff --git a/tests/ui/paren-span.rs b/tests/ui/macros/macro-paren-span-diagnostic.rs similarity index 100% rename from tests/ui/paren-span.rs rename to tests/ui/macros/macro-paren-span-diagnostic.rs diff --git a/tests/ui/paren-span.stderr b/tests/ui/macros/macro-paren-span-diagnostic.stderr similarity index 100% rename from tests/ui/paren-span.stderr rename to tests/ui/macros/macro-paren-span-diagnostic.stderr diff --git a/tests/ui/panic-while-printing.rs b/tests/ui/panics/panic-during-display-formatting.rs similarity index 100% rename from tests/ui/panic-while-printing.rs rename to tests/ui/panics/panic-during-display-formatting.rs diff --git a/tests/ui/panic_implementation-closures.rs b/tests/ui/panics/panic-handler-closures.rs similarity index 100% rename from tests/ui/panic_implementation-closures.rs rename to tests/ui/panics/panic-handler-closures.rs diff --git a/tests/ui/path-lookahead.fixed b/tests/ui/parser/ufcs-return-unused-parens.fixed similarity index 100% rename from tests/ui/path-lookahead.fixed rename to tests/ui/parser/ufcs-return-unused-parens.fixed diff --git a/tests/ui/path-lookahead.rs b/tests/ui/parser/ufcs-return-unused-parens.rs similarity index 100% rename from tests/ui/path-lookahead.rs rename to tests/ui/parser/ufcs-return-unused-parens.rs diff --git a/tests/ui/path-lookahead.stderr b/tests/ui/parser/ufcs-return-unused-parens.stderr similarity index 100% rename from tests/ui/path-lookahead.stderr rename to tests/ui/parser/ufcs-return-unused-parens.stderr diff --git a/tests/ui/partialeq_help.rs b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs similarity index 100% rename from tests/ui/partialeq_help.rs rename to tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs diff --git a/tests/ui/partialeq_help.stderr b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr similarity index 100% rename from tests/ui/partialeq_help.stderr rename to tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr From 7c2cc2ce40f962edeb7badc50172c5b6ff280f12 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 1 Jul 2025 02:46:47 +0500 Subject: [PATCH 2/2] cleaned up some tests --- .../ui/codegen/output-slot-init-vs-noninit.rs | 54 +++++++++++-------- tests/ui/codegen/remark-flag-functionality.rs | 14 ++--- .../codegen/shift-right-operand-mutation.rs | 21 +++++--- tests/ui/codegen/sret-aliasing-rules.rs | 13 +++-- .../ui/macros/macro-paren-span-diagnostic.rs | 6 ++- .../macros/macro-paren-span-diagnostic.stderr | 2 +- .../panics/panic-during-display-formatting.rs | 12 +++-- tests/ui/panics/panic-handler-closures.rs | 6 ++- .../ui/parser/ufcs-return-unused-parens.fixed | 9 ++-- tests/ui/parser/ufcs-return-unused-parens.rs | 9 ++-- .../parser/ufcs-return-unused-parens.stderr | 4 +- .../partialeq-ref-mismatch-diagnostic.rs | 4 +- .../partialeq-ref-mismatch-diagnostic.stderr | 8 +-- 13 files changed, 101 insertions(+), 61 deletions(-) diff --git a/tests/ui/codegen/output-slot-init-vs-noninit.rs b/tests/ui/codegen/output-slot-init-vs-noninit.rs index 97757e74fc4ea..55586843740a7 100644 --- a/tests/ui/codegen/output-slot-init-vs-noninit.rs +++ b/tests/ui/codegen/output-slot-init-vs-noninit.rs @@ -1,26 +1,48 @@ +//! Check that output slots work correctly for both initializing and non-initializing assignments. +//! +//! Regression test for . + //@ run-pass #![allow(dead_code)] #![allow(unused_assignments)] #![allow(unknown_lints)] - #![allow(dead_assignment)] #![allow(unused_variables)] -struct A { a: isize, b: isize } -struct Abox { a: Box, b: Box } +struct A { + a: isize, + b: isize, +} -fn ret_int_i() -> isize { 10 } +struct Abox { + a: Box, + b: Box, +} -fn ret_ext_i() -> Box { Box::new(10) } +fn ret_int_i() -> isize { + 10 +} -fn ret_int_rec() -> A { A {a: 10, b: 10} } +fn ret_ext_i() -> Box { + Box::new(10) +} -fn ret_ext_rec() -> Box { Box::new(A {a: 10, b: 10}) } +fn ret_int_rec() -> A { + A { a: 10, b: 10 } +} -fn ret_ext_mem() -> Abox { Abox {a: Box::new(10), b: Box::new(10) } } +fn ret_ext_rec() -> Box { + Box::new(A { a: 10, b: 10 }) +} + +fn ret_ext_mem() -> Abox { + Abox { a: Box::new(10), b: Box::new(10) } +} -fn ret_ext_ext_mem() -> Box { Box::new(Abox{a: Box::new(10), b: Box::new(10) }) } +fn ret_ext_ext_mem() -> Box { + Box::new(Abox { a: Box::new(10), b: Box::new(10) }) +} pub fn main() { let mut int_i: isize; @@ -29,40 +51,28 @@ pub fn main() { let mut ext_rec: Box; let mut ext_mem: Abox; let mut ext_ext_mem: Box; - int_i = ret_int_i(); // initializing + int_i = ret_int_i(); // initializing int_i = ret_int_i(); // non-initializing - int_i = ret_int_i(); // non-initializing ext_i = ret_ext_i(); // initializing - ext_i = ret_ext_i(); // non-initializing - ext_i = ret_ext_i(); // non-initializing int_rec = ret_int_rec(); // initializing - int_rec = ret_int_rec(); // non-initializing - int_rec = ret_int_rec(); // non-initializing ext_rec = ret_ext_rec(); // initializing - ext_rec = ret_ext_rec(); // non-initializing - ext_rec = ret_ext_rec(); // non-initializing ext_mem = ret_ext_mem(); // initializing - ext_mem = ret_ext_mem(); // non-initializing - ext_mem = ret_ext_mem(); // non-initializing ext_ext_mem = ret_ext_ext_mem(); // initializing - ext_ext_mem = ret_ext_ext_mem(); // non-initializing - ext_ext_mem = ret_ext_ext_mem(); // non-initializing - } diff --git a/tests/ui/codegen/remark-flag-functionality.rs b/tests/ui/codegen/remark-flag-functionality.rs index 165fc63c0076a..797c55ba830c1 100644 --- a/tests/ui/codegen/remark-flag-functionality.rs +++ b/tests/ui/codegen/remark-flag-functionality.rs @@ -1,24 +1,26 @@ +//! Check that `-Cremark` flag correctly emits LLVM optimization remarks. +//! +//! Regression test for . + //@ build-pass //@ ignore-pass //@ revisions: all inline merge1 merge2 //@ compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2 -// + // Check that remarks can be enabled individually or with "all": -// //@ [all] compile-flags: -Cremark=all //@ [inline] compile-flags: -Cremark=inline -// + // Check that values of -Cremark flag are accumulated: -// //@ [merge1] compile-flags: -Cremark=all -Cremark=giraffe //@ [merge2] compile-flags: -Cremark=inline -Cremark=giraffe + //@ dont-check-compiler-stderr //@ dont-require-annotations: NOTE #[no_mangle] #[inline(never)] -pub fn f() { -} +pub fn f() {} #[no_mangle] pub fn g() { diff --git a/tests/ui/codegen/shift-right-operand-mutation.rs b/tests/ui/codegen/shift-right-operand-mutation.rs index 016a667e93785..b37a0baa6f8e7 100644 --- a/tests/ui/codegen/shift-right-operand-mutation.rs +++ b/tests/ui/codegen/shift-right-operand-mutation.rs @@ -1,12 +1,19 @@ +//! Ensure shift operations don't mutate their right operand. +//! +//! This test checks that expressions like `0 << b` don't accidentally +//! modify the variable `b` due to codegen issues with virtual registers. +//! +//! Regression test for . + //@ run-pass -#![allow(unused_must_use)] -// Regression test for issue #152. pub fn main() { - let mut b: usize = 1_usize; - while b < std::mem::size_of::() { - 0_usize << b; - b <<= 1_usize; - println!("{}", b); + let mut b: usize = 1; + while b < size_of::() { + // This shift operation should not mutate `b` + let _ = 0_usize << b; + b <<= 1; + std::hint::black_box(b); } + assert_eq!(size_of::(), b); } diff --git a/tests/ui/codegen/sret-aliasing-rules.rs b/tests/ui/codegen/sret-aliasing-rules.rs index 0dfaa19fadb0f..f35e722f764a5 100644 --- a/tests/ui/codegen/sret-aliasing-rules.rs +++ b/tests/ui/codegen/sret-aliasing-rules.rs @@ -1,3 +1,11 @@ +//! Check that functions with sret results don't violate aliasing rules. +//! +//! When `foo = func(&mut foo)` is called, the compiler must avoid creating +//! two mutable references to the same variable simultaneously (one for the +//! parameter and one for the hidden sret out-pointer). +//! +//! Regression test for . + //@ run-pass #[derive(Copy, Clone)] @@ -14,10 +22,7 @@ pub fn foo(f: &mut Foo) -> Foo { } pub fn main() { - let mut f = Foo { - f1: 8, - _f2: 9, - }; + let mut f = Foo { f1: 8, _f2: 9 }; f = foo(&mut f); assert_eq!(f.f1, 8); } diff --git a/tests/ui/macros/macro-paren-span-diagnostic.rs b/tests/ui/macros/macro-paren-span-diagnostic.rs index c8cb63d5190d1..cbcb0231e4e30 100644 --- a/tests/ui/macros/macro-paren-span-diagnostic.rs +++ b/tests/ui/macros/macro-paren-span-diagnostic.rs @@ -1,5 +1,6 @@ -// Be smart about span of parenthesized expression in macro. +//! Check that error spans in parenthesized macro expressions point to the call site. +#[rustfmt::skip] macro_rules! paren { ($e:expr) => (($e)) // ^^^^ do not highlight here @@ -7,8 +8,9 @@ macro_rules! paren { mod m { pub struct S { - x: i32 + x: i32, } + pub fn make() -> S { S { x: 0 } } diff --git a/tests/ui/macros/macro-paren-span-diagnostic.stderr b/tests/ui/macros/macro-paren-span-diagnostic.stderr index da2f57033a44e..ede6ff51c7129 100644 --- a/tests/ui/macros/macro-paren-span-diagnostic.stderr +++ b/tests/ui/macros/macro-paren-span-diagnostic.stderr @@ -1,5 +1,5 @@ error[E0616]: field `x` of struct `S` is private - --> $DIR/paren-span.rs:19:14 + --> $DIR/macro-paren-span-diagnostic.rs:21:14 | LL | paren!(s.x); | ^ private field diff --git a/tests/ui/panics/panic-during-display-formatting.rs b/tests/ui/panics/panic-during-display-formatting.rs index 6505a69fef7cf..a307ee493854a 100644 --- a/tests/ui/panics/panic-during-display-formatting.rs +++ b/tests/ui/panics/panic-during-display-formatting.rs @@ -1,3 +1,5 @@ +//! Check that panics in `Display::fmt` during printing are properly handled. + //@ run-pass //@ needs-unwind @@ -18,8 +20,10 @@ impl Display for A { fn main() { set_output_capture(Some(Arc::new(Mutex::new(Vec::new())))); - assert!(std::panic::catch_unwind(|| { - eprintln!("{}", A); - }) - .is_err()); + assert!( + std::panic::catch_unwind(|| { + eprintln!("{}", A); + }) + .is_err() + ); } diff --git a/tests/ui/panics/panic-handler-closures.rs b/tests/ui/panics/panic-handler-closures.rs index b161859bf9c51..27fea92572050 100644 --- a/tests/ui/panics/panic-handler-closures.rs +++ b/tests/ui/panics/panic-handler-closures.rs @@ -1,10 +1,12 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//! Check that closures can be used inside `#[panic_handler]` functions. + +//@ check-pass #![crate_type = "rlib"] #![no_std] #[panic_handler] -pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { +pub fn panicfmt(_: &::core::panic::PanicInfo) -> ! { |x: u8| x; loop {} } diff --git a/tests/ui/parser/ufcs-return-unused-parens.fixed b/tests/ui/parser/ufcs-return-unused-parens.fixed index 440b22edd7d51..811a853b76933 100644 --- a/tests/ui/parser/ufcs-return-unused-parens.fixed +++ b/tests/ui/parser/ufcs-return-unused-parens.fixed @@ -1,13 +1,16 @@ +//! Check that UFCS syntax works correctly in return statements +//! without requiring workaround parentheses. +//! +//! Regression test for . + //@ run-pass //@ run-rustfix #![allow(dead_code)] #![warn(unused_parens)] -// Parser test for #37765 - fn with_parens(arg: T) -> String { - return ::to_string(&arg); //~WARN unnecessary parentheses around `return` value + return ::to_string(&arg); //~ WARN unnecessary parentheses around `return` value } fn no_parens(arg: T) -> String { diff --git a/tests/ui/parser/ufcs-return-unused-parens.rs b/tests/ui/parser/ufcs-return-unused-parens.rs index 7eaacd6bba78b..6ea69ef9a2627 100644 --- a/tests/ui/parser/ufcs-return-unused-parens.rs +++ b/tests/ui/parser/ufcs-return-unused-parens.rs @@ -1,13 +1,16 @@ +//! Check that UFCS syntax works correctly in return statements +//! without requiring workaround parentheses. +//! +//! Regression test for . + //@ run-pass //@ run-rustfix #![allow(dead_code)] #![warn(unused_parens)] -// Parser test for #37765 - fn with_parens(arg: T) -> String { - return (::to_string(&arg)); //~WARN unnecessary parentheses around `return` value + return (::to_string(&arg)); //~ WARN unnecessary parentheses around `return` value } fn no_parens(arg: T) -> String { diff --git a/tests/ui/parser/ufcs-return-unused-parens.stderr b/tests/ui/parser/ufcs-return-unused-parens.stderr index 2cc786fd947c2..6c09e98e7b105 100644 --- a/tests/ui/parser/ufcs-return-unused-parens.stderr +++ b/tests/ui/parser/ufcs-return-unused-parens.stderr @@ -1,11 +1,11 @@ warning: unnecessary parentheses around `return` value - --> $DIR/path-lookahead.rs:10:12 + --> $DIR/ufcs-return-unused-parens.rs:13:12 | LL | return (::to_string(&arg)); | ^ ^ | note: the lint level is defined here - --> $DIR/path-lookahead.rs:5:9 + --> $DIR/ufcs-return-unused-parens.rs:10:9 | LL | #![warn(unused_parens)] | ^^^^^^^^^^^^^ diff --git a/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs index 34b88b8a86685..26ef8050b8769 100644 --- a/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs +++ b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.rs @@ -1,8 +1,10 @@ +//! Check diagnostic messages for `PartialEq` trait bound mismatches between `&T` and `T`. + fn foo(a: &T, b: T) { a == b; //~ ERROR E0277 } -fn foo2(a: &T, b: T) where { +fn foo2(a: &T, b: T) { a == b; //~ ERROR E0277 } diff --git a/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr index f5de1308e8714..4cbd31656dc53 100644 --- a/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr +++ b/tests/ui/traits/partialeq-ref-mismatch-diagnostic.stderr @@ -1,5 +1,5 @@ error[E0277]: can't compare `&T` with `T` - --> $DIR/partialeq_help.rs:2:7 + --> $DIR/partialeq-ref-mismatch-diagnostic.rs:4:7 | LL | a == b; | ^^ no implementation for `&T == T` @@ -15,7 +15,7 @@ LL | fn foo(a: &T, b: T) where &T: PartialEq { | ++++++++++++++++++++++ error[E0277]: can't compare `&T` with `T` - --> $DIR/partialeq_help.rs:6:7 + --> $DIR/partialeq-ref-mismatch-diagnostic.rs:8:7 | LL | a == b; | ^^ no implementation for `&T == T` @@ -25,10 +25,10 @@ help: consider dereferencing here | LL | *a == b; | + -help: consider extending the `where` clause, but there might be an alternative better way to express this requirement +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | LL | fn foo2(a: &T, b: T) where &T: PartialEq { - | ++++++++++++++++ + | ++++++++++++++++++++++ error: aborting due to 2 previous errors