Skip to content

Commit

Permalink
Rollup merge of rust-lang#68073 - Centril:fix-68062, r=estebank
Browse files Browse the repository at this point in the history
expect `fn` after `const unsafe` / `const extern`

Fixes rust-lang#68062

r? @estebank @petrochenkov
cc @Aaron1011
  • Loading branch information
Centril authored Jan 10, 2020
2 parents 2307f0c + 915db7a commit 6f3f1c5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'a> Parser<'a> {
self.sess.gated_spans.gate(sym::const_extern_fn, lo.to(self.token.span));
}
let ext = self.parse_extern()?;
self.bump(); // `fn`
self.expect_keyword(kw::Fn)?;

let header = FnHeader {
unsafety,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {}

#[cfg(FALSE)]
fn container() {
const unsafe WhereIsFerris Now() {}
//~^ ERROR expected one of `extern` or `fn`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected one of `extern` or `fn`, found `WhereIsFerris`
--> $DIR/issue-68062-const-extern-fns-dont-need-fn-specifier-2.rs:5:18
|
LL | const unsafe WhereIsFerris Now() {}
| ^^^^^^^^^^^^^ expected one of `extern` or `fn`

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {}

#[cfg(FALSE)]
fn container() {
const extern "Rust" PUT_ANYTHING_YOU_WANT_HERE bug() -> usize { 1 }
//~^ ERROR expected `fn`
//~| ERROR `const extern fn` definitions are unstable
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: expected `fn`, found `PUT_ANYTHING_YOU_WANT_HERE`
--> $DIR/issue-68062-const-extern-fns-dont-need-fn-specifier.rs:5:25
|
LL | const extern "Rust" PUT_ANYTHING_YOU_WANT_HERE bug() -> usize { 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `fn`

error[E0658]: `const extern fn` definitions are unstable
--> $DIR/issue-68062-const-extern-fns-dont-need-fn-specifier.rs:5:5
|
LL | const extern "Rust" PUT_ANYTHING_YOU_WANT_HERE bug() -> usize { 1 }
| ^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64926
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

0 comments on commit 6f3f1c5

Please sign in to comment.