Skip to content

Commit 52836cf

Browse files
committed
Avoid dead_code warnings in test
warning: trait `UnsafeTraitPubCrate` is never used --> tests/test.rs:160:25 | 160 | pub(crate) unsafe trait UnsafeTraitPubCrate {} | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: trait `UnsafeTraitPrivate` is never used --> tests/test.rs:163:14 | 163 | unsafe trait UnsafeTraitPrivate {} | ^^^^^^^^^^^^^^^^^^ warning: trait `CanDestruct` is never used --> tests/test.rs:167:11 | 167 | trait CanDestruct { | ^^^^^^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:184:11 | 184 | trait Trait { | ^^^^^ warning: trait `Trait` is never used --> tests/test.rs:206:15 | 206 | pub trait Trait { | ^^^^^ warning: trait `Trait` is never used --> tests/test.rs:231:15 | 231 | pub trait Trait { | ^^^^^ warning: trait `Issue1` is never used --> tests/test.rs:243:11 | 243 | trait Issue1 { | ^^^^^^ warning: trait `Issue11` is never used --> tests/test.rs:287:11 | 287 | trait Issue11 { | ^^^^^^^ warning: struct `Struct` is never constructed --> tests/test.rs:291:12 | 291 | struct Struct; | ^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:304:11 | 304 | trait Trait {} | ^^^^^ warning: trait `Issue15` is never used --> tests/test.rs:307:11 | 307 | trait Issue15 { | ^^^^^^^ warning: trait `Issue17` is never used --> tests/test.rs:317:11 | 317 | trait Issue17 { | ^^^^^^^ warning: struct `Struct` is never constructed --> tests/test.rs:321:12 | 321 | struct Struct { | ^^^^^^ warning: struct `Str` is never constructed --> tests/test.rs:412:12 | 412 | struct Str<'a>(&'a str); | ^^^ warning: trait `Trait1` is never used --> tests/test.rs:415:11 | 415 | trait Trait1<'a> { | ^^^^^^ warning: trait `Trait2` is never used --> tests/test.rs:430:11 | 430 | trait Trait2 { | ^^^^^^ warning: trait `Trait3` is never used --> tests/test.rs:440:11 | 440 | trait Trait3<'a, 'b> { | ^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:870:11 | 870 | trait Trait { | ^^^^^ warning: trait `T1` is never used --> tests/test.rs:1006:11 | 1006 | trait T1 { | ^^ warning: struct `Foo` is never constructed --> tests/test.rs:1021:12 | 1021 | struct Foo; | ^^^ warning: trait `Trait` is never used --> tests/test.rs:1085:11 | 1085 | trait Trait { | ^^^^^ warning: trait `Trait` is never used --> tests/test.rs:1100:11 | 1100 | trait Trait<T = ()> { | ^^^^^ warning: trait `TestTrait` is never used --> tests/test.rs:1140:11 | 1140 | trait TestTrait { | ^^^^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:1287:11 | 1287 | trait Trait { | ^^^^^ warning: struct `Struct` is never constructed --> tests/test.rs:1293:12 | 1293 | struct Struct; | ^^^^^^ warning: trait `Foo` is never used --> tests/test.rs:1402:11 | 1402 | trait Foo { | ^^^
1 parent db5bfa5 commit 52836cf

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

tests/test.rs

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ pub unsafe trait UnsafeTrait {}
157157
unsafe impl UnsafeTrait for () {}
158158

159159
#[async_trait]
160+
#[allow(dead_code)]
160161
pub(crate) unsafe trait UnsafeTraitPubCrate {}
161162

162163
#[async_trait]
164+
#[allow(dead_code)]
163165
unsafe trait UnsafeTraitPrivate {}
164166

165167
pub async fn test_can_destruct() {
@@ -177,6 +179,8 @@ pub async fn test_can_destruct() {
177179
let _d: u8 = d;
178180
}
179181
}
182+
183+
let _ = <Struct as CanDestruct>::f;
180184
}
181185

182186
pub async fn test_self_in_macro() {
@@ -199,6 +203,10 @@ pub async fn test_self_in_macro() {
199203
println!("{}", self);
200204
}
201205
}
206+
207+
let _ = <String as Trait>::a;
208+
let _ = <String as Trait>::b;
209+
let _ = <String as Trait>::c;
202210
}
203211

204212
pub async fn test_inference() {
@@ -208,6 +216,10 @@ pub async fn test_inference() {
208216
Box::new(std::iter::empty())
209217
}
210218
}
219+
220+
impl Trait for () {}
221+
222+
let _ = <() as Trait>::f;
211223
}
212224

213225
pub async fn test_internal_items() {
@@ -233,14 +245,18 @@ pub async fn test_unimplemented() {
233245
unimplemented!()
234246
}
235247
}
248+
249+
impl Trait for () {}
250+
251+
let _ = <() as Trait>::f;
236252
}
237253

238254
// https://github.com/dtolnay/async-trait/issues/1
239255
pub mod issue1 {
240256
use async_trait::async_trait;
241257

242258
#[async_trait]
243-
trait Issue1 {
259+
pub trait Issue1 {
244260
async fn f<U>(&self);
245261
}
246262

@@ -284,11 +300,11 @@ pub mod issue11 {
284300
use std::sync::Arc;
285301

286302
#[async_trait]
287-
trait Issue11 {
303+
pub trait Issue11 {
288304
async fn example(self: Arc<Self>);
289305
}
290306

291-
struct Struct;
307+
pub struct Struct;
292308

293309
#[async_trait]
294310
impl Issue11 for Struct {
@@ -301,10 +317,10 @@ pub mod issue15 {
301317
use async_trait::async_trait;
302318
use std::marker::PhantomData;
303319

304-
trait Trait {}
320+
pub trait Trait {}
305321

306322
#[async_trait]
307-
trait Issue15 {
323+
pub trait Issue15 {
308324
async fn myfn(&self, _: PhantomData<dyn Trait + Send>) {}
309325
}
310326
}
@@ -314,11 +330,11 @@ pub mod issue17 {
314330
use async_trait::async_trait;
315331

316332
#[async_trait]
317-
trait Issue17 {
333+
pub trait Issue17 {
318334
async fn f(&self);
319335
}
320336

321-
struct Struct {
337+
pub struct Struct {
322338
string: String,
323339
}
324340

@@ -409,10 +425,10 @@ pub mod issue25 {
409425
pub mod issue28 {
410426
use async_trait::async_trait;
411427

412-
struct Str<'a>(&'a str);
428+
pub struct Str<'a>(&'a str);
413429

414430
#[async_trait]
415-
trait Trait1<'a> {
431+
pub trait Trait1<'a> {
416432
async fn f(x: Str<'a>) -> &'a str;
417433
async fn g(x: Str<'a>) -> &'a str {
418434
x.0
@@ -427,7 +443,7 @@ pub mod issue28 {
427443
}
428444

429445
#[async_trait]
430-
trait Trait2 {
446+
pub trait Trait2 {
431447
async fn f();
432448
}
433449

@@ -437,7 +453,7 @@ pub mod issue28 {
437453
}
438454

439455
#[async_trait]
440-
trait Trait3<'a, 'b> {
456+
pub trait Trait3<'a, 'b> {
441457
async fn f(_: &'a &'b ()); // chain 'a and 'b
442458
async fn g(_: &'b ()); // chain 'b only
443459
async fn h(); // do not chain
@@ -867,7 +883,7 @@ pub mod issue89 {
867883
use async_trait::async_trait;
868884

869885
#[async_trait]
870-
trait Trait {
886+
pub trait Trait {
871887
async fn f(&self);
872888
}
873889

@@ -1003,7 +1019,7 @@ pub mod issue104 {
10031019
use async_trait::async_trait;
10041020

10051021
#[async_trait]
1006-
trait T1 {
1022+
pub trait T1 {
10071023
async fn id(&self) -> i32;
10081024
}
10091025

@@ -1018,7 +1034,7 @@ pub mod issue104 {
10181034
};
10191035
}
10201036

1021-
struct Foo;
1037+
pub struct Foo;
10221038

10231039
impl_t1!(Foo, 1);
10241040
}
@@ -1082,7 +1098,7 @@ pub mod issue120 {
10821098
use async_trait::async_trait;
10831099

10841100
#[async_trait]
1085-
trait Trait {
1101+
pub trait Trait {
10861102
async fn f(&self);
10871103
}
10881104

@@ -1097,7 +1113,7 @@ pub mod issue123 {
10971113
use async_trait::async_trait;
10981114

10991115
#[async_trait]
1100-
trait Trait<T = ()> {
1116+
pub trait Trait<T = ()> {
11011117
async fn f(&self) -> &str
11021118
where
11031119
T: 'async_trait,
@@ -1137,7 +1153,7 @@ pub mod issue134 {
11371153
use async_trait::async_trait;
11381154

11391155
#[async_trait]
1140-
trait TestTrait {
1156+
pub trait TestTrait {
11411157
async fn run<const DUMMY: bool>(self)
11421158
where
11431159
Self: Sized,
@@ -1284,13 +1300,13 @@ pub mod issue152 {
12841300
use async_trait::async_trait;
12851301

12861302
#[async_trait]
1287-
trait Trait {
1303+
pub trait Trait {
12881304
type Assoc;
12891305

12901306
async fn f(&self) -> Self::Assoc;
12911307
}
12921308

1293-
struct Struct;
1309+
pub struct Struct;
12941310

12951311
#[async_trait]
12961312
impl Trait for Struct {
@@ -1399,7 +1415,7 @@ pub mod issue183 {
13991415
use async_trait::async_trait;
14001416

14011417
#[async_trait]
1402-
trait Foo {
1418+
pub trait Foo {
14031419
async fn foo(_n: i32) {}
14041420
}
14051421
}

0 commit comments

Comments
 (0)