Skip to content

Commit 01b0a8d

Browse files
Rollup merge of #88146 - BoxyUwU:tests-cec-incr-comp, r=oli-obk
Add tests for some `feature(const_evaluatable_checked)` incr comp issues Closes #77650 Closes #79251 #79251 didn't seem to be ICEing anymore so added regression tests for that aswell r? `@oli-obk`
2 parents 10165f8 + 0d9ea42 commit 01b0a8d

8 files changed

+169
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// revisions: cfail
2+
#![feature(const_generics, const_evaluatable_checked)]
3+
#![allow(incomplete_features)]
4+
// regression test for #77650
5+
fn c<T, const N: std::num::NonZeroUsize>()
6+
where
7+
[T; N.get()]: Sized,
8+
{
9+
use std::convert::TryFrom;
10+
<[T; N.get()]>::try_from(())
11+
//~^ error: the trait bound
12+
//~^^ error: mismatched types
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error[E0277]: the trait bound `[T; _]: From<()>` is not satisfied
2+
--> $DIR/hash-tyvid-regression-1.rs:9:5
3+
|
4+
LL | <[T; N.get()]>::try_from(())
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<()>` is not implemented for `[T; _]`
6+
|
7+
= note: required because of the requirements on the impl of `Into<[T; _]>` for `()`
8+
= note: required because of the requirements on the impl of `TryFrom<()>` for `[T; _]`
9+
note: required by `try_from`
10+
--> $SRC_DIR/core/src/convert/mod.rs:LL:COL
11+
|
12+
LL | fn try_from(value: T) -> Result<Self, Self::Error>;
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
error[E0308]: mismatched types
16+
--> $DIR/hash-tyvid-regression-1.rs:9:5
17+
|
18+
LL | <[T; N.get()]>::try_from(())
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found enum `Result`
20+
|
21+
= note: expected unit type `()`
22+
found enum `Result<[T; _], Infallible>`
23+
help: consider using a semicolon here
24+
|
25+
LL | <[T; N.get()]>::try_from(());
26+
| +
27+
help: try adding a return type
28+
|
29+
LL | -> Result<[T; _], Infallible> where
30+
| +++++++++++++++++++++++++++++
31+
32+
error: aborting due to 2 previous errors
33+
34+
Some errors have detailed explanations: E0277, E0308.
35+
For more information about an error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// revisions: cfail
2+
#![feature(const_generics, const_evaluatable_checked)]
3+
#![allow(incomplete_features)]
4+
// regression test for #77650
5+
struct C<T, const N: core::num::NonZeroUsize>([T; N.get()])
6+
where
7+
[T; N.get()]: Sized;
8+
impl<'a, const N: core::num::NonZeroUsize, A, B: PartialEq<A>> PartialEq<&'a [A]> for C<B, N>
9+
where
10+
[B; N.get()]: Sized,
11+
{
12+
fn eq(&self, other: &&'a [A]) -> bool {
13+
self.0 == other
14+
//~^ error: can't compare
15+
}
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0277]: can't compare `[B; _]` with `&&[A]`
2+
--> $DIR/hash-tyvid-regression-2.rs:12:16
3+
|
4+
LL | self.0 == other
5+
| ^^ no implementation for `[B; _] == &&[A]`
6+
|
7+
= help: the trait `PartialEq<&&[A]>` is not implemented for `[B; _]`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// revisions: cfail
2+
#![feature(const_generics, const_evaluatable_checked)]
3+
#![allow(incomplete_features)]
4+
// regression test for #79251
5+
struct Node<const D: usize>
6+
where
7+
SmallVec<{ D * 2 }>: ,
8+
{
9+
keys: SmallVec<{ D * 2 }>,
10+
}
11+
12+
impl<const D: usize> Node<D>
13+
where
14+
SmallVec<{ D * 2 }>: ,
15+
{
16+
fn new() -> Self {
17+
let mut node = Node::new();
18+
node.keys.some_function();
19+
//~^ error: no method named
20+
node
21+
}
22+
}
23+
24+
struct SmallVec<const D: usize> {}
25+
26+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0599]: no method named `some_function` found for struct `SmallVec` in the current scope
2+
--> $DIR/hash-tyvid-regression-3.rs:17:19
3+
|
4+
LL | node.keys.some_function();
5+
| ^^^^^^^^^^^^^ method not found in `SmallVec<{ D * 2 }>`
6+
...
7+
LL | struct SmallVec<const D: usize> {}
8+
| ------------------------------- method `some_function` not found for this
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0599`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// revisions: cfail
2+
#![feature(const_generics, const_evaluatable_checked)]
3+
#![allow(incomplete_features)]
4+
// regression test for #79251
5+
#[derive(Debug)]
6+
struct Node<K, const D: usize>
7+
where
8+
SmallVec<K, { D * 2 }>: ,
9+
{
10+
keys: SmallVec<K, { D * 2 }>,
11+
}
12+
13+
impl<K, const D: usize> Node<K, D>
14+
where
15+
SmallVec<K, { D * 2 }>: ,
16+
{
17+
fn new() -> Self {
18+
panic!()
19+
}
20+
21+
#[inline(never)]
22+
fn split(&mut self, i: usize, k: K, right: bool) -> Node<K, D> {
23+
let mut node = Node::new();
24+
node.keys.push(k);
25+
//~^ error: no method named
26+
node
27+
}
28+
}
29+
30+
#[derive(Debug)]
31+
struct SmallVec<T, const D: usize> {
32+
data: [T; D],
33+
}
34+
impl<T, const D: usize> SmallVec<T, D> {
35+
fn new() -> Self {
36+
panic!()
37+
}
38+
}
39+
40+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0599]: no method named `push` found for struct `SmallVec` in the current scope
2+
--> $DIR/hash-tyvid-regression-4.rs:23:19
3+
|
4+
LL | node.keys.push(k);
5+
| ^^^^ method not found in `SmallVec<_, { D * 2 }>`
6+
...
7+
LL | struct SmallVec<T, const D: usize> {
8+
| ---------------------------------- method `push` not found for this
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)