about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/consts/const-eval/ub-slice-get-unchecked.rs3
-rw-r--r--tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr12
-rw-r--r--tests/ui/consts/issue-94675.rs4
-rw-r--r--tests/ui/consts/issue-94675.stderr27
-rw-r--r--tests/ui/parser/issues/issue-35813-postfix-after-cast.rs3
-rw-r--r--tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr38
6 files changed, 45 insertions, 42 deletions
diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
index e805ac01c9d..ad2b49e6049 100644
--- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
+++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
@@ -1,9 +1,10 @@
-//@ known-bug: #110395
+#![feature(const_index, const_trait_impl)]
 
 const A: [(); 5] = [(), (), (), (), ()];
 
 // Since the indexing is on a ZST, the addresses are all fine,
 // but we should still catch the bad range.
 const B: &[()] = unsafe { A.get_unchecked(3..1) };
+//~^ ERROR: slice::get_unchecked requires that the range is within the slice
 
 fn main() {}
diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr
index 6e428079afe..88ea310f19c 100644
--- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr
+++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr
@@ -1,11 +1,11 @@
-error[E0015]: cannot call non-const method `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` in constants
-  --> $DIR/ub-slice-get-unchecked.rs:7:29
+error[E0080]: evaluation panicked: unsafe precondition(s) violated: slice::get_unchecked requires that the range is within the slice
+              
+              This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
+  --> $DIR/ub-slice-get-unchecked.rs:7:27
    |
 LL | const B: &[()] = unsafe { A.get_unchecked(3..1) };
-   |                             ^^^^^^^^^^^^^^^^^^^
-   |
-   = note: calls in constants are limited to constant functions, tuple structs and tuple variants
+   |                           ^^^^^^^^^^^^^^^^^^^^^ evaluation of `B` failed here
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0015`.
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/issue-94675.rs b/tests/ui/consts/issue-94675.rs
index 87c8b04452b..22791e7d15e 100644
--- a/tests/ui/consts/issue-94675.rs
+++ b/tests/ui/consts/issue-94675.rs
@@ -7,7 +7,9 @@ struct Foo<'a> {
 impl<'a> Foo<'a> {
     const fn spam(&mut self, baz: &mut Vec<u32>) {
         self.bar[0] = baz.len();
-        //~^ ERROR: cannot call
+        //~^ ERROR: `Vec<usize>: [const] Index<_>` is not satisfied
+        //~| ERROR: `Vec<usize>: [const] Index<usize>` is not satisfied
+        //~| ERROR: `Vec<usize>: [const] IndexMut<usize>` is not satisfied
     }
 }
 
diff --git a/tests/ui/consts/issue-94675.stderr b/tests/ui/consts/issue-94675.stderr
index 63a86b45633..608ce0cfef0 100644
--- a/tests/ui/consts/issue-94675.stderr
+++ b/tests/ui/consts/issue-94675.stderr
@@ -1,13 +1,24 @@
-error[E0015]: cannot call non-const operator in constant functions
-  --> $DIR/issue-94675.rs:9:17
+error[E0277]: the trait bound `Vec<usize>: [const] Index<_>` is not satisfied
+  --> $DIR/issue-94675.rs:9:9
    |
 LL |         self.bar[0] = baz.len();
-   |                 ^^^
+   |         ^^^^^^^^^^^
+
+error[E0277]: the trait bound `Vec<usize>: [const] IndexMut<usize>` is not satisfied
+  --> $DIR/issue-94675.rs:9:9
+   |
+LL |         self.bar[0] = baz.len();
+   |         ^^^^^^^^^^^
+
+error[E0277]: the trait bound `Vec<usize>: [const] Index<usize>` is not satisfied
+  --> $DIR/issue-94675.rs:9:9
+   |
+LL |         self.bar[0] = baz.len();
+   |         ^^^^^^^^^^^
    |
-note: impl defined here, but it is not `const`
-  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
-   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+note: required by a bound in `std::ops::IndexMut::index_mut`
+  --> $SRC_DIR/core/src/ops/index.rs:LL:COL
 
-error: aborting due to 1 previous error
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0015`.
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs b/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs
index 316c612940c..439793ea8f7 100644
--- a/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs
+++ b/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs
@@ -1,6 +1,6 @@
 //@ edition:2018
 #![crate_type = "lib"]
-#![feature(type_ascription)]
+#![feature(type_ascription, const_index, const_trait_impl)]
 use std::future::Future;
 use std::pin::Pin;
 
