Skip to content

Commit

Permalink
Add test for rust-lang#58022
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Sep 30, 2019
1 parent 576c215 commit bc25746
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/ui/issues/issue-58022.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions src/test/ui/issues/issue-58022.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit bc25746

Please sign in to comment.