Add test for #58022
This commit is contained in:
18
src/test/ui/issues/issue-58022.rs
Normal file
18
src/test/ui/issues/issue-58022.rs
Normal 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() {}
|
||||||
19
src/test/ui/issues/issue-58022.stderr
Normal file
19
src/test/ui/issues/issue-58022.stderr
Normal 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`.
|
||||||
Reference in New Issue
Block a user