@@ -129,7 +129,6 @@ pub fn inside_block() {
 
 static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
 //~^ ERROR: cast cannot be followed by indexing
-//~| ERROR: cannot call non-const operator in statics
 
 static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
 //~^ ERROR: expected one of
diff --git a/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr
index 64cf8baf9a5..ce7129da937 100644
--- a/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr
+++ b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr
@@ -219,13 +219,13 @@ LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]);
    |                        +                  +
 
 error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:`
-  --> $DIR/issue-35813-postfix-after-cast.rs:134:36
+  --> $DIR/issue-35813-postfix-after-cast.rs:133:36
    |
 LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
    |                                    ^ expected one of `)`, `,`, `.`, `?`, or an operator
 
 error: cast cannot be followed by `?`
-  --> $DIR/issue-35813-postfix-after-cast.rs:139:5
+  --> $DIR/issue-35813-postfix-after-cast.rs:138:5
    |
 LL |     Err(0u64) as Result<u64,u64>?;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -236,25 +236,25 @@ LL |     (Err(0u64) as Result<u64,u64>)?;
    |     +                            +
 
 error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:`
-  --> $DIR/issue-35813-postfix-after-cast.rs:141:14
+  --> $DIR/issue-35813-postfix-after-cast.rs:140:14
    |
 LL |     Err(0u64): Result<u64,u64>?;
    |              ^ expected one of `.`, `;`, `?`, `}`, or an operator
 
 error: expected identifier, found `:`
-  --> $DIR/issue-35813-postfix-after-cast.rs:153:13
+  --> $DIR/issue-35813-postfix-after-cast.rs:152:13
    |
 LL |     drop_ptr: F();
    |             ^ expected identifier
 
 error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:`
-  --> $DIR/issue-35813-postfix-after-cast.rs:160:13
+  --> $DIR/issue-35813-postfix-after-cast.rs:159:13
    |
 LL |     drop_ptr: fn(u8);
    |             ^ expected one of 8 possible tokens
 
 error: cast cannot be followed by a function call
-  --> $DIR/issue-35813-postfix-after-cast.rs:166:5
+  --> $DIR/issue-35813-postfix-after-cast.rs:165:5
    |
 LL |     drop as fn(u8)(0);
    |     ^^^^^^^^^^^^^^
@@ -265,13 +265,13 @@ LL |     (drop as fn(u8))(0);
    |     +              +
 
 error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:`
-  --> $DIR/issue-35813-postfix-after-cast.rs:168:13
+  --> $DIR/issue-35813-postfix-after-cast.rs:167:13
    |
 LL |     drop_ptr: fn(u8)(0);
    |             ^ expected one of 8 possible tokens
 
 error: cast cannot be followed by `.await`
-  --> $DIR/issue-35813-postfix-after-cast.rs:173:5
+  --> $DIR/issue-35813-postfix-after-cast.rs:172:5
    |
 LL |     Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -282,13 +282,13 @@ LL |     (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await;
    |     +                                                     +
 
 error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:`
-  --> $DIR/issue-35813-postfix-after-cast.rs:176:21
+  --> $DIR/issue-35813-postfix-after-cast.rs:175:21
    |
 LL |     Box::pin(noop()): Pin<Box<_>>.await;
    |                     ^ expected one of `.`, `;`, `?`, `}`, or an operator
 
 error: cast cannot be followed by a field access
-  --> $DIR/issue-35813-postfix-after-cast.rs:188:5
+  --> $DIR/issue-35813-postfix-after-cast.rs:187:5
    |
 LL |     Foo::default() as Foo.bar;
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -299,7 +299,7 @@ LL |     (Foo::default() as Foo).bar;
    |     +                     +
 
 error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:`
-  --> $DIR/issue-35813-postfix-after-cast.rs:190:19
+  --> $DIR/issue-35813-postfix-after-cast.rs:189:19
    |
 LL |     Foo::default(): Foo.bar;
    |                   ^ expected one of `.`, `;`, `?`, `}`, or an operator
@@ -322,21 +322,11 @@ LL |         if true { 33 } else { 44 }: i32.max(0)
    |                                   ^ expected one of `,`, `.`, `?`, or an operator
 
 error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
-  --> $DIR/issue-35813-postfix-after-cast.rs:151:13
+  --> $DIR/issue-35813-postfix-after-cast.rs:150:13
    |
 LL |     drop as F();
    |             ^^^ only `Fn` traits may use parentheses
 
-error[E0015]: cannot call non-const operator in statics
-  --> $DIR/issue-35813-postfix-after-cast.rs:130:42
-   |
-LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
-   |                                          ^^^^^^
-   |
-   = note: calls in statics are limited to constant functions, tuple structs and tuple variants
-   = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
-
-error: aborting due to 40 previous errors
+error: aborting due to 39 previous errors
 
-Some errors have detailed explanations: E0015, E0214.
-For more information about an error, try `rustc --explain E0015`.
+For more information about this error, try `rustc --explain E0214`.