Skip to content

Commit 57b3652

Browse files
committed
fix: Always refer to the core crate
And not to a user defined module or import named `core`
1 parent d5dc4f8 commit 57b3652

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/expand.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn transform_sig(
194194
where_clause.predicates.push(if assume_bound || is_local {
195195
parse_quote!(Self: #lifetime)
196196
} else {
197-
parse_quote!(Self: core::marker::#bound + #lifetime)
197+
parse_quote!(Self: ::core::marker::#bound + #lifetime)
198198
});
199199
}
200200
} else {
@@ -222,12 +222,12 @@ fn transform_sig(
222222
let bounds = if is_local {
223223
quote!(#lifetime)
224224
} else {
225-
quote!(core::marker::Send + #lifetime)
225+
quote!(::core::marker::Send + #lifetime)
226226
};
227227

228228
sig.output = parse_quote! {
229-
-> core::pin::Pin<Box<
230-
dyn core::future::Future<Output = #ret> + #bounds
229+
-> ::core::pin::Pin<Box<
230+
dyn ::core::future::Future<Output = #ret> + #bounds
231231
>>
232232
};
233233
}
@@ -317,8 +317,8 @@ fn transform_block(
317317
match context {
318318
Context::Trait { .. } => {
319319
self_bound = Some(match mutability {
320-
Some(_) => parse_quote!(core::marker::Send),
321-
None => parse_quote!(core::marker::Sync),
320+
Some(_) => parse_quote!(::core::marker::Send),
321+
None => parse_quote!(::core::marker::Sync),
322322
});
323323
*arg = parse_quote! {
324324
#under_self: &#lifetime #mutability AsyncTrait
@@ -343,7 +343,7 @@ fn transform_block(
343343
let under_self = Ident::new("_self", self_token.span);
344344
match context {
345345
Context::Trait { .. } => {
346-
self_bound = Some(parse_quote!(core::marker::Send));
346+
self_bound = Some(parse_quote!(::core::marker::Send));
347347
*arg = parse_quote! {
348348
#mutability #under_self: AsyncTrait
349349
};

tests/test.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use async_trait::async_trait;
44

55
pub mod executor;
66

7+
// Dummy module to check that the expansion refer to rust's core crate
8+
mod core {}
9+
710
#[async_trait]
811
trait Trait {
912
type Assoc;
@@ -361,15 +364,14 @@ pub mod issue31 {
361364
}
362365
}
363366

364-
365367
#[async_trait]
366-
pub unsafe trait UnsafeTrait { }
368+
pub unsafe trait UnsafeTrait {}
367369

368370
#[async_trait]
369-
unsafe impl UnsafeTrait for () { }
371+
unsafe impl UnsafeTrait for () {}
370372

371373
#[async_trait]
372-
pub(crate) unsafe trait UnsafeTraitPubCrate { }
374+
pub(crate) unsafe trait UnsafeTraitPubCrate {}
373375

374376
#[async_trait]
375-
unsafe trait UnsafeTraitPrivate { }
377+
unsafe trait UnsafeTraitPrivate {}

0 commit comments

Comments
 (0)