-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
self
in locally defined macro doesn't get rewritten
#68
Comments
self
in locally defined macro doesn't get rewritten to _self
self
in locally defined macro doesn't get rewritten
I just updated to the latest version but this is still a problem for me in the case where The following code fails to compile: fn main() {
let _ = Bar.foo();
}
#[async_trait::async_trait]
trait Foo {
async fn foo(&self);
}
macro_rules! impl_foo {
($target:ty) => {
#[async_trait::async_trait]
impl Foo for $target {
async fn foo(&self) {
}
}
};
}
struct Bar;
impl_foo!(Bar); It expands to (using #![feature(prelude_import)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
fn main() {
let _ = Bar.foo();
}
trait Foo {
#[must_use]
fn foo<'life0, 'async_trait>(
&'life0 self,
) -> ::core::pin::Pin<
Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Send + 'async_trait>,
>
where
'life0: 'async_trait,
Self: 'async_trait;
}
struct Bar;
impl Foo for Bar {
fn foo<'life0, 'async_trait>(
&'life0 self,
) -> ::core::pin::Pin<
Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Send + 'async_trait>,
>
where
'life0: 'async_trait,
Self: 'async_trait,
{
#[allow(
clippy::missing_docs_in_private_items,
clippy::type_repetition_in_bounds,
clippy::used_underscore_binding
)]
async fn __foo(_self: &Bar) {}
Box::pin(__foo(self))
}
} Interestingly this compiles if you remove the prelude import stuff 🤔 |
That one is a rustc bug: #46 / rust-lang/rust#43081. |
You should be able to work around it by using |
Hi there and thanks for the great lib!
I just noticed that
self
, when referenced from a locally defined macro, is not correctly rewritten to_self
.expands to
resulting in
Currently, I just work around this by just passing it in as
$self:ident
.The text was updated successfully, but these errors were encountered: