Skip to content
Permalink
Browse files

syntax: reformat passing of `FnHeader` to `parse_item_fn`.

  • Loading branch information...
Centril committed Oct 1, 2019
1 parent e046904 commit 5c5dd8069d0aeeb97ef6b6099767f97aec1edee4
Showing with 22 additions and 18 deletions.
  1. +16 −12 src/libsyntax/parse/parser/item.rs
  2. +6 −6 src/test/ui/async-await/edition-deny-async-fns-2015.stderr
@@ -122,12 +122,13 @@ impl<'a> Parser<'a> {
if self.eat_keyword(kw::Fn) {
// EXTERN FUNCTION ITEM
let fn_span = self.prev_span;
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
let header = FnHeader {
unsafety: Unsafety::Normal,
asyncness: respan(fn_span, IsAsync::NotAsync),
constness: respan(fn_span, Constness::NotConst),
abi: opt_abi.unwrap_or(Abi::C),
});
};
return self.parse_item_fn(lo, visibility, attrs, header);
} else if self.check(&token::OpenDelim(token::Brace)) {
return Ok(Some(
self.parse_item_foreign_mod(lo, opt_abi, visibility, attrs, extern_sp)?,
@@ -154,12 +155,13 @@ impl<'a> Parser<'a> {
// CONST FUNCTION ITEM
let unsafety = self.parse_unsafety();
self.bump();
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
let header = FnHeader {
unsafety,
asyncness: respan(const_span, IsAsync::NotAsync),
constness: respan(const_span, Constness::Const),
abi: Abi::Rust,
});
};
return self.parse_item_fn(lo, visibility, attrs, header);
}

// CONST ITEM
@@ -196,14 +198,14 @@ impl<'a> Parser<'a> {
closure_id: DUMMY_NODE_ID,
return_impl_trait_id: DUMMY_NODE_ID,
});
let item = self.parse_item_fn(lo, visibility, attrs, FnHeader {
self.ban_async_in_2015(async_span);
let header = FnHeader {
unsafety,
asyncness,
constness: respan(fn_span, Constness::NotConst),
abi: Abi::Rust,
})?;
self.ban_async_in_2015(async_span);
return Ok(item);
};
return self.parse_item_fn(lo, visibility, attrs, header);
}
}
if self.check_keyword(kw::Unsafe) &&
@@ -241,12 +243,13 @@ impl<'a> Parser<'a> {
// FUNCTION ITEM
self.bump();
let fn_span = self.prev_span;
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
let header = FnHeader {
unsafety: Unsafety::Normal,
asyncness: respan(fn_span, IsAsync::NotAsync),
constness: respan(fn_span, Constness::NotConst),
abi: Abi::Rust,
});
};
return self.parse_item_fn(lo, visibility, attrs, header);
}
if self.check_keyword(kw::Unsafe)
&& self.look_ahead(1, |t| *t != token::OpenDelim(token::Brace)) {
@@ -261,12 +264,13 @@ impl<'a> Parser<'a> {
};
self.expect_keyword(kw::Fn)?;
let fn_span = self.prev_span;
return self.parse_item_fn(lo, visibility, attrs, FnHeader {
let header = FnHeader {
unsafety: Unsafety::Unsafe,
asyncness: respan(fn_span, IsAsync::NotAsync),
constness: respan(fn_span, Constness::NotConst),
abi,
});
};
return self.parse_item_fn(lo, visibility, attrs, header);
}
if self.eat_keyword(kw::Mod) {
// MODULE ITEM
@@ -10,18 +10,18 @@ error[E0670]: `async fn` is not permitted in the 2015 edition
LL | fn baz() { async fn foo() {} }
| ^^^^^

error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:8:5
|
LL | async fn bar() {}
| ^^^^^

error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:7:1
|
LL | async fn async_baz() {
| ^^^^^

error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:8:5
|
LL | async fn bar() {}
| ^^^^^

error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:14:5
|

0 comments on commit 5c5dd80

Please sign in to comment.
You can’t perform that action at this time.