about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-06 12:19:16 +0000
committerbors <bors@rust-lang.org>2025-06-06 12:19:16 +0000
commitf315e6145802e091ff9fceab6db627a4b4ec2b86 (patch)
treed69d62320a58ea2060ef381bc09d41e3146c360e /tests
parentd00435f223dc3a88d8c5f472b10ba948b7959cc6 (diff)
parente12572f583f6b47e66537f2a9c0aa58db898384c (diff)
downloadrust-f315e6145802e091ff9fceab6db627a4b4ec2b86.tar.gz
rust-f315e6145802e091ff9fceab6db627a4b4ec2b86.zip
Auto merge of #142099 - matthiaskrgr:rollup-r9s3c35, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#125087 (Optimize `Seek::stream_len` impl for `File`)
 - rust-lang/rust#141982 (`tests/ui`: A New Order [5/N])
 - rust-lang/rust#142012 (Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None)
 - rust-lang/rust#142044 (compiler: Document the offset invariant of `OperandValue::Pair`)
 - rust-lang/rust#142047 (Ensure stack in two places that affect s390x)
 - rust-lang/rust#142058 (Clean `rustc_attr_parsing/src/lib.rs` documentation)
 - rust-lang/rust#142067 (canon_abi: make to_erased_extern_abi just a detail in formatting)
 - rust-lang/rust#142072 (doc: Fix inverted meaning in E0783.md)
 - rust-lang/rust#142084 (add myself to rotation)
 - rust-lang/rust#142091 (Fix AIX build)
 - rust-lang/rust#142092 (rustdoc: Support middle::ty associated const equality predicates again)

Failed merges:

 - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc/inline_cross/assoc-const-equality.rs1
-rw-r--r--tests/ui/borrowck/rvalue-borrow-scope-error.rs (renamed from tests/ui/cleanup-rvalue-scopes-cf.rs)14
-rw-r--r--tests/ui/borrowck/rvalue-borrow-scope-error.stderr (renamed from tests/ui/cleanup-rvalue-scopes-cf.stderr)14
-rw-r--r--tests/ui/cleanup-rvalue-scopes.rs128
-rw-r--r--tests/ui/close-over-big-then-small-data.rs39
-rw-r--r--tests/ui/diagnostic-width/command-line-error-format-human.rs (renamed from tests/ui/command-line-diagnostics.rs)3
-rw-r--r--tests/ui/diagnostic-width/command-line-error-format-human.stderr (renamed from tests/ui/command-line-diagnostics.stderr)2
-rw-r--r--tests/ui/lang-items/lang-item-generic-requirements.rs3
-rw-r--r--tests/ui/lang-items/lang-item-generic-requirements.stderr8
-rw-r--r--tests/ui/lifetimes/rvalue-cleanup-shortcircuit.rs (renamed from tests/ui/cleanup-shortcircuit.rs)9
-rw-r--r--tests/ui/lifetimes/rvalue-lifetime-drop-timing.rs104
-rw-r--r--tests/ui/panics/rvalue-cleanup-during-box-panic.rs (renamed from tests/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs)10
12 files changed, 142 insertions, 193 deletions
diff --git a/tests/rustdoc/inline_cross/assoc-const-equality.rs b/tests/rustdoc/inline_cross/assoc-const-equality.rs
index ec5c2f748ef..36ab027ef71 100644
--- a/tests/rustdoc/inline_cross/assoc-const-equality.rs
+++ b/tests/rustdoc/inline_cross/assoc-const-equality.rs
@@ -1,6 +1,5 @@
 //@ aux-crate:assoc_const_equality=assoc-const-equality.rs
 //@ edition:2021
-//@ ignore-test (FIXME: #125092)
 
 #![crate_name = "user"]
 
diff --git a/tests/ui/cleanup-rvalue-scopes-cf.rs b/tests/ui/borrowck/rvalue-borrow-scope-error.rs
index e3cecb1bffe..5bf96e800d3 100644
--- a/tests/ui/cleanup-rvalue-scopes-cf.rs
+++ b/tests/ui/borrowck/rvalue-borrow-scope-error.rs
@@ -1,15 +1,19 @@
-// Test that the borrow checker prevents pointers to temporaries
-// with statement lifetimes from escaping.
+//! Test that the borrow checker prevents pointers to temporaries
+//! with statement lifetimes from escaping.
 
 use std::ops::Drop;
 
 static mut FLAGS: u64 = 0;
 
