diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/consts/issue-94675.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-94675.stderr | 38 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-87707.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-87707.run.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/on-unimplemented/impl-substs.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/on-unimplemented/impl-substs.stderr | 13 |
6 files changed, 85 insertions, 2 deletions
diff --git a/src/test/ui/consts/issue-94675.rs b/src/test/ui/consts/issue-94675.rs new file mode 100644 index 00000000000..0604aab3bcd --- /dev/null +++ b/src/test/ui/consts/issue-94675.rs @@ -0,0 +1,16 @@ +#![feature(const_trait_impl, const_mut_refs)] + +struct Foo<'a> { + bar: &'a mut Vec<usize>, +} + +impl<'a> Foo<'a> { + const fn spam(&mut self, baz: &mut Vec<u32>) { + self.bar[0] = baz.len(); + //~^ ERROR cannot call non-const fn `Vec::<u32>::len` in constant functions + //~| ERROR the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied + //~| ERROR cannot call non-const operator in constant functions + } +} + +fn main() {} diff --git a/src/test/ui/consts/issue-94675.stderr b/src/test/ui/consts/issue-94675.stderr new file mode 100644 index 00000000000..6665e42835b --- /dev/null +++ b/src/test/ui/consts/issue-94675.stderr @@ -0,0 +1,38 @@ +error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions + --> $DIR/issue-94675.rs:9:27 + | +LL | self.bar[0] = baz.len(); + | ^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +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(); + | ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` + | + = help: the trait `~const IndexMut<usize>` is not implemented for `Vec<usize>` +note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that implementation is not `const` + --> $DIR/issue-94675.rs:9:9 + | +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ + +error[E0015]: cannot call non-const operator in constant functions + --> $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 + | +LL | impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/issues/issue-87707.rs b/src/test/ui/issues/issue-87707.rs index d2e9343f86c..26e9e2c8f91 100644 --- a/src/test/ui/issues/issue-87707.rs +++ b/src/test/ui/issues/issue-87707.rs @@ -1,6 +1,7 @@ // test for #87707 // edition:2018 // run-fail +// exec-env:RUST_BACKTRACE=0 // check-run-results use std::sync::Once; diff --git a/src/test/ui/issues/issue-87707.run.stderr b/src/test/ui/issues/issue-87707.run.stderr index 8f82ccc0c2a..e6c9ea0eb53 100644 --- a/src/test/ui/issues/issue-87707.run.stderr +++ b/src/test/ui/issues/issue-87707.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:12:24 +thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:13:24 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:14:7 +thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:15:7 diff --git a/src/test/ui/on-unimplemented/impl-substs.rs b/src/test/ui/on-unimplemented/impl-substs.rs new file mode 100644 index 00000000000..fe9c50ec3d4 --- /dev/null +++ b/src/test/ui/on-unimplemented/impl-substs.rs @@ -0,0 +1,15 @@ +#![feature(rustc_attrs)] + +trait Foo<A> { + fn foo(self); +} + +#[rustc_on_unimplemented = "an impl did not match: {A} {B} {C}"] +impl<A, B, C> Foo<A> for (A, B, C) { + fn foo(self) {} +} + +fn main() { + Foo::<usize>::foo((1i32, 1i32, 1i32)); + //~^ ERROR the trait bound `(i32, i32, i32): Foo<usize>` is not satisfied +} diff --git a/src/test/ui/on-unimplemented/impl-substs.stderr b/src/test/ui/on-unimplemented/impl-substs.stderr new file mode 100644 index 00000000000..db66ab0bfae --- /dev/null +++ b/src/test/ui/on-unimplemented/impl-substs.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `(i32, i32, i32): Foo<usize>` is not satisfied + --> $DIR/impl-substs.rs:13:23 + | +LL | Foo::<usize>::foo((1i32, 1i32, 1i32)); + | ----------------- ^^^^^^^^^^^^^^^^^^ an impl did not match: usize _ _ + | | + | required by a bound introduced by this call + | + = help: the trait `Foo<usize>` is not implemented for `(i32, i32, i32)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
