Skip to content

Commit 0e49feb

Browse files
authored
Rollup merge of #88409 - spastorino:autoleakage-tait-test, r=oli-obk
Add auto trait leakage TAIT test r? `@oli-obk` Related to #86727
2 parents b490f35 + c85529e commit 0e49feb

5 files changed

+100
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
#![allow(dead_code)]
5+
6+
mod m {
7+
type Foo = impl std::fmt::Debug;
8+
9+
pub fn foo() -> Foo {
10+
22_u32
11+
}
12+
}
13+
14+
fn is_send<T: Send>(_: T) {}
15+
16+
fn main() {
17+
is_send(m::foo());
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(type_alias_impl_trait)]
2+
#![allow(dead_code)]
3+
4+
mod m {
5+
use std::rc::Rc;
6+
7+
type Foo = impl std::fmt::Debug;
8+
9+
pub fn foo() -> Foo {
10+
Rc::new(22_u32)
11+
}
12+
}
13+
14+
fn is_send<T: Send>(_: T) {}
15+
16+
fn main() {
17+
is_send(m::foo());
18+
//~^ ERROR: `Rc<u32>` cannot be sent between threads safely [E0277]
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0277]: `Rc<u32>` cannot be sent between threads safely
2+
--> $DIR/auto-trait-leakage2.rs:17:5
3+
|
4+
LL | type Foo = impl std::fmt::Debug;
5+
| -------------------- within this `impl Debug`
6+
...
7+
LL | is_send(m::foo());
8+
| ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
9+
|
10+
= help: within `impl Debug`, the trait `Send` is not implemented for `Rc<u32>`
11+
= note: required because it appears within the type `impl Debug`
12+
note: required by a bound in `is_send`
13+
--> $DIR/auto-trait-leakage2.rs:14:15
14+
|
15+
LL | fn is_send<T: Send>(_: T) {}
16+
| ^^^^ required by this bound in `is_send`
17+
18+
error: aborting due to previous error
19+
20+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(type_alias_impl_trait)]
2+
#![allow(dead_code)]
3+
4+
// FIXME This should compile, but it currently doesn't
5+
6+
mod m {
7+
type Foo = impl std::fmt::Debug;
8+
//~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
9+
10+
pub fn foo() -> Foo {
11+
22_u32
12+
}
13+
14+
pub fn bar() {
15+
is_send(foo());
16+
}
17+
18+
fn is_send<T: Send>(_: T) {}
19+
}
20+
21+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
2+
--> $DIR/auto-trait-leakage3.rs:7:16
3+
|
4+
LL | type Foo = impl std::fmt::Debug;
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: ...which requires type-checking `m::bar`...
8+
--> $DIR/auto-trait-leakage3.rs:14:5
9+
|
10+
LL | pub fn bar() {
11+
| ^^^^^^^^^^^^
12+
= note: ...which requires evaluating trait selection obligation `impl std::fmt::Debug: std::marker::Send`...
13+
= note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
14+
note: cycle used when checking item types in module `m`
15+
--> $DIR/auto-trait-leakage3.rs:6:1
16+
|
17+
LL | mod m {
18+
| ^^^^^
19+
20+
error: aborting due to previous error
21+
22+
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)