-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3b05c6
commit c31b217
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903-fixed.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//@ check-pass | ||
|
||
#![feature(type_alias_impl_trait)] | ||
#![allow(dead_code)] | ||
|
||
trait Duh {} | ||
|
||
impl Duh for i32 {} | ||
|
||
trait Trait { | ||
type Assoc: Duh; | ||
} | ||
|
||
impl<R: Duh, F: FnMut() -> R> Trait for F { | ||
type Assoc = R; | ||
} | ||
|
||
type Sendable = impl Send + Duh; | ||
|
||
type Foo = impl Trait<Assoc = Sendable>; | ||
|
||
fn foo() -> Foo { | ||
|| 42 | ||
} | ||
|
||
fn main() {} |
29 changes: 29 additions & 0 deletions
29
tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//@ check-pass | ||
|
||
// See https://doc.rust-lang.org/1.77.0/nightly-rustc/rustc_lint/opaque_hidden_inferred_bound/static.OPAQUE_HIDDEN_INFERRED_BOUND.html#example | ||
|
||
#![feature(type_alias_impl_trait)] | ||
#![allow(dead_code)] | ||
|
||
trait Duh {} | ||
|
||
impl Duh for i32 {} | ||
|
||
trait Trait { | ||
type Assoc: Duh; | ||
} | ||
|
||
impl<R: Duh, F: FnMut() -> R> Trait for F { | ||
type Assoc = R; | ||
} | ||
|
||
type Sendable = impl Send; | ||
|
||
type Foo = impl Trait<Assoc = Sendable>; | ||
//~^ WARNING opaque type `Foo` does not satisfy its associated type bounds | ||
|
||
fn foo() -> Foo { | ||
|| 42 | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
warning: opaque type `Foo` does not satisfy its associated type bounds | ||
--> $DIR/tait-in-function-return-type-issue-101903.rs:22:23 | ||
| | ||
LL | type Assoc: Duh; | ||
| --- this associated type bound is unsatisfied for `Sendable` | ||
... | ||
LL | type Foo = impl Trait<Assoc = Sendable>; | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(opaque_hidden_inferred_bound)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|