Skip to content

Commit bc25746

Browse files
committed
Add test for #58022
1 parent 576c215 commit bc25746

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/test/ui/issues/issue-58022.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub trait Foo: Sized {
2+
const SIZE: usize;
3+
4+
fn new(slice: &[u8; Foo::SIZE]) -> Self;
5+
//~^ ERROR: type annotations needed: cannot resolve `_: Foo`
6+
}
7+
8+
pub struct Bar<T: ?Sized>(T);
9+
10+
impl Bar<[u8]> {
11+
const SIZE: usize = 32;
12+
13+
fn new(slice: &[u8; Self::SIZE]) -> Self {
14+
Foo(Box::new(*slice)) //~ ERROR: expected function, found trait `Foo`
15+
}
16+
}
17+
18+
fn main() {}

src/test/ui/issues/issue-58022.stderr

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

0 commit comments

Comments
 (0)