Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for some feature(const_evaluatable_checked) incr comp issues #88146

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// revisions: cfail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need revisions at all if there is only one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you dont have a revision the testing stuff shouts at you saying Incremental tests require revisions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol ok. I guess the alternative would be to move the test to ui tests and add flags, but I don't see why that would be better.

#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #77650
fn c<T, const N: std::num::NonZeroUsize>()
where
[T; N.get()]: Sized,
{
use std::convert::TryFrom;
<[T; N.get()]>::try_from(())
//~^ error: the trait bound
//~^^ error: mismatched types
}

fn main() {}
35 changes: 35 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-1.stderr
Original file line number Diff line number Diff line change
@@ -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<Self, Self::Error>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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`.
18 changes: 18 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// revisions: cfail
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #77650
struct C<T, const N: core::num::NonZeroUsize>([T; N.get()])
where
[T; N.get()]: Sized;
impl<'a, const N: core::num::NonZeroUsize, A, B: PartialEq<A>> PartialEq<&'a [A]> for C<B, N>
where
[B; N.get()]: Sized,
{
fn eq(&self, other: &&'a [A]) -> bool {
self.0 == other
//~^ error: can't compare
}
}

fn main() {}
11 changes: 11 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-2.stderr
Original file line number Diff line number Diff line change
@@ -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`.
26 changes: 26 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// revisions: cfail
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #79251
struct Node<const D: usize>
where
SmallVec<{ D * 2 }>: ,
{
keys: SmallVec<{ D * 2 }>,
}

impl<const D: usize> Node<D>
where
SmallVec<{ D * 2 }>: ,
{
fn new() -> Self {
let mut node = Node::new();
node.keys.some_function();
//~^ error: no method named
node
}
}

struct SmallVec<const D: usize> {}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-3.stderr
Original file line number Diff line number Diff line change
@@ -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<const D: usize> {}
| ------------------------------- method `some_function` not found for this

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
40 changes: 40 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// revisions: cfail
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #79251
#[derive(Debug)]
struct Node<K, const D: usize>
where
SmallVec<K, { D * 2 }>: ,
{
keys: SmallVec<K, { D * 2 }>,
}

impl<K, const D: usize> Node<K, D>
where
SmallVec<K, { D * 2 }>: ,
{
fn new() -> Self {
panic!()
}

#[inline(never)]
fn split(&mut self, i: usize, k: K, right: bool) -> Node<K, D> {
let mut node = Node::new();
node.keys.push(k);
//~^ error: no method named
node
}
}

#[derive(Debug)]
struct SmallVec<T, const D: usize> {
data: [T; D],
}
impl<T, const D: usize> SmallVec<T, D> {
fn new() -> Self {
panic!()
}
}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-4.stderr
Original file line number Diff line number Diff line change
@@ -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<T, const D: usize> {
| ---------------------------------- method `push` not found for this

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.