Add test for #58022

This commit is contained in:
Yuki Okushi 2019-10-01 04:55:29 +09:00
parent 576c215ab9
commit bc25746d48
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,18 @@
pub trait Foo: Sized {
const SIZE: usize;
fn new(slice: &[u8; Foo::SIZE]) -> Self;
//~^ ERROR: type annotations needed: cannot resolve `_: Foo`
}
pub struct Bar<T: ?Sized>(T);
impl Bar<[u8]> {
const SIZE: usize = 32;
fn new(slice: &[u8; Self::SIZE]) -> Self {
Foo(Box::new(*slice)) //~ ERROR: expected function, found trait `Foo`
}
}
fn main() {}

View File

@ -0,0 +1,19 @@
error[E0423]: expected function, found trait `Foo`
--> $DIR/issue-58022.rs:14:9
|
LL | Foo(Box::new(*slice))
| ^^^ not a function
error[E0283]: type annotations needed: cannot resolve `_: Foo`
--> $DIR/issue-58022.rs:4:25
|
LL | const SIZE: usize;
| ------------------ required by `Foo::SIZE`
LL |
LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
| ^^^^^^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0283, E0423.
For more information about an error, try `rustc --explain E0283`.