diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-1.rs b/src/test/incremental/const-generics/hash-tyvid-regression-1.rs new file mode 100644 index 0000000000000..f98ae59ddfe3c --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-1.rs @@ -0,0 +1,15 @@ +// revisions: cfail +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] +// regression test for #77650 +fn c() +where + [T; N.get()]: Sized, +{ + use std::convert::TryFrom; + <[T; N.get()]>::try_from(()) + //~^ error: the trait bound + //~^^ error: mismatched types +} + +fn main() {} diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-1.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-1.stderr new file mode 100644 index 0000000000000..cb8ca3abd7f94 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-1.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `[T; _]: From<()>` is not satisfied + --> $DIR/hash-tyvid-regression-1.rs:9:5 + | +LL | <[T; N.get()]>::try_from(()) + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<()>` is not implemented for `[T; _]` + | + = note: required because of the requirements on the impl of `Into<[T; _]>` for `()` + = note: required because of the requirements on the impl of `TryFrom<()>` for `[T; _]` +note: required by `try_from` + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL + | +LL | fn try_from(value: T) -> Result; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/hash-tyvid-regression-1.rs:9:5 + | +LL | <[T; N.get()]>::try_from(()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found enum `Result` + | + = note: expected unit type `()` + found enum `Result<[T; _], Infallible>` +help: consider using a semicolon here + | +LL | <[T; N.get()]>::try_from(()); + | + +help: try adding a return type + | +LL | -> Result<[T; _], Infallible> where + | +++++++++++++++++++++++++++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-2.rs b/src/test/incremental/const-generics/hash-tyvid-regression-2.rs new file mode 100644 index 0000000000000..22536ff56d7ce --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-2.rs @@ -0,0 +1,18 @@ +// revisions: cfail +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] +// regression test for #77650 +struct C([T; N.get()]) +where + [T; N.get()]: Sized; +impl<'a, const N: core::num::NonZeroUsize, A, B: PartialEq> PartialEq<&'a [A]> for C +where + [B; N.get()]: Sized, +{ + fn eq(&self, other: &&'a [A]) -> bool { + self.0 == other + //~^ error: can't compare + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-2.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-2.stderr new file mode 100644 index 0000000000000..0e6040ef02e7a --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-2.stderr @@ -0,0 +1,11 @@ +error[E0277]: can't compare `[B; _]` with `&&[A]` + --> $DIR/hash-tyvid-regression-2.rs:12:16 + | +LL | self.0 == other + | ^^ no implementation for `[B; _] == &&[A]` + | + = help: the trait `PartialEq<&&[A]>` is not implemented for `[B; _]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-3.rs b/src/test/incremental/const-generics/hash-tyvid-regression-3.rs new file mode 100644 index 0000000000000..76b1ae11c7d03 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-3.rs @@ -0,0 +1,26 @@ +// revisions: cfail +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] +// regression test for #79251 +struct Node +where + SmallVec<{ D * 2 }>: , +{ + keys: SmallVec<{ D * 2 }>, +} + +impl Node +where + SmallVec<{ D * 2 }>: , +{ + fn new() -> Self { + let mut node = Node::new(); + node.keys.some_function(); + //~^ error: no method named + node + } +} + +struct SmallVec {} + +fn main() {} diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-3.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-3.stderr new file mode 100644 index 0000000000000..555d46756dcb9 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-3.stderr @@ -0,0 +1,12 @@ +error[E0599]: no method named `some_function` found for struct `SmallVec` in the current scope + --> $DIR/hash-tyvid-regression-3.rs:17:19 + | +LL | node.keys.some_function(); + | ^^^^^^^^^^^^^ method not found in `SmallVec<{ D * 2 }>` +... +LL | struct SmallVec {} + | ------------------------------- method `some_function` not found for this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-4.rs b/src/test/incremental/const-generics/hash-tyvid-regression-4.rs new file mode 100644 index 0000000000000..35a675a2ab4d2 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-4.rs @@ -0,0 +1,40 @@ +// revisions: cfail +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] +// regression test for #79251 +#[derive(Debug)] +struct Node +where + SmallVec: , +{ + keys: SmallVec, +} + +impl Node +where + SmallVec: , +{ + fn new() -> Self { + panic!() + } + + #[inline(never)] + fn split(&mut self, i: usize, k: K, right: bool) -> Node { + let mut node = Node::new(); + node.keys.push(k); + //~^ error: no method named + node + } +} + +#[derive(Debug)] +struct SmallVec { + data: [T; D], +} +impl SmallVec { + fn new() -> Self { + panic!() + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-4.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-4.stderr new file mode 100644 index 0000000000000..c9a6715e571c9 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-4.stderr @@ -0,0 +1,12 @@ +error[E0599]: no method named `push` found for struct `SmallVec` in the current scope + --> $DIR/hash-tyvid-regression-4.rs:23:19 + | +LL | node.keys.push(k); + | ^^^^ method not found in `SmallVec<_, { D * 2 }>` +... +LL | struct SmallVec { + | ---------------------------------- method `push` not found for this + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`.