Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jun 23, 2020
1 parent 710192d commit c035299
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/ui/const-generics/issues/issue-69654-run-pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![feature(const_generics)]
#![allow(incomplete_features, unused_braces)]

trait Bar<T> {}
impl<T> Bar<T> for [u8; {7}] {}

struct Foo<const N: usize> {}
impl<const N: usize> Foo<N>
where
[u8; N]: Bar<[(); N]>,
{
fn foo() {}
}

fn main() {
Foo::foo();
//~^ ERROR no function or associated item named `foo`
// FIXME(const_generics): The above should not error
}
15 changes: 15 additions & 0 deletions src/test/ui/const-generics/issues/issue-69654-run-pass.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0599]: no function or associated item named `foo` found for struct `Foo<{_: usize}>` in the current scope
--> $DIR/issue-69654-run-pass.rs:16:10
|
LL | struct Foo<const N: usize> {}
| -------------------------- function or associated item `foo` not found for this
...
LL | Foo::foo();
| ^^^ function or associated item not found in `Foo<{_: usize}>`
|
= note: the method `foo` exists but the following trait bounds were not satisfied:
`[u8; _]: Bar<[(); _]>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
19 changes: 19 additions & 0 deletions src/test/ui/const-generics/issues/issue-69654.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![feature(const_generics)]
#![allow(incomplete_features)]

trait Bar<T> {}
impl<T> Bar<T> for [u8; T] {}
//~^ ERROR expected value, found type parameter `T`

struct Foo<const N: usize> {}
impl<const N: usize> Foo<N>
where
[u8; N]: Bar<[(); N]>,
{
fn foo() {}
}

fn main() {
Foo::foo();
//~^ ERROR no function or associated item named `foo`
}
22 changes: 22 additions & 0 deletions src/test/ui/const-generics/issues/issue-69654.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0423]: expected value, found type parameter `T`
--> $DIR/issue-69654.rs:5:25
|
LL | impl<T> Bar<T> for [u8; T] {}
| ^ not a value

error[E0599]: no function or associated item named `foo` found for struct `Foo<{_: usize}>` in the current scope
--> $DIR/issue-69654.rs:17:10
|
LL | struct Foo<const N: usize> {}
| -------------------------- function or associated item `foo` not found for this
...
LL | Foo::foo();
| ^^^ function or associated item not found in `Foo<{_: usize}>`
|
= note: the method `foo` exists but the following trait bounds were not satisfied:
`[u8; _]: Bar<[(); _]>`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0423, E0599.
For more information about an error, try `rustc --explain E0423`.

0 comments on commit c035299

Please sign in to comment.