Skip to content

Commit

Permalink
added failing test for issue:106136
Browse files Browse the repository at this point in the history
  • Loading branch information
megakorre committed Feb 17, 2023
1 parent 068161e commit 8ea3b58
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/incremental/auxiliary/issue-106136-macro-def.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// force-host
// no-prefer-dynamic
// edition:2021

#![crate_type = "proc-macro"]

extern crate proc_macro;

use proc_macro::TokenStream;

const TEMPLATE : &str = "
type F<'a> = fn(&'a ());
struct S<'a> {
r: &'a VARIABLE,
o: Box<F<'a>>,
}
struct SAsyncSendTryBuilder<
'a,
RBuilder_: for<'this> FnOnce(
&'this Box<F<'a>>,
) -> Pin<
Box<dyn Future<Output = Result<&'this VARIABLE, Error_>> + Send + 'this>,
>,
Error_,
> {
o: Box<F<'a>>,
r_builder: RBuilder_,
}
impl<'a, RBuilder_: for<'this> FnOnce(
&'this Box<F<'a>>,
) -> Pin<
Box<dyn Future<Output = Result<&'this VARIABLE, Error_>> + Send + 'this>,
>,
Error_,
> SAsyncSendTryBuilder<'a, RBuilder_, Error_>
{
async fn try_build_or_recover(self) -> Result<S<'a>, (Error_, Heads<'a>)> {
S::try_new_or_recover_async_send(self.o, self.r_builder).await
}
}
struct Heads<'a> {
o: Box<F<'a>>,
_consume_template_lifetime_a: PhantomData<&'a ()>,
}
impl<'a> S<'a> {
async fn try_new_or_recover_async_send<Error_>(
o: Box<F<'a>>,
r_builder: impl for<'this> FnOnce(
&'this Box<F<'a>>,
) -> Pin<
Box<dyn Future<Output = Result<&'this VARIABLE, Error_>> + Send + 'this>,
>,
) -> Result<S<'a>, (Error_, Heads<'a>)> {
todo!()
}
}";

#[proc_macro_derive(IncrementalMacro)]
pub fn derive(input: TokenStream) -> TokenStream {
#[cfg(cfail1)] let template_type = "u8";
#[cfg(cfail2)] let template_type = "str";

TEMPLATE
.replace("VARIABLE", template_type)
.parse()
.unwrap()
}
16 changes: 16 additions & 0 deletions tests/incremental/issue-106136.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// aux-build:issue-106136-macro-def.rs
// revisions: cfail1 cfail2
// build-pass
// edition:2021

#![crate_type = "rlib"]

#[macro_use]
extern crate issue_106136_macro_def;

use core::pin::Pin;
use core::future::Future;
use core::marker::PhantomData;

#[derive(IncrementalMacro)]
pub struct Foo {}

0 comments on commit 8ea3b58

Please sign in to comment.