-struct StackBox<T> { f: T }
-struct AddFlags { bits: u64 }
+struct StackBox<T> {
+    f: T,
+}
+struct AddFlags {
+    bits: u64,
+}
 
 fn AddFlags(bits: u64) -> AddFlags {
-    AddFlags { bits: bits }
+    AddFlags { bits }
 }
 
 fn arg(x: &AddFlags) -> &AddFlags {
diff --git a/tests/ui/cleanup-rvalue-scopes-cf.stderr b/tests/ui/borrowck/rvalue-borrow-scope-error.stderr
index 425cd75141c..bedcfce4541 100644
--- a/tests/ui/cleanup-rvalue-scopes-cf.stderr
+++ b/tests/ui/borrowck/rvalue-borrow-scope-error.stderr
@@ -1,5 +1,5 @@
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/cleanup-rvalue-scopes-cf.rs:26:19
+  --> $DIR/rvalue-borrow-scope-error.rs:30:19
    |
 LL |     let x1 = arg(&AddFlags(1));
    |                   ^^^^^^^^^^^ - temporary value is freed at the end of this statement
@@ -16,7 +16,7 @@ LL ~     let x1 = arg(&binding);
    |
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/cleanup-rvalue-scopes-cf.rs:27:14
+  --> $DIR/rvalue-borrow-scope-error.rs:31:14
    |
 LL |     let x2 = AddFlags(1).get();
    |              ^^^^^^^^^^^      - temporary value is freed at the end of this statement
@@ -33,7 +33,7 @@ LL ~     let x2 = binding.get();
    |
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/cleanup-rvalue-scopes-cf.rs:28:21
+  --> $DIR/rvalue-borrow-scope-error.rs:32:21
    |
 LL |     let x3 = &*arg(&AddFlags(1));
    |                     ^^^^^^^^^^^ - temporary value is freed at the end of this statement
@@ -50,7 +50,7 @@ LL ~     let x3 = &*arg(&binding);
    |
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/cleanup-rvalue-scopes-cf.rs:29:24
+  --> $DIR/rvalue-borrow-scope-error.rs:33:24
    |
 LL |     let ref x4 = *arg(&AddFlags(1));
    |                        ^^^^^^^^^^^ - temporary value is freed at the end of this statement
@@ -67,7 +67,7 @@ LL ~     let ref x4 = *arg(&binding);
    |
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/cleanup-rvalue-scopes-cf.rs:30:24
+  --> $DIR/rvalue-borrow-scope-error.rs:34:24
    |
 LL |     let &ref x5 = arg(&AddFlags(1));
    |                        ^^^^^^^^^^^ - temporary value is freed at the end of this statement
@@ -84,7 +84,7 @@ LL ~     let &ref x5 = arg(&binding);
    |
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/cleanup-rvalue-scopes-cf.rs:31:14
+  --> $DIR/rvalue-borrow-scope-error.rs:35:14
    |
 LL |     let x6 = AddFlags(1).get();
    |              ^^^^^^^^^^^      - temporary value is freed at the end of this statement
@@ -101,7 +101,7 @@ LL ~     let x6 = binding.get();
    |
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/cleanup-rvalue-scopes-cf.rs:32:44
+  --> $DIR/rvalue-borrow-scope-error.rs:36:44
    |
 LL |     let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() };
    |                                            ^^^^^^^^^^^        - temporary value is freed at the end of this statement
