-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let's add a test case using the full `NAME: BOUNDS` syntax to verify that compilation works and that we get the bounds that we want.
- Loading branch information
1 parent
f1e171e
commit f81bb09
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
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,65 @@ | ||
// Copyright (c) 2023 Google LLC | ||
// Copyright (c) 2023 Various contributors (see git history) | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#[trait_variant::make(Trait: Send + Sync)] | ||
pub trait LocalTrait { | ||
const CONST: &'static (); | ||
type Gat<'a> | ||
where | ||
Self: 'a; | ||
async fn assoc_async_fn_no_ret(a: (), b: ()); | ||
async fn assoc_async_method_no_ret(&self, a: (), b: ()); | ||
async fn assoc_async_fn(a: (), b: ()) -> (); | ||
async fn assoc_async_method(&self, a: (), b: ()) -> (); | ||
fn assoc_sync_fn_no_ret(a: (), b: ()); | ||
fn assoc_sync_method_no_ret(&self, a: (), b: ()); | ||
fn assoc_sync_fn(a: (), b: ()) -> (); | ||
fn assoc_sync_method(&self, a: (), b: ()) -> (); | ||
// FIXME: See #17. | ||
//async fn dft_assoc_async_fn_no_ret(_a: (), _b: ()) {} | ||
//async fn dft_assoc_async_method_no_ret(&self, _a: (), _b: ()) {} | ||
//async fn dft_assoc_async_fn(_a: (), _b: ()) -> () {} | ||
//async fn dft_assoc_async_method(&self, _a: (), _b: ()) -> () {} | ||
fn dft_assoc_sync_fn_no_ret(_a: (), _b: ()) {} | ||
fn dft_assoc_sync_method_no_ret(&self, _a: (), _b: ()) {} | ||
fn dft_assoc_sync_fn(_a: (), _b: ()) -> () {} | ||
fn dft_assoc_sync_method(&self, _a: (), _b: ()) -> () {} | ||
} | ||
|
||
impl Trait for () { | ||
const CONST: &'static () = &(); | ||
type Gat<'a> = (); | ||
async fn assoc_async_fn_no_ret(_a: (), _b: ()) {} | ||
async fn assoc_async_method_no_ret(&self, _a: (), _b: ()) {} | ||
async fn assoc_async_fn(_a: (), _b: ()) -> () {} | ||
async fn assoc_async_method(&self, _a: (), _b: ()) -> () {} | ||
fn assoc_sync_fn_no_ret(_a: (), _b: ()) {} | ||
fn assoc_sync_method_no_ret(&self, _a: (), _b: ()) {} | ||
fn assoc_sync_fn(_a: (), _b: ()) -> () {} | ||
fn assoc_sync_method(&self, _a: (), _b: ()) -> () {} | ||
} | ||
|
||
fn is_bounded<T: Send + Sync>(_: T) {} | ||
|
||
#[test] | ||
fn test() { | ||
fn inner<T: Trait>(x: T) { | ||
let (a, b) = ((), ()); | ||
is_bounded(<T as Trait>::assoc_async_fn_no_ret(a, b)); | ||
is_bounded(<T as Trait>::assoc_async_method_no_ret(&x, a, b)); | ||
is_bounded(<T as Trait>::assoc_async_fn(a, b)); | ||
is_bounded(<T as Trait>::assoc_async_method(&x, a, b)); | ||
// FIXME: See #17. | ||
//is_bounded(<T as Trait>::dft_assoc_async_fn_no_ret(a, b)); | ||
//is_bounded(<T as Trait>::dft_assoc_async_method_no_ret(&x, a, b)); | ||
//is_bounded(<T as Trait>::dft_assoc_async_fn(a, b)); | ||
//is_bounded(<T as Trait>::dft_assoc_async_method(&x, a, b)); | ||
} | ||
inner(()); | ||
} |