Skip to content

Commit cebf357

Browse files
authored
Unrolled build for rust-lang#117973
Rollup merge of rust-lang#117973 - CohenArthur:fix-89699, r=lqd test: Add test for async-move in 2015 Rust proc macro Fixes rust-lang#89699 Ran cargo bisect-rustc to find when this was fixed exactly, which is in 474709a
2 parents 8534923 + fd70a4c commit cebf357

3 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
// Proc macro helper for issue #89699, used by tests/ui/proc-macro/edition-gated-async-move-
5+
// syntax-issue89699.rs, emitting an `async move` closure. This syntax is only available in
6+
// editions 2018 and up, but is used in edition 2015 in the test.
7+
8+
#![crate_type = "proc-macro"]
9+
10+
extern crate proc_macro;
11+
use proc_macro::*;
12+
13+
#[proc_macro_attribute]
14+
pub fn foo(_attr: TokenStream, item: TokenStream) -> TokenStream {
15+
let tt = item.into_iter().next().unwrap();
16+
let sp = tt.span();
17+
let mut arg = TokenStream::new();
18+
let mut g = Group::new(Delimiter::Brace, TokenStream::new());
19+
g.set_span(sp);
20+
arg.extend([
21+
TokenTree::Ident(Ident::new("async", sp)),
22+
TokenTree::Ident(Ident::new("move", sp)),
23+
TokenTree::Group(g),
24+
]);
25+
let mut body = TokenStream::new();
26+
body.extend([
27+
TokenTree::Ident(Ident::new("async_main", sp)),
28+
TokenTree::Group(Group::new(Delimiter::Parenthesis, arg)),
29+
]);
30+
31+
let mut ret = TokenStream::new();
32+
ret.extend([
33+
TokenTree::Ident(Ident::new("fn", sp)),
34+
TokenTree::Ident(Ident::new("main", sp)),
35+
TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
36+
TokenTree::Group(Group::new(Delimiter::Brace, body)),
37+
]);
38+
ret
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// aux-build:edition-gated-async-move-syntax.rs
2+
// edition: 2015
3+
4+
// Non-regression test for issue #89699, where a proc-macro emitting syntax only available in
5+
// edition 2018 and up (`async move`) is used on edition 2015
6+
7+
extern crate edition_gated_async_move_syntax;
8+
9+
#[edition_gated_async_move_syntax::foo]
10+
fn foo() {} //~ ERROR `async move` blocks are only allowed in Rust 2018 or later
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `async move` blocks are only allowed in Rust 2018 or later
2+
--> $DIR/edition-gated-async-move-syntax-issue89699.rs:10:1
3+
|
4+
LL | fn foo() {}
5+
| ^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)