Skip to content

Commit 0f1093b

Browse files
committed
Add tests for issue number 89299 and 149881
1 parent fffc4fc commit 0f1093b

6 files changed

Lines changed: 115 additions & 0 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
2+
--> $DIR/expectated-input-not-satisfying-fn-bounds-issue-149881.rs:15:24
3+
|
4+
LL | <[_]>::into_vec(id(Box::new([0, 1, 2])));
5+
| -- ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `Sized` is not implemented for `[{integer}]`
10+
note: required by an implicit `Sized` bound in `id`
11+
--> $DIR/expectated-input-not-satisfying-fn-bounds-issue-149881.rs:10:7
12+
|
13+
LL | fn id<T>(x: Box<T>) -> Box<T> {
14+
| ^ required by the implicit `Sized` requirement on this type parameter in `id`
15+
help: consider relaxing the implicit `Sized` restriction
16+
|
17+
LL | fn id<T: ?Sized>(x: Box<T>) -> Box<T> {
18+
| ++++++++
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
2+
--> $DIR/expectated-input-not-satisfying-fn-bounds-issue-149881.rs:15:24
3+
|
4+
LL | <[_]>::into_vec(id(Box::new([0, 1, 2])));
5+
| -- ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `Sized` is not implemented for `[{integer}]`
10+
note: required by an implicit `Sized` bound in `id`
11+
--> $DIR/expectated-input-not-satisfying-fn-bounds-issue-149881.rs:10:7
12+
|
13+
LL | fn id<T>(x: Box<T>) -> Box<T> {
14+
| ^ required by the implicit `Sized` requirement on this type parameter in `id`
15+
help: consider relaxing the implicit `Sized` restriction
16+
|
17+
LL | fn id<T: ?Sized>(x: Box<T>) -> Box<T> {
18+
| ++++++++
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
5+
// FIXME(#149379): This should pass, but fails due to fudged expactation
6+
// types which are potentially not well-formed or for whom the function
7+
// where-bounds don't actually hold. And this results in weird bugs when
8+
// later treating these expectations as if they were actually correct..
9+
10+
fn id<T>(x: Box<T>) -> Box<T> {
11+
x
12+
}
13+
14+
fn main() {
15+
<[_]>::into_vec(id(Box::new([0, 1, 2])));
16+
//~^ ERROR: the size for values of type `[{integer}]` cannot be known at compilation time
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0277]: `dyn Trait + Send` cannot be unpinned
2+
--> $DIR/expectated-input-not-satisfying-fn-bounds-issue-89299.rs:20:27
3+
|
4+
LL | let _x = Foo(Pin::new(&mut a));
5+
| -------- ^^^^^^ the trait `Unpin` is not implemented for `dyn Trait + Send`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= note: consider using the `pin!` macro
10+
consider using `Box::pin` if you need to access the pinned value outside of the current scope
11+
note: required by a bound in `Pin::<Ptr>::new`
12+
--> $SRC_DIR/core/src/pin.rs:LL:COL
13+
14+
error: aborting due to 1 previous error
15+
16+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0277]: `dyn Trait + Send` cannot be unpinned
2+
--> $DIR/expectated-input-not-satisfying-fn-bounds-issue-89299.rs:20:27
3+
|
4+
LL | let _x = Foo(Pin::new(&mut a));
5+
| -------- ^^^^^^ the trait `Unpin` is not implemented for `dyn Trait + Send`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= note: consider using the `pin!` macro
10+
consider using `Box::pin` if you need to access the pinned value outside of the current scope
11+
note: required by a bound in `Pin::<Ptr>::new`
12+
--> $SRC_DIR/core/src/pin.rs:LL:COL
13+
14+
error: aborting due to 1 previous error
15+
16+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
5+
// FIXME(#149379): This should pass, but fails due to fudged expactation
6+
// types which are potentially not well-formed or for whom the function
7+
// where-bounds don't actually hold. And this results in weird bugs when
8+
// later treating these expectations as if they were actually correct..
9+
10+
use std::pin::Pin;
11+
12+
trait Trait {}
13+
14+
impl Trait for i32 {}
15+
16+
struct Foo<'a>(Pin<&'a mut (dyn Trait + Send)>);
17+
18+
fn main() {
19+
let mut a = 1;
20+
let _x = Foo(Pin::new(&mut a));
21+
//~^ ERROR: `dyn Trait + Send` cannot be unpinned
22+
}

0 commit comments

Comments
 (0)