Skip to content

Commit f81bb09

Browse files
committed
Add name-colon-bounds test
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.
1 parent f1e171e commit f81bb09

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) 2023 Google LLC
2+
// Copyright (c) 2023 Various contributors (see git history)
3+
//
4+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5+
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6+
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
7+
// option. This file may not be copied, modified, or distributed
8+
// except according to those terms.
9+
10+
#[trait_variant::make(Trait: Send + Sync)]
11+
pub trait LocalTrait {
12+
const CONST: &'static ();
13+
type Gat<'a>
14+
where
15+
Self: 'a;
16+
async fn assoc_async_fn_no_ret(a: (), b: ());
17+
async fn assoc_async_method_no_ret(&self, a: (), b: ());
18+
async fn assoc_async_fn(a: (), b: ()) -> ();
19+
async fn assoc_async_method(&self, a: (), b: ()) -> ();
20+
fn assoc_sync_fn_no_ret(a: (), b: ());
21+
fn assoc_sync_method_no_ret(&self, a: (), b: ());
22+
fn assoc_sync_fn(a: (), b: ()) -> ();
23+
fn assoc_sync_method(&self, a: (), b: ()) -> ();
24+
// FIXME: See #17.
25+
//async fn dft_assoc_async_fn_no_ret(_a: (), _b: ()) {}
26+
//async fn dft_assoc_async_method_no_ret(&self, _a: (), _b: ()) {}
27+
//async fn dft_assoc_async_fn(_a: (), _b: ()) -> () {}
28+
//async fn dft_assoc_async_method(&self, _a: (), _b: ()) -> () {}
29+
fn dft_assoc_sync_fn_no_ret(_a: (), _b: ()) {}
30+
fn dft_assoc_sync_method_no_ret(&self, _a: (), _b: ()) {}
31+
fn dft_assoc_sync_fn(_a: (), _b: ()) -> () {}
32+
fn dft_assoc_sync_method(&self, _a: (), _b: ()) -> () {}
33+
}
34+
35+
impl Trait for () {
36+
const CONST: &'static () = &();
37+
type Gat<'a> = ();
38+
async fn assoc_async_fn_no_ret(_a: (), _b: ()) {}
39+
async fn assoc_async_method_no_ret(&self, _a: (), _b: ()) {}
40+
async fn assoc_async_fn(_a: (), _b: ()) -> () {}
41+
async fn assoc_async_method(&self, _a: (), _b: ()) -> () {}
42+
fn assoc_sync_fn_no_ret(_a: (), _b: ()) {}
43+
fn assoc_sync_method_no_ret(&self, _a: (), _b: ()) {}
44+
fn assoc_sync_fn(_a: (), _b: ()) -> () {}
45+
fn assoc_sync_method(&self, _a: (), _b: ()) -> () {}
46+
}
47+
48+
fn is_bounded<T: Send + Sync>(_: T) {}
49+
50+
#[test]
51+
fn test() {
52+
fn inner<T: Trait>(x: T) {
53+
let (a, b) = ((), ());
54+
is_bounded(<T as Trait>::assoc_async_fn_no_ret(a, b));
55+
is_bounded(<T as Trait>::assoc_async_method_no_ret(&x, a, b));
56+
is_bounded(<T as Trait>::assoc_async_fn(a, b));
57+
is_bounded(<T as Trait>::assoc_async_method(&x, a, b));
58+
// FIXME: See #17.
59+
//is_bounded(<T as Trait>::dft_assoc_async_fn_no_ret(a, b));
60+
//is_bounded(<T as Trait>::dft_assoc_async_method_no_ret(&x, a, b));
61+
//is_bounded(<T as Trait>::dft_assoc_async_fn(a, b));
62+
//is_bounded(<T as Trait>::dft_assoc_async_method(&x, a, b));
63+
}
64+
inner(());
65+
}

0 commit comments

Comments
 (0)