about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorJieyou Xu <jieyouxu@outlook.com>2025-09-11 09:00:01 +0800
committerJieyou Xu <jieyouxu@outlook.com>2025-09-11 09:10:46 +0800
commitb38a86f4d7c28ae9ab153b87c7e45037e56306fb (patch)
tree4a732b90729f242a458b49d98ec79d96dc186a58 /tests
parentfc58d8f5cce592998d0ba43b25e445eb6b96c827 (diff)
downloadrust-b38a86f4d7c28ae9ab153b87c7e45037e56306fb.tar.gz
rust-b38a86f4d7c28ae9ab153b87c7e45037e56306fb.zip
Revert "Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov"
This reverts commit 1eeb8e8b151d1da7daa73837a25dc5f7a1a7fa28, reversing
changes made to 324bf2b9fd8bf9661e7045c8a93f5ff0ec1a8ca5.

Unfortunately the assert desugaring change is not backwards compatible,
see RUST-145770.

Code such as

```rust
#[derive(Debug)]
struct F {
    data: bool
}

impl std::ops::Not for F {
  type Output = bool;
  fn not(self) -> Self::Output { !self.data }
}

fn main() {
  let f = F { data: true };

  assert!(f);
}
```

would be broken by the assert desugaring change. We may need to land
the change over an edition boundary, or limit the editions that the
desugaring change impacts.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/codemap_tests/issue-28308.rs16
-rw-r--r--tests/ui/codemap_tests/issue-28308.stderr28
-rw-r--r--tests/ui/consts/control-flow/assert.stderr4
-rw-r--r--tests/ui/generics/post_monomorphization_error_backtrace.stderr8
-rw-r--r--tests/ui/inline-const/const-expr-generic-err.stderr4
-rw-r--r--tests/ui/macros/assert-desugaring-145770.rs3
-rw-r--r--tests/ui/macros/assert-desugaring-145770.stderr14
-rw-r--r--tests/ui/macros/assert-macro-lifetimes.rs8
-rw-r--r--tests/ui/mir/alignment/packed.rs2
-rw-r--r--tests/ui/simd/const-err-trumps-simd-err.stderr4
-rw-r--r--tests/ui/transmutability/uninhabited.stderr12
11 files changed, 26 insertions, 77 deletions
diff --git a/tests/ui/codemap_tests/issue-28308.rs b/tests/ui/codemap_tests/issue-28308.rs
index b0e04d0f1f6..81493f8c453 100644
--- a/tests/ui/codemap_tests/issue-28308.rs
+++ b/tests/ui/codemap_tests/issue-28308.rs
@@ -1,16 +1,4 @@
 fn main() {
-    assert!("foo"); //~ ERROR mismatched types
-    //~^ NOTE expected `bool`, found `str`
-    //~| NOTE in this expansion of assert!
-    let x = Some(&1);
-    assert!(x); //~ ERROR mismatched types
-    //~^ NOTE expected `bool`, found `Option<&{integer}>`
-    //~| NOTE expected enum `bool`
-    //~| NOTE in this expansion of assert!
-    //~| NOTE in this expansion of assert!
-    assert!(x, ""); //~ ERROR mismatched types
-    //~^ NOTE expected `bool`, found `Option<&{integer}>`
-    //~| NOTE expected enum `bool`
-    //~| NOTE in this expansion of assert!
-    //~| NOTE in this expansion of assert!
+    assert!("foo");
+    //~^ ERROR cannot apply unary operator `!`
 }
diff --git a/tests/ui/codemap_tests/issue-28308.stderr b/tests/ui/codemap_tests/issue-28308.stderr
index e84ceb44aac..7bc9e05dfc0 100644
--- a/tests/ui/codemap_tests/issue-28308.stderr
+++ b/tests/ui/codemap_tests/issue-28308.stderr
@@ -1,27 +1,9 @@
-error[E0308]: mismatched types
-  --> $DIR/issue-28308.rs:2:13
+error[E0600]: cannot apply unary operator `!` to type `&'static str`
+  --> $DIR/issue-28308.rs:2:5
    |
 LL |     assert!("foo");
-   |             ^^^^^ expected `bool`, found `str`
+   |     ^^^^^^^^^^^^^^ cannot apply unary operator `!`
 
