Skip to content

Commit

Permalink
expect fn after const unsafe / const extern
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Jan 9, 2020
1 parent 59eb49d commit 915db7a
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 915db7a

Please sign in to comment.