Skip to content

Commit 8ea3b58

Browse files
committed
added failing test for issue:106136
1 parent 068161e commit 8ea3b58

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
// edition:2021
4+
5+
#![crate_type = "proc-macro"]
6+
7+
extern crate proc_macro;
8+
9+
use proc_macro::TokenStream;
10+
11+
const TEMPLATE : &str = "
12+
type F<'a> = fn(&'a ());
13+
14+
struct S<'a> {
15+
r: &'a VARIABLE,
16+
o: Box<F<'a>>,
17+
}
18+
19+
struct SAsyncSendTryBuilder<
20+
'a,
21+
RBuilder_: for<'this> FnOnce(
22+
&'this Box<F<'a>>,
23+
) -> Pin<
24+
Box<dyn Future<Output = Result<&'this VARIABLE, Error_>> + Send + 'this>,
25+
>,
26+
Error_,
27+
> {
28+
o: Box<F<'a>>,
29+
r_builder: RBuilder_,
30+
}
31+
impl<'a, RBuilder_: for<'this> FnOnce(
32+
&'this Box<F<'a>>,
33+
) -> Pin<
34+
Box<dyn Future<Output = Result<&'this VARIABLE, Error_>> + Send + 'this>,
35+
>,
36+
Error_,
37+
> SAsyncSendTryBuilder<'a, RBuilder_, Error_>
38+
{
39+
async fn try_build_or_recover(self) -> Result<S<'a>, (Error_, Heads<'a>)> {
40+
S::try_new_or_recover_async_send(self.o, self.r_builder).await
41+
}
42+
}
43+
struct Heads<'a> {
44+
o: Box<F<'a>>,
45+
_consume_template_lifetime_a: PhantomData<&'a ()>,
46+
}
47+
impl<'a> S<'a> {
48+
async fn try_new_or_recover_async_send<Error_>(
49+
o: Box<F<'a>>,
50+
r_builder: impl for<'this> FnOnce(
51+
&'this Box<F<'a>>,
52+
) -> Pin<
53+
Box<dyn Future<Output = Result<&'this VARIABLE, Error_>> + Send + 'this>,
54+
>,
55+
) -> Result<S<'a>, (Error_, Heads<'a>)> {
56+
todo!()
57+
}
58+
}";
59+
60+
#[proc_macro_derive(IncrementalMacro)]
61+
pub fn derive(input: TokenStream) -> TokenStream {
62+
#[cfg(cfail1)] let template_type = "u8";
63+
#[cfg(cfail2)] let template_type = "str";
64+
65+
TEMPLATE
66+
.replace("VARIABLE", template_type)
67+
.parse()
68+
.unwrap()
69+
}

tests/incremental/issue-106136.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// aux-build:issue-106136-macro-def.rs
2+
// revisions: cfail1 cfail2
3+
// build-pass
4+
// edition:2021
5+
6+
#![crate_type = "rlib"]
7+
8+
#[macro_use]
9+
extern crate issue_106136_macro_def;
10+
11+
use core::pin::Pin;
12+
use core::future::Future;
13+
use core::marker::PhantomData;
14+
15+
#[derive(IncrementalMacro)]
16+
pub struct Foo {}

0 commit comments

Comments
 (0)