Skip to content

Commit

Permalink
syntax: reformat passing of FnHeader to parse_item_fn.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Oct 1, 2019
1 parent e046904 commit 5c5dd80
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
28 changes: 16 additions & 12 deletions src/libsyntax/parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?,
Expand All @@ -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
Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -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)) {
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/async-await/edition-deny-async-fns-2015.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand Down

0 comments on commit 5c5dd80

Please sign in to comment.