-error[E0308]: mismatched types
-  --> $DIR/issue-28308.rs:6:13
-   |
-LL |     assert!(x);
-   |             ^ expected `bool`, found `Option<&{integer}>`
-   |
-   = note: expected enum `bool`
-              found type `Option<&{integer}>`
-
-error[E0308]: mismatched types
-  --> $DIR/issue-28308.rs:11:13
-   |
-LL |     assert!(x, "");
-   |             ^ expected `bool`, found `Option<&{integer}>`
-   |
-   = note: expected enum `bool`
-              found type `Option<&{integer}>`
-
-error: aborting due to 3 previous errors
+error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0600`.
diff --git a/tests/ui/consts/control-flow/assert.stderr b/tests/ui/consts/control-flow/assert.stderr
index deaad6abbcc..026097a6ba0 100644
--- a/tests/ui/consts/control-flow/assert.stderr
+++ b/tests/ui/consts/control-flow/assert.stderr
@@ -1,8 +1,8 @@
 error[E0080]: evaluation panicked: assertion failed: false
-  --> $DIR/assert.rs:5:23
+  --> $DIR/assert.rs:5:15
    |
 LL | const _: () = assert!(false);
-   |                       ^^^^^ evaluation of `_` failed here
+   |               ^^^^^^^^^^^^^^ evaluation of `_` failed here
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr
index 92c7df73638..6953414f0c2 100644
--- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr
+++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr
@@ -1,8 +1,8 @@
 error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0
-  --> $DIR/post_monomorphization_error_backtrace.rs:6:31
+  --> $DIR/post_monomorphization_error_backtrace.rs:6:23
    |
 LL |         const V: () = assert!(std::mem::size_of::<T>() == 0);
-   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<u32>::V` failed here
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<u32>::V` failed here
 
 note: erroneous constant encountered
   --> $DIR/post_monomorphization_error_backtrace.rs:14:5
@@ -17,10 +17,10 @@ LL |     assert_zst::<U>()
    |     ^^^^^^^^^^^^^^^^^
 
 error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0
-  --> $DIR/post_monomorphization_error_backtrace.rs:6:31
+  --> $DIR/post_monomorphization_error_backtrace.rs:6:23
    |
 LL |         const V: () = assert!(std::mem::size_of::<T>() == 0);
-   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<i32>::V` failed here
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<i32>::V` failed here
 
 note: erroneous constant encountered
   --> $DIR/post_monomorphization_error_backtrace.rs:14:5
diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr
index e053e88db17..26039ba6d44 100644
--- a/tests/ui/inline-const/const-expr-generic-err.stderr
+++ b/tests/ui/inline-const/const-expr-generic-err.stderr
@@ -1,8 +1,8 @@
 error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0
-  --> $DIR/const-expr-generic-err.rs:4:21
+  --> $DIR/const-expr-generic-err.rs:4:13
    |
 LL |     const { assert!(std::mem::size_of::<T>() == 0); }
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::<i32>::{constant#0}` failed here
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::<i32>::{constant#0}` failed here
 
 note: erroneous constant encountered
   --> $DIR/const-expr-generic-err.rs:4:5
diff --git a/tests/ui/macros/assert-desugaring-145770.rs b/tests/ui/macros/assert-desugaring-145770.rs
index 9eb850f0380..d56e771ecfb 100644
--- a/tests/ui/macros/assert-desugaring-145770.rs
+++ b/tests/ui/macros/assert-desugaring-145770.rs
@@ -4,6 +4,8 @@
 //! backwards-incompatible, and may need to be done over an edition boundary or limit editions for
 //! which the desguaring change impacts.
 
+//@ check-pass
+
 #[derive(Debug)]
 struct F {
     data: bool
@@ -18,5 +20,4 @@ fn main() {
   let f = F { data: true };
 
   assert!(f);
-  //~^ ERROR mismatched types
 }
diff --git a/tests/ui/macros/assert-desugaring-145770.stderr b/tests/ui/macros/assert-desugaring-145770.stderr
deleted file mode 100644
index 875ea8f7c32..00000000000
--- a/tests/ui/macros/assert-desugaring-145770.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/assert-desugaring-145770.rs:20:11
-   |
-LL |   assert!(f);
-   |           ^ expected `bool`, found `F`
-   |
-help: you might have meant to use field `data` whose type is `bool`
-   |
-LL |   assert!(f.data);
-   |            +++++
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/macros/assert-macro-lifetimes.rs b/tests/ui/macros/assert-macro-lifetimes.rs
deleted file mode 100644
index cc259283204..00000000000
--- a/tests/ui/macros/assert-macro-lifetimes.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-//@ check-pass
-#[derive(PartialEq, Eq, Hash)]
-struct S;
-fn main() {
-    let foo = std::rc::Rc::new(std::cell::RefCell::new(std::collections::HashMap::<S, S>::new()));
-    // Ensure that the lifetimes of the borrow do not leak past the end of `main`.
-    assert!(matches!(foo.borrow().get(&S).unwrap(), S))
-}
diff --git a/tests/ui/mir/alignment/packed.rs b/tests/ui/mir/alignment/packed.rs
index aa79880a21a..cf908365e1a 100644
--- a/tests/ui/mir/alignment/packed.rs
+++ b/tests/ui/mir/alignment/packed.rs
@@ -12,7 +12,7 @@ fn main() {
     // Test that we can use addr_of! to get the address of a packed member which according to its
     // type is not aligned, but because it is a projection from a packed type is a valid place.
     let ptr0 = std::ptr::addr_of!(memory[0].tail);
-    let ptr1 = std::ptr::addr_of!(memory[1].tail);
+    let ptr1 = std::ptr::addr_of!(memory[0].tail);
     // Even if ptr0 happens to be aligned by chance, ptr1 is not.
     assert!(!ptr0.is_aligned() || !ptr1.is_aligned());
 
diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr
index 6d25a28c92c..93d1fce637f 100644
--- a/tests/ui/simd/const-err-trumps-simd-err.stderr
+++ b/tests/ui/simd/const-err-trumps-simd-err.stderr
@@ -1,8 +1,8 @@
 error[E0080]: evaluation panicked: assertion failed: LANE < 4
-  --> $DIR/const-err-trumps-simd-err.rs:17:21
+  --> $DIR/const-err-trumps-simd-err.rs:17:13
    |
 LL |     const { assert!(LANE < 4); } // the error should be here...
-   |                     ^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here
+   |             ^^^^^^^^^^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here
 
 note: erroneous constant encountered
   --> $DIR/const-err-trumps-simd-err.rs:17:5
diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr
index 9f289852809..4757daec997 100644
--- a/tests/ui/transmutability/uninhabited.stderr
+++ b/tests/ui/transmutability/uninhabited.stderr
@@ -41,10 +41,10 @@ LL | |         }>
    | |__________^ required by this bound in `is_maybe_transmutable`
 
 error[E0080]: evaluation panicked: assertion failed: false
-  --> $DIR/uninhabited.rs:41:17
+  --> $DIR/uninhabited.rs:41:9
    |
 LL |         assert!(false);
-   |                 ^^^^^ evaluation of `yawning_void_struct::_` failed here
+   |         ^^^^^^^^^^^^^^ evaluation of `yawning_void_struct::_` failed here
 
 error[E0277]: `()` cannot be safely transmuted into `yawning_void_enum::Void`
   --> $DIR/uninhabited.rs:71:41
@@ -68,10 +68,10 @@ LL | |         }>
    | |__________^ required by this bound in `is_maybe_transmutable`
 
 error[E0080]: evaluation panicked: assertion failed: false
-  --> $DIR/uninhabited.rs:63:17
+  --> $DIR/uninhabited.rs:63:9
    |
 LL |         assert!(false);
-   |                 ^^^^^ evaluation of `yawning_void_enum::_` failed here
+   |         ^^^^^^^^^^^^^^ evaluation of `yawning_void_enum::_` failed here
 
 error[E0277]: `u128` cannot be safely transmuted into `DistantVoid`
   --> $DIR/uninhabited.rs:92:43
@@ -95,10 +95,10 @@ LL | |         }>
    | |__________^ required by this bound in `is_maybe_transmutable`
 
 error[E0080]: evaluation panicked: assertion failed: false
-  --> $DIR/uninhabited.rs:87:17
+  --> $DIR/uninhabited.rs:87:9
    |
 LL |         assert!(false);
-   |                 ^^^^^ evaluation of `distant_void::_` failed here
+   |         ^^^^^^^^^^^^^^ evaluation of `distant_void::_` failed here
 
 error[E0277]: `Src` cannot be safely transmuted into `issue_126267::Error`
   --> $DIR/uninhabited.rs:108:42