Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect fn after const unsafe / const extern #68073

Merged
merged 1 commit into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.