Skip to content

Commit 90e9d26

Browse files
committed
Updated tests for issue rust-lang#65673.
1 parent fb35f14 commit 90e9d26

File tree

4 files changed

+49
-22
lines changed

4 files changed

+49
-22
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![feature(trait_alias)]
2+
3+
use std::any::Any;
4+
5+
trait Trait {}
6+
7+
trait WithType {
8+
type Ctx: ?Sized;
9+
}
10+
11+
trait Alias<T> = Any where T: Trait;
12+
13+
// Note, we do not impl `Trait` for `()` here, so should expect the error below.
14+
15+
impl<T> WithType for T {
16+
type Ctx = dyn Alias<T>;
17+
}
18+
19+
fn main() {
20+
let _: Box<<() as WithType>::Ctx> = Box::new(());
21+
//~^ ERROR the trait bound `(): Trait` is not satisfied [E0277]
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0277]: the trait bound `(): Trait` is not satisfied
2+
--> $DIR/issue-65673-fail.rs:20:41
3+
|
4+
LL | let _: Box<<() as WithType>::Ctx> = Box::new(());
5+
| ^^^^^^^^^^^^ the trait `Trait` is not implemented for `()`
6+
|
7+
= note: required for the cast to the object type `dyn Alias<()>`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0277`.

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
#![feature(trait_alias)] // Enabled to reduce stderr output, but can be triggered even if disabled.
1+
// run-pass
2+
3+
#![feature(trait_alias)]
4+
5+
use std::any::Any;
6+
27
trait Trait {}
8+
39
trait WithType {
4-
type Ctx;
10+
type Ctx: ?Sized;
511
}
6-
trait Alias<T> = where T: Trait;
12+
13+
trait Alias<T> = Any where T: Trait;
14+
15+
impl Trait for () {}
716

817
impl<T> WithType for T {
918
type Ctx = dyn Alias<T>;
10-
//~^ ERROR the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
1119
}
12-
fn main() {}
20+
21+
fn main() {
22+
let _: Box<<() as WithType>::Ctx> = Box::new(());
23+
}

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

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)