Skip to content

Commit 4856f9a

Browse files
2 parents 9775296 + c31b217 commit 4856f9a

3 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
#![allow(dead_code)]
5+
6+
trait Duh {}
7+
8+
impl Duh for i32 {}
9+
10+
trait Trait {
11+
type Assoc: Duh;
12+
}
13+
14+
impl<R: Duh, F: FnMut() -> R> Trait for F {
15+
type Assoc = R;
16+
}
17+
18+
type Sendable = impl Send + Duh;
19+
20+
type Foo = impl Trait<Assoc = Sendable>;
21+
22+
fn foo() -> Foo {
23+
|| 42
24+
}
25+
26+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ check-pass
2+
3+
// See https://doc.rust-lang.org/1.77.0/nightly-rustc/rustc_lint/opaque_hidden_inferred_bound/static.OPAQUE_HIDDEN_INFERRED_BOUND.html#example
4+
5+
#![feature(type_alias_impl_trait)]
6+
#![allow(dead_code)]
7+
8+
trait Duh {}
9+
10+
impl Duh for i32 {}
11+
12+
trait Trait {
13+
type Assoc: Duh;
14+
}
15+
16+
impl<R: Duh, F: FnMut() -> R> Trait for F {
17+
type Assoc = R;
18+
}
19+
20+
type Sendable = impl Send;
21+
22+
type Foo = impl Trait<Assoc = Sendable>;
23+
//~^ WARNING opaque type `Foo` does not satisfy its associated type bounds
24+
25+
fn foo() -> Foo {
26+
|| 42
27+
}
28+
29+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
warning: opaque type `Foo` does not satisfy its associated type bounds
2+
--> $DIR/tait-in-function-return-type-issue-101903.rs:22:23
3+
|
4+
LL | type Assoc: Duh;
5+
| --- this associated type bound is unsatisfied for `Sendable`
6+
...
7+
LL | type Foo = impl Trait<Assoc = Sendable>;
8+
| ^^^^^^^^^^^^^^^^
9+
|
10+
= note: `#[warn(opaque_hidden_inferred_bound)]` on by default
11+
12+
warning: 1 warning emitted
13+

0 commit comments

Comments
 (0)