diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-03-25 14:35:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-25 14:35:36 -0700 |
| commit | 4856f9a42fc1ceda0a04fcddd79f5e9d6322b597 (patch) | |
| tree | a7c93ff2bfe385a53d73ad7a67b2aed0f06c49c4 | |
| parent | 977529679609222ed5d4951c737e6eb5ca4e7f11 (diff) | |
| parent | c31b2178e0c4266550375dc1641ba60dfbcf58e1 (diff) | |
| download | rust-4856f9a42fc1ceda0a04fcddd79f5e9d6322b597.tar.gz rust-4856f9a42fc1ceda0a04fcddd79f5e9d6322b597.zip | |
Rollup merge of #122950 - ShoyuVanilla:issue-101903, r=compiler-errors
Add regression tests for #101903 Closes #101903 See https://doc.rust-lang.org/1.77.0/nightly-rustc/rustc_lint/opaque_hidden_inferred_bound/static.OPAQUE_HIDDEN_INFERRED_BOUND.html#example
3 files changed, 68 insertions, 0 deletions
diff --git a/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903-fixed.rs b/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903-fixed.rs new file mode 100644 index 00000000000..109a70c766d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903-fixed.rs @@ -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() {} diff --git a/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.rs b/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.rs new file mode 100644 index 00000000000..4f9d54737dc --- /dev/null +++ b/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.rs @@ -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() {} diff --git a/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.stderr b/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.stderr new file mode 100644 index 00000000000..68def454c7f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/tait-in-function-return-type-issue-101903.stderr @@ -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 + |