diff --git a/tests/ui/cleanup-rvalue-scopes.rs b/tests/ui/cleanup-rvalue-scopes.rs
deleted file mode 100644
index 09ceda065b9..00000000000
--- a/tests/ui/cleanup-rvalue-scopes.rs
+++ /dev/null
@@ -1,128 +0,0 @@
-//@ run-pass
-#![allow(unused_braces)]
-#![allow(non_snake_case)]
-#![allow(unused_variables)]
-// Test that destructors for rvalue temporaries run either at end of
-// statement or end of block, as appropriate given the temporary
-// lifetime rules.
-
-#![feature(box_patterns)]
-
-static mut FLAGS: u64 = 0;
-
-struct Box<T> { f: T }
-struct AddFlags { bits: u64 }
-
-fn AddFlags(bits: u64) -> AddFlags {
-    AddFlags { bits: bits }
-}
-
-fn arg(exp: u64, _x: &AddFlags) {
-    check_flags(exp);
-}
-
-fn pass<T>(v: T) -> T {
-    v
-}
-
-fn check_flags(exp: u64) {
-    unsafe {
-        let x = FLAGS;
-        FLAGS = 0;
-        println!("flags {}, expected {}", x, exp);
-        assert_eq!(x, exp);
-    }
-}
-
-impl AddFlags {
-    fn check_flags<'a>(&'a self, exp: u64) -> &'a AddFlags {
-        check_flags(exp);
-        self
-    }
-
-    fn bits(&self) -> u64 {
-        self.bits
-    }
-}
-
-impl Drop for AddFlags {
-    fn drop(&mut self) {
-        unsafe {
-            FLAGS = FLAGS + self.bits;
-        }
-    }
-}
-
-macro_rules! end_of_block {
-    ($pat:pat, $expr:expr) => (
-        {
-            println!("end_of_block({})", stringify!({let $pat = $expr;}));
-
-            {
-                // Destructor here does not run until exit from the block.
-                let $pat = $expr;
-                check_flags(0);
-            }
-            check_flags(1);
-        }
-    )
-}
-
-macro_rules! end_of_stmt {
-    ($pat:pat, $expr:expr) => (
-        {
-            println!("end_of_stmt({})", stringify!($expr));
-
-            {
-                // Destructor here run after `let` statement
-                // terminates.
-                let $pat = $expr;
-                check_flags(1);
-            }
-
-            check_flags(0);
-        }
-    )
-}
-
-pub fn main() {
-
-    // In all these cases, we trip over the rules designed to cover
-    // the case where we are taking addr of rvalue and storing that
-    // addr into a stack slot, either via `let ref` or via a `&` in
-    // the initializer.
-
-    end_of_block!(_x, AddFlags(1));
-    end_of_block!(_x, &AddFlags(1));
-    end_of_block!(_x, & &AddFlags(1));
-    end_of_block!(_x, Box { f: AddFlags(1) });
-    end_of_block!(_x, Box { f: &AddFlags(1) });
-    end_of_block!(_x, Box { f: &AddFlags(1) });
-    end_of_block!(_x, pass(AddFlags(1)));
-    end_of_block!(ref _x, AddFlags(1));
-    end_of_block!(AddFlags { bits: ref _x }, AddFlags(1));
-    end_of_block!(&AddFlags { bits }, &AddFlags(1));
-    end_of_block!((_, ref _y), (AddFlags(1), 22));
-    end_of_block!(box ref _x, std::boxed::Box::new(AddFlags(1)));
-    end_of_block!(box _x, std::boxed::Box::new(AddFlags(1)));
-    end_of_block!(_, { { check_flags(0); &AddFlags(1) } });
-    end_of_block!(_, &((Box { f: AddFlags(1) }).f));
-    end_of_block!(_, &(([AddFlags(1)])[0]));
-
-    // LHS does not create a ref binding, so temporary lives as long
-    // as statement, and we do not move the AddFlags out:
-    end_of_stmt!(_, AddFlags(1));
-    end_of_stmt!((_, _), (AddFlags(1), 22));
-
-    // `&` operator appears inside an arg to a function,
-    // so it is not prolonged:
-    end_of_stmt!(ref _x, arg(0, &AddFlags(1)));
-
-    // autoref occurs inside receiver, so temp lifetime is not
-    // prolonged:
-    end_of_stmt!(ref _x, AddFlags(1).check_flags(0).bits());
-
-    // No reference is created on LHS, thus RHS is moved into
-    // a temporary that lives just as long as the statement.
-    end_of_stmt!(AddFlags { bits }, AddFlags(1));
-}
diff --git a/tests/ui/close-over-big-then-small-data.rs b/tests/ui/close-over-big-then-small-data.rs
deleted file mode 100644
index d3cb1db8886..00000000000
--- a/tests/ui/close-over-big-then-small-data.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-//@ run-pass
-
-#![allow(dead_code)]
-// If we use GEPi rather than GEP_tup_like when
-// storing closure data (as we used to do), the u64 would
-// overwrite the u16.
-
-struct Pair<A,B> {
-    a: A, b: B
-}
-
-struct Invoker<A> {
-    a: A,
-    b: u16,
-}
-
-trait Invokable<A> {
-    fn f(&self) -> (A, u16);
-}
-
-impl<A:Clone> Invokable<A> for Invoker<A> {
-    fn f(&self) -> (A, u16) {
-        (self.a.clone(), self.b)
-    }
-}
-
-fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
-    Box::new(Invoker {
-        a: a,
-        b: b,
-    }) as Box<dyn Invokable<A>+'static>
-}
-
-pub fn main() {
-    let (a, b) = f(22_u64, 44u16).f();
-    println!("a={} b={}", a, b);
-    assert_eq!(a, 22u64);
-    assert_eq!(b, 44u16);
-}
diff --git a/tests/ui/command-line-diagnostics.rs b/tests/ui/diagnostic-width/command-line-error-format-human.rs
index 8a6cf5b8e32..a2cfbbcbeb1 100644
--- a/tests/ui/command-line-diagnostics.rs
+++ b/tests/ui/diagnostic-width/command-line-error-format-human.rs
@@ -1,4 +1,5 @@
-// This test checks the output format without the intermediate json representation
+//! This test checks the output format without the intermediate json representation
+
 //@ compile-flags: --error-format=human
 
 pub fn main() {
diff --git a/tests/ui/command-line-diagnostics.stderr b/tests/ui/diagnostic-width/command-line-error-format-human.stderr
index 6d33fb4172f..b4b78239f88 100644
--- a/tests/ui/command-line-diagnostics.stderr
+++ b/tests/ui/diagnostic-width/command-line-error-format-human.stderr
@@ -1,5 +1,5 @@
 error[E0384]: cannot assign twice to immutable variable `x`
-  --> $DIR/command-line-diagnostics.rs:6:5
+  --> $DIR/command-line-error-format-human.rs:7:5
    |
 LL |     let x = 42;
    |         - first assignment to `x`
diff --git a/tests/ui/lang-items/lang-item-generic-requirements.rs b/tests/ui/lang-items/lang-item-generic-requirements.rs
index 7676b5557d2..25a4ff283ba 100644
--- a/tests/ui/lang-items/lang-item-generic-requirements.rs
+++ b/tests/ui/lang-items/lang-item-generic-requirements.rs
@@ -48,6 +48,7 @@ fn ice() {
 
     // Use index
     let arr = [0; 5];
+    //~^ ERROR requires `copy` lang_item
     let _ = arr[2];
     //~^ ERROR cannot index into a value of type `[{integer}; 5]`
 
@@ -61,5 +62,3 @@ fn ice() {
 
 // use `start`
 fn main() {}
-
-//~? ERROR requires `copy` lang_item
diff --git a/tests/ui/lang-items/lang-item-generic-requirements.stderr b/tests/ui/lang-items/lang-item-generic-requirements.stderr
index 409fa05d637..c82bdb00fd1 100644
--- a/tests/ui/lang-items/lang-item-generic-requirements.stderr
+++ b/tests/ui/lang-items/lang-item-generic-requirements.stderr
@@ -77,13 +77,13 @@ LL |     r + a;
    |     {integer}
 
 error[E0608]: cannot index into a value of type `[{integer}; 5]`
-  --> $DIR/lang-item-generic-requirements.rs:51:16
+  --> $DIR/lang-item-generic-requirements.rs:52:16
    |
 LL |     let _ = arr[2];
    |                ^^^
 
 error[E0308]: mismatched types
-  --> $DIR/lang-item-generic-requirements.rs:58:17
+  --> $DIR/lang-item-generic-requirements.rs:59:17
    |
 LL |     let _: () = Foo;
    |            --   ^^^ expected `()`, found `Foo`
@@ -91,6 +91,10 @@ LL |     let _: () = Foo;
    |            expected due to this
 
 error: requires `copy` lang_item
+  --> $DIR/lang-item-generic-requirements.rs:50:16
+   |
+LL |     let arr = [0; 5];
+   |                ^
 
 error: aborting due to 12 previous errors
 
diff --git a/tests/ui/cleanup-shortcircuit.rs b/tests/ui/lifetimes/rvalue-cleanup-shortcircuit.rs
index 40a5dfa94e3..dba899585c4 100644
--- a/tests/ui/cleanup-shortcircuit.rs
+++ b/tests/ui/lifetimes/rvalue-cleanup-shortcircuit.rs
@@ -1,10 +1,9 @@
-//@ run-pass
-// Test that cleanups for the RHS of shortcircuiting operators work.
+//! Test that cleanups for the RHS of shortcircuiting operators work.
 
+//@ run-pass
 
 #![allow(deref_nullptr)]
 
-
 use std::env;
 
 pub fn main() {
@@ -18,6 +17,8 @@ pub fn main() {
 
     if args.len() >= 2 && args[1] == "signal" {
         // Raise a segfault.
-        unsafe { *std::ptr::null_mut::<isize>() = 0; }
+        unsafe {
+            *std::ptr::null_mut::<isize>() = 0;
+        }
     }
 }
diff --git a/tests/ui/lifetimes/rvalue-lifetime-drop-timing.rs b/tests/ui/lifetimes/rvalue-lifetime-drop-timing.rs
new file mode 100644
index 00000000000..9e7b84bfccf
--- /dev/null
+++ b/tests/ui/lifetimes/rvalue-lifetime-drop-timing.rs
@@ -0,0 +1,104 @@
+//! Test that destructors for temporaries run either at end of
+//! statement or end of block as appropriate.
+
+//@ run-pass
+
+#![feature(box_patterns)]
+
+static mut FLAGS: u64 = 0;
+
+struct Box<T> {
+    f: T,
+}
+
+struct AddFlags {
+    bits: u64,
+}
+
+fn add_flags(bits: u64) -> AddFlags {
+    AddFlags { bits }
+}
+
+fn arg(expected: u64, _x: &AddFlags) {
+    check_flags(expected);
+}
+
+fn pass<T>(v: T) -> T {
+    v
+}
+
+fn check_flags(expected: u64) {
+    unsafe {
+        let actual = FLAGS;
+        FLAGS = 0;
+        assert_eq!(actual, expected, "flags {}, expected {}", actual, expected);
+    }
+}
+
+impl AddFlags {
+    fn check_flags(&self, expected: u64) -> &AddFlags {
+        check_flags(expected);
+        self
+    }
+
+    fn bits(&self) -> u64 {
+        self.bits
+    }
+}
+
+impl Drop for AddFlags {
+    fn drop(&mut self) {
+        unsafe {
+            FLAGS += self.bits;
+        }
+    }
+}
+
+macro_rules! end_of_block {
+    ($pat:pat, $expr:expr) => {{
+        {
+            let $pat = $expr;
+            check_flags(0);
+        }
+        check_flags(1);
+    }};
+}
+
+macro_rules! end_of_stmt {
+    ($pat:pat, $expr:expr) => {{
+        {
+            let $pat = $expr;
+            check_flags(1);
+        }
+        check_flags(0);
+    }};
+}
+
+fn main() {
+    end_of_block!(_x, add_flags(1));
+    end_of_block!(_x, &add_flags(1));
+    end_of_block!(_x, &&add_flags(1));
+    end_of_block!(_x, Box { f: add_flags(1) });
+    end_of_block!(_x, Box { f: &add_flags(1) });
+    end_of_block!(_x, pass(add_flags(1)));
+    end_of_block!(ref _x, add_flags(1));
+    end_of_block!(AddFlags { bits: ref _x }, add_flags(1));
+    end_of_block!(&AddFlags { bits: _ }, &add_flags(1));
+    end_of_block!((_, ref _y), (add_flags(1), 22));
+    end_of_block!(box ref _x, std::boxed::Box::new(add_flags(1)));
+    end_of_block!(box _x, std::boxed::Box::new(add_flags(1)));
+    end_of_block!(_, {
+        {
+            check_flags(0);
+            &add_flags(1)
+        }
+    });
+    end_of_block!(_, &((Box { f: add_flags(1) }).f));
+    end_of_block!(_, &(([add_flags(1)])[0]));
+
+    end_of_stmt!(_, add_flags(1));
+    end_of_stmt!((_, _), (add_flags(1), 22));
+    end_of_stmt!(ref _x, arg(0, &add_flags(1)));
+    end_of_stmt!(ref _x, add_flags(1).check_flags(0).bits());
+    end_of_stmt!(AddFlags { bits: _ }, add_flags(1));
+}
diff --git a/tests/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs b/tests/ui/panics/rvalue-cleanup-during-box-panic.rs
index 4c59df24e4b..84c5d85d7e0 100644
--- a/tests/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs
+++ b/tests/ui/panics/rvalue-cleanup-during-box-panic.rs
@@ -25,16 +25,20 @@
 use std::thread;
 
 enum Conzabble {
-    Bickwick(Foo)
+    Bickwick(Foo),
 }
 
-struct Foo { field: Box<usize> }
+struct Foo {
+    field: Box<usize>,
+}
 
 fn do_it(x: &[usize]) -> Foo {
     panic!()
 }
 
-fn get_bar(x: usize) -> Vec<usize> { vec![x * 2] }
+fn get_bar(x: usize) -> Vec<usize> {
+    vec![x * 2]
+}
 
 pub fn fails() {
     let x = 2;