Skip to content

Commit 5c5dd80

Browse files
committed
syntax: reformat passing of FnHeader to parse_item_fn.
1 parent e046904 commit 5c5dd80

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

Diff for: src/libsyntax/parse/parser/item.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,13 @@ impl<'a> Parser<'a> {
122122
if self.eat_keyword(kw::Fn) {
123123
// EXTERN FUNCTION ITEM
124124
let fn_span = self.prev_span;
125-
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
125+
let header = FnHeader {
126126
unsafety: Unsafety::Normal,
127127
asyncness: respan(fn_span, IsAsync::NotAsync),
128128
constness: respan(fn_span, Constness::NotConst),
129129
abi: opt_abi.unwrap_or(Abi::C),
130-
});
130+
};
131+
return self.parse_item_fn(lo, visibility, attrs, header);
131132
} else if self.check(&token::OpenDelim(token::Brace)) {
132133
return Ok(Some(
133134
self.parse_item_foreign_mod(lo, opt_abi, visibility, attrs, extern_sp)?,
@@ -154,12 +155,13 @@ impl<'a> Parser<'a> {
154155
// CONST FUNCTION ITEM
155156
let unsafety = self.parse_unsafety();
156157
self.bump();
157-
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
158+
let header = FnHeader {
158159
unsafety,
159160
asyncness: respan(const_span, IsAsync::NotAsync),
160161
constness: respan(const_span, Constness::Const),
161162
abi: Abi::Rust,
162-
});
163+
};
164+
return self.parse_item_fn(lo, visibility, attrs, header);
163165
}
164166

165167
// CONST ITEM
@@ -196,14 +198,14 @@ impl<'a> Parser<'a> {
196198
closure_id: DUMMY_NODE_ID,
197199
return_impl_trait_id: DUMMY_NODE_ID,
198200
});
199-
let item = self.parse_item_fn(lo, visibility, attrs, FnHeader {
201+
self.ban_async_in_2015(async_span);
202+
let header = FnHeader {
200203
unsafety,
201204
asyncness,
202205
constness: respan(fn_span, Constness::NotConst),
203206
abi: Abi::Rust,
204-
})?;
205-
self.ban_async_in_2015(async_span);
206-
return Ok(item);
207+
};
208+
return self.parse_item_fn(lo, visibility, attrs, header);
207209
}
208210
}
209211
if self.check_keyword(kw::Unsafe) &&
@@ -241,12 +243,13 @@ impl<'a> Parser<'a> {
241243
// FUNCTION ITEM
242244
self.bump();
243245
let fn_span = self.prev_span;
244-
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
246+
let header = FnHeader {
245247
unsafety: Unsafety::Normal,
246248
asyncness: respan(fn_span, IsAsync::NotAsync),
247249
constness: respan(fn_span, Constness::NotConst),
248250
abi: Abi::Rust,
249-
});
251+
};
252+
return self.parse_item_fn(lo, visibility, attrs, header);
250253
}
251254
if self.check_keyword(kw::Unsafe)
252255
&& self.look_ahead(1, |t| *t != token::OpenDelim(token::Brace)) {
@@ -261,12 +264,13 @@ impl<'a> Parser<'a> {
261264
};
262265
self.expect_keyword(kw::Fn)?;
263266
let fn_span = self.prev_span;
264-
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
267+
let header = FnHeader {
265268
unsafety: Unsafety::Unsafe,
266269
asyncness: respan(fn_span, IsAsync::NotAsync),
267270
constness: respan(fn_span, Constness::NotConst),
268271
abi,
269-
});
272+
};
273+
return self.parse_item_fn(lo, visibility, attrs, header);
270274
}
271275
if self.eat_keyword(kw::Mod) {
272276
// MODULE ITEM

Diff for: src/test/ui/async-await/edition-deny-async-fns-2015.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
1010
LL | fn baz() { async fn foo() {} }
1111
| ^^^^^
1212

13-
error[E0670]: `async fn` is not permitted in the 2015 edition
14-
--> $DIR/edition-deny-async-fns-2015.rs:8:5
15-
|
16-
LL | async fn bar() {}
17-
| ^^^^^
18-
1913
error[E0670]: `async fn` is not permitted in the 2015 edition
2014
--> $DIR/edition-deny-async-fns-2015.rs:7:1
2115
|
2216
LL | async fn async_baz() {
2317
| ^^^^^
2418

19+
error[E0670]: `async fn` is not permitted in the 2015 edition
20+
--> $DIR/edition-deny-async-fns-2015.rs:8:5
21+
|
22+
LL | async fn bar() {}
23+
| ^^^^^
24+
2525
error[E0670]: `async fn` is not permitted in the 2015 edition
2626
--> $DIR/edition-deny-async-fns-2015.rs:14:5
2727
|

0 commit comments

Comments
 (0)