parser: fuse free fn
parsing together.
This commit is contained in:
parent
36a17e4067
commit
a833be2162
28 changed files with 181 additions and 185 deletions
|
@ -1089,6 +1089,20 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
|
|
||||||
self.check_c_varadic_type(fk);
|
self.check_c_varadic_type(fk);
|
||||||
|
|
||||||
|
// Functions cannot both be `const async`
|
||||||
|
if let Some(FnHeader {
|
||||||
|
constness: Const::Yes(cspan),
|
||||||
|
asyncness: Async::Yes { span: aspan, .. },
|
||||||
|
..
|
||||||
|
}) = fk.header()
|
||||||
|
{
|
||||||
|
self.err_handler()
|
||||||
|
.struct_span_err(span, "functions cannot be both `const` and `async`")
|
||||||
|
.span_label(*cspan, "`const` because of this")
|
||||||
|
.span_label(*aspan, "`async` because of this")
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
|
|
||||||
// Functions without bodies cannot have patterns.
|
// Functions without bodies cannot have patterns.
|
||||||
if let FnKind::Fn(ctxt, _, sig, _, None) = fk {
|
if let FnKind::Fn(ctxt, _, sig, _, None) = fk {
|
||||||
Self::check_decl_no_pat(&sig.decl, |span, mut_ident| {
|
Self::check_decl_no_pat(&sig.decl, |span, mut_ident| {
|
||||||
|
|
|
@ -496,6 +496,17 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||||
if let Some(header) = fn_kind.header() {
|
if let Some(header) = fn_kind.header() {
|
||||||
// Stability of const fn methods are covered in `visit_assoc_item` below.
|
// Stability of const fn methods are covered in `visit_assoc_item` below.
|
||||||
self.check_extern(header.ext);
|
self.check_extern(header.ext);
|
||||||
|
|
||||||
|
if let (ast::Const::Yes(_), ast::Extern::Implicit)
|
||||||
|
| (ast::Const::Yes(_), ast::Extern::Explicit(_)) = (header.constness, header.ext)
|
||||||
|
{
|
||||||
|
gate_feature_post!(
|
||||||
|
&self,
|
||||||
|
const_extern_fn,
|
||||||
|
span,
|
||||||
|
"`const extern fn` definitions are unstable"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if fn_kind.ctxt() != Some(FnCtxt::Foreign) && fn_kind.decl().c_variadic() {
|
if fn_kind.ctxt() != Some(FnCtxt::Foreign) && fn_kind.decl().c_variadic() {
|
||||||
|
@ -595,7 +606,6 @@ pub fn check_crate(
|
||||||
gate_all!(async_closure, "async closures are unstable");
|
gate_all!(async_closure, "async closures are unstable");
|
||||||
gate_all!(generators, "yield syntax is experimental");
|
gate_all!(generators, "yield syntax is experimental");
|
||||||
gate_all!(or_patterns, "or-patterns syntax is experimental");
|
gate_all!(or_patterns, "or-patterns syntax is experimental");
|
||||||
gate_all!(const_extern_fn, "`const extern fn` definitions are unstable");
|
|
||||||
gate_all!(raw_ref_op, "raw address of syntax is experimental");
|
gate_all!(raw_ref_op, "raw address of syntax is experimental");
|
||||||
gate_all!(const_trait_bound_opt_out, "`?const` on trait bounds is experimental");
|
gate_all!(const_trait_bound_opt_out, "`?const` on trait bounds is experimental");
|
||||||
gate_all!(const_trait_impl, "const trait impls are experimental");
|
gate_all!(const_trait_impl, "const trait impls are experimental");
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_span::symbol::{kw, sym, Symbol};
|
||||||
use rustc_span::BytePos;
|
use rustc_span::BytePos;
|
||||||
use syntax::ast::{self, AttrKind, AttrStyle, AttrVec, Attribute, Ident, DUMMY_NODE_ID};
|
use syntax::ast::{self, AttrKind, AttrStyle, AttrVec, Attribute, Ident, DUMMY_NODE_ID};
|
||||||
use syntax::ast::{AssocItem, AssocItemKind, Item, ItemKind, UseTree, UseTreeKind};
|
use syntax::ast::{AssocItem, AssocItemKind, Item, ItemKind, UseTree, UseTreeKind};
|
||||||
use syntax::ast::{Async, Const, Defaultness, Extern, IsAuto, PathSegment, StrLit, Unsafe};
|
use syntax::ast::{Async, Const, Defaultness, IsAuto, PathSegment, StrLit, Unsafe};
|
||||||
use syntax::ast::{BindingMode, Block, FnDecl, FnSig, Mac, MacArgs, MacDelimiter, Param, SelfKind};
|
use syntax::ast::{BindingMode, Block, FnDecl, FnSig, Mac, MacArgs, MacDelimiter, Param, SelfKind};
|
||||||
use syntax::ast::{EnumDef, Generics, StructField, TraitRef, Ty, TyKind, Variant, VariantData};
|
use syntax::ast::{EnumDef, Generics, StructField, TraitRef, Ty, TyKind, Variant, VariantData};
|
||||||
use syntax::ast::{FnHeader, ForeignItem, ForeignItemKind, Mutability, Visibility, VisibilityKind};
|
use syntax::ast::{FnHeader, ForeignItem, ForeignItemKind, Mutability, Visibility, VisibilityKind};
|
||||||
|
@ -96,53 +96,30 @@ impl<'a> Parser<'a> {
|
||||||
return Ok(Some(item));
|
return Ok(Some(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.is_fn_front_matter() {
|
||||||
|
// FUNCTION ITEM
|
||||||
|
return self.parse_item_fn(lo, vis, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
if self.eat_keyword(kw::Extern) {
|
if self.eat_keyword(kw::Extern) {
|
||||||
if self.eat_keyword(kw::Crate) {
|
if self.eat_keyword(kw::Crate) {
|
||||||
|
// EXTERN CRATE
|
||||||
return Ok(Some(self.parse_item_extern_crate(lo, vis, attrs)?));
|
return Ok(Some(self.parse_item_extern_crate(lo, vis, attrs)?));
|
||||||
}
|
}
|
||||||
|
// EXTERN BLOCK
|
||||||
let abi = self.parse_abi();
|
let abi = self.parse_abi();
|
||||||
|
return Ok(Some(self.parse_item_foreign_mod(lo, abi, vis, attrs)?));
|
||||||
if self.eat_keyword(kw::Fn) {
|
|
||||||
// EXTERN FUNCTION ITEM
|
|
||||||
let header = FnHeader {
|
|
||||||
unsafety: Unsafe::No,
|
|
||||||
asyncness: Async::No,
|
|
||||||
constness: Const::No,
|
|
||||||
ext: Extern::from_abi(abi),
|
|
||||||
};
|
|
||||||
return self.parse_item_fn(lo, vis, attrs, header);
|
|
||||||
} else if self.check(&token::OpenDelim(token::Brace)) {
|
|
||||||
return Ok(Some(self.parse_item_foreign_mod(lo, abi, vis, attrs)?));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.unexpected()?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_static_global() {
|
if self.is_static_global() {
|
||||||
self.bump();
|
|
||||||
// STATIC ITEM
|
// STATIC ITEM
|
||||||
|
self.bump();
|
||||||
let m = self.parse_mutability();
|
let m = self.parse_mutability();
|
||||||
let info = self.parse_item_const(Some(m))?;
|
let info = self.parse_item_const(Some(m))?;
|
||||||
return self.mk_item_with_info(attrs, lo, vis, info);
|
return self.mk_item_with_info(attrs, lo, vis, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
let constness = self.parse_constness();
|
if let Const::Yes(const_span) = self.parse_constness() {
|
||||||
if let Const::Yes(const_span) = constness {
|
|
||||||
if [kw::Fn, kw::Unsafe, kw::Extern].iter().any(|k| self.check_keyword(*k)) {
|
|
||||||
// CONST FUNCTION ITEM
|
|
||||||
let unsafety = self.parse_unsafety();
|
|
||||||
|
|
||||||
if self.check_keyword(kw::Extern) {
|
|
||||||
self.sess.gated_spans.gate(sym::const_extern_fn, lo.to(self.token.span));
|
|
||||||
}
|
|
||||||
let ext = self.parse_extern()?;
|
|
||||||
self.expect_keyword(kw::Fn)?;
|
|
||||||
|
|
||||||
let header = FnHeader { unsafety, asyncness: Async::No, constness, ext };
|
|
||||||
return self.parse_item_fn(lo, vis, attrs, header);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CONST ITEM
|
// CONST ITEM
|
||||||
if self.eat_keyword(kw::Mut) {
|
if self.eat_keyword(kw::Mut) {
|
||||||
let prev_span = self.prev_span;
|
let prev_span = self.prev_span;
|
||||||
|
@ -161,21 +138,6 @@ impl<'a> Parser<'a> {
|
||||||
return self.mk_item_with_info(attrs, lo, vis, info);
|
return self.mk_item_with_info(attrs, lo, vis, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses `async unsafe? fn`.
|
|
||||||
if self.check_keyword(kw::Async) {
|
|
||||||
let async_span = self.token.span;
|
|
||||||
if self.is_keyword_ahead(1, &[kw::Fn]) || self.is_keyword_ahead(2, &[kw::Fn]) {
|
|
||||||
// ASYNC FUNCTION ITEM
|
|
||||||
let asyncness = self.parse_asyncness(); // `async`
|
|
||||||
let unsafety = self.parse_unsafety(); // `unsafe`?
|
|
||||||
self.expect_keyword(kw::Fn)?; // `fn`
|
|
||||||
self.ban_async_in_2015(async_span);
|
|
||||||
let header =
|
|
||||||
FnHeader { unsafety, asyncness, constness: Const::No, ext: Extern::None };
|
|
||||||
return self.parse_item_fn(lo, vis, attrs, header);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.check_keyword(kw::Unsafe) && self.is_keyword_ahead(1, &[kw::Trait, kw::Auto]) {
|
if self.check_keyword(kw::Unsafe) && self.is_keyword_ahead(1, &[kw::Trait, kw::Auto]) {
|
||||||
// UNSAFE TRAIT ITEM
|
// UNSAFE TRAIT ITEM
|
||||||
let unsafety = self.parse_unsafety();
|
let unsafety = self.parse_unsafety();
|
||||||
|
@ -195,26 +157,6 @@ impl<'a> Parser<'a> {
|
||||||
return self.mk_item_with_info(attrs, lo, vis, info);
|
return self.mk_item_with_info(attrs, lo, vis, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.check_keyword(kw::Fn) {
|
|
||||||
// FUNCTION ITEM
|
|
||||||
self.bump();
|
|
||||||
let header = FnHeader::default();
|
|
||||||
return self.parse_item_fn(lo, vis, attrs, header);
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.check_keyword(kw::Unsafe)
|
|
||||||
&& self.look_ahead(1, |t| *t != token::OpenDelim(token::Brace))
|
|
||||||
{
|
|
||||||
// UNSAFE FUNCTION ITEM
|
|
||||||
let unsafety = self.parse_unsafety();
|
|
||||||
// `{` is also expected after `unsafe`; in case of error, include it in the diagnostic.
|
|
||||||
self.check(&token::OpenDelim(token::Brace));
|
|
||||||
let ext = self.parse_extern()?;
|
|
||||||
self.expect_keyword(kw::Fn)?;
|
|
||||||
let header = FnHeader { unsafety, asyncness: Async::No, constness: Const::No, ext };
|
|
||||||
return self.parse_item_fn(lo, vis, attrs, header);
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.eat_keyword(kw::Mod) {
|
if self.eat_keyword(kw::Mod) {
|
||||||
// MODULE ITEM
|
// MODULE ITEM
|
||||||
let info = self.parse_item_mod(&attrs[..])?;
|
let info = self.parse_item_mod(&attrs[..])?;
|
||||||
|
@ -1662,9 +1604,9 @@ impl<'a> Parser<'a> {
|
||||||
lo: Span,
|
lo: Span,
|
||||||
vis: Visibility,
|
vis: Visibility,
|
||||||
mut attrs: Vec<Attribute>,
|
mut attrs: Vec<Attribute>,
|
||||||
header: FnHeader,
|
|
||||||
) -> PResult<'a, Option<P<Item>>> {
|
) -> PResult<'a, Option<P<Item>>> {
|
||||||
let cfg = ParamCfg { is_name_required: |_| true };
|
let cfg = ParamCfg { is_name_required: |_| true };
|
||||||
|
let header = self.parse_fn_front_matter()?;
|
||||||
let (ident, decl, generics) = self.parse_fn_sig(&cfg)?;
|
let (ident, decl, generics) = self.parse_fn_sig(&cfg)?;
|
||||||
let body = self.parse_fn_body(&mut false, &mut attrs)?;
|
let body = self.parse_fn_body(&mut false, &mut attrs)?;
|
||||||
let kind = ItemKind::Fn(FnSig { decl, header }, generics, body);
|
let kind = ItemKind::Fn(FnSig { decl, header }, generics, body);
|
||||||
|
@ -1730,27 +1672,24 @@ impl<'a> Parser<'a> {
|
||||||
Ok(body)
|
Ok(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the current token unambiguously the start of an `FnHeader`?
|
/// Is the current token the start of an `FnHeader` / not a valid parse?
|
||||||
fn is_fn_front_matter(&mut self) -> bool {
|
fn is_fn_front_matter(&mut self) -> bool {
|
||||||
// We use an over-approximation here.
|
// We use an over-approximation here.
|
||||||
// `const const`, `fn const` won't parse, but we're not stepping over other syntax either.
|
// `const const`, `fn const` won't parse, but we're not stepping over other syntax either.
|
||||||
// This works for `async fn` and similar as `async async` is an invalid
|
const QUALS: [Symbol; 4] = [kw::Const, kw::Async, kw::Unsafe, kw::Extern];
|
||||||
// parse and `async fn` is never a valid parse on previous editions.
|
|
||||||
const QUALIFIER: [Symbol; 4] = [kw::Const, kw::Async, kw::Unsafe, kw::Extern];
|
|
||||||
|
|
||||||
let check_qual_follow = |this: &mut Self, dist| {
|
|
||||||
this.look_ahead(dist, |t| {
|
|
||||||
// ...qualified and then `fn`, e.g. `const fn`.
|
|
||||||
t.is_keyword(kw::Fn)
|
|
||||||
// Two qualifiers. This is enough.
|
|
||||||
|| QUALIFIER.iter().any(|&kw| t.is_keyword(kw))
|
|
||||||
})
|
|
||||||
};
|
|
||||||
self.check_keyword(kw::Fn) // Definitely an `fn`.
|
self.check_keyword(kw::Fn) // Definitely an `fn`.
|
||||||
// `$qual fn` or `$qual $qual`:
|
// `$qual fn` or `$qual $qual`:
|
||||||
|| QUALIFIER.iter().any(|&kw| self.check_keyword(kw)) && check_qual_follow(self, 1)
|
|| QUALS.iter().any(|&kw| self.check_keyword(kw))
|
||||||
// `extern ABI fn` or `extern ABI $qual`; skip 1 for the ABI.
|
&& self.look_ahead(1, |t| {
|
||||||
|| self.check_keyword(kw::Extern) && check_qual_follow(self, 2)
|
// ...qualified and then `fn`, e.g. `const fn`.
|
||||||
|
t.is_keyword(kw::Fn)
|
||||||
|
// Two qualifiers. This is enough. Due `async` we need to check that it's reserved.
|
||||||
|
|| t.is_non_raw_ident_where(|i| QUALS.contains(&i.name) && i.is_reserved())
|
||||||
|
})
|
||||||
|
// `extern ABI fn`
|
||||||
|
|| self.check_keyword(kw::Extern)
|
||||||
|
&& self.look_ahead(1, |t| t.can_begin_literal_or_bool())
|
||||||
|
&& self.look_ahead(2, |t| t.is_keyword(kw::Fn))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses all the "front matter" (or "qualifiers") for a `fn` declaration,
|
/// Parses all the "front matter" (or "qualifiers") for a `fn` declaration,
|
||||||
|
|
|
@ -402,12 +402,14 @@ impl Token {
|
||||||
|
|
||||||
/// Returns `true` if the token is any literal, a minus (which can prefix a literal,
|
/// Returns `true` if the token is any literal, a minus (which can prefix a literal,
|
||||||
/// for example a '-42', or one of the boolean idents).
|
/// for example a '-42', or one of the boolean idents).
|
||||||
|
///
|
||||||
|
/// Keep this in sync with `Lit::from_token`.
|
||||||
pub fn can_begin_literal_or_bool(&self) -> bool {
|
pub fn can_begin_literal_or_bool(&self) -> bool {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Literal(..) | BinOp(Minus) => true,
|
Literal(..) | BinOp(Minus) => true,
|
||||||
Ident(name, false) if name.is_bool_lit() => true,
|
Ident(name, false) if name.is_bool_lit() => true,
|
||||||
Interpolated(ref nt) => match **nt {
|
Interpolated(ref nt) => match &**nt {
|
||||||
NtLiteral(..) => true,
|
NtExpr(e) | NtLiteral(e) => matches!(e.kind, ast::ExprKind::Lit(_)),
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -530,7 +532,7 @@ impl Token {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
|
/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
|
||||||
fn is_non_raw_ident_where(&self, pred: impl FnOnce(ast::Ident) -> bool) -> bool {
|
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(ast::Ident) -> bool) -> bool {
|
||||||
match self.ident() {
|
match self.ident() {
|
||||||
Some((id, false)) => pred(id),
|
Some((id, false)) => pred(id),
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
@ -188,6 +188,8 @@ impl Lit {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts arbitrary token into an AST literal.
|
/// Converts arbitrary token into an AST literal.
|
||||||
|
///
|
||||||
|
/// Keep this in sync with `Token::can_begin_literal_or_bool`.
|
||||||
pub fn from_token(token: &Token) -> Result<Lit, LitError> {
|
pub fn from_token(token: &Token) -> Result<Lit, LitError> {
|
||||||
let lit = match token.kind {
|
let lit = match token.kind {
|
||||||
token::Ident(name, false) if name.is_bool_lit() => {
|
token::Ident(name, false) if name.is_bool_lit() => {
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
// compile-flags: --crate-type lib
|
// compile-flags: --crate-type lib
|
||||||
|
|
||||||
pub async const fn x() {}
|
pub async const fn x() {}
|
||||||
//~^ ERROR expected one of `fn` or `unsafe`, found keyword `const`
|
//~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `const`
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected one of `fn` or `unsafe`, found keyword `const`
|
error: expected one of `extern`, `fn`, or `unsafe`, found keyword `const`
|
||||||
--> $DIR/no-async-const.rs:4:11
|
--> $DIR/no-async-const.rs:4:11
|
||||||
|
|
|
|
||||||
LL | pub async const fn x() {}
|
LL | pub async const fn x() {}
|
||||||
| ^^^^^ expected one of `fn` or `unsafe`
|
| ^^^^^ expected one of `extern`, `fn`, or `unsafe`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
// compile-flags: --crate-type lib
|
// compile-flags: --crate-type lib
|
||||||
|
|
||||||
pub const async fn x() {}
|
pub const async fn x() {}
|
||||||
//~^ ERROR expected identifier, found keyword `async`
|
//~^ ERROR functions cannot be both `const` and `async`
|
||||||
//~^^ expected `:`, found keyword `fn`
|
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
error: expected identifier, found keyword `async`
|
error: functions cannot be both `const` and `async`
|
||||||
--> $DIR/no-const-async.rs:4:11
|
--> $DIR/no-const-async.rs:4:1
|
||||||
|
|
|
|
||||||
LL | pub const async fn x() {}
|
LL | pub const async fn x() {}
|
||||||
| ^^^^^ expected identifier, found keyword
|
| ^^^^-----^-----^^^^^^^^^^
|
||||||
|
| | |
|
||||||
|
| | `async` because of this
|
||||||
|
| `const` because of this
|
||||||
|
|
||||||
error: expected `:`, found keyword `fn`
|
error: aborting due to previous error
|
||||||
--> $DIR/no-const-async.rs:4:17
|
|
||||||
|
|
|
||||||
LL | pub const async fn x() {}
|
|
||||||
| ^^ expected `:`
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,4 @@ impl S {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(FALSE)]
|
#[cfg(FALSE)]
|
||||||
unsafe async fn f() {} //~ ERROR expected one of `extern`, `fn`, or `{`, found keyword `async`
|
unsafe async fn f() {} //~ ERROR expected one of `extern` or `fn`, found keyword `async`
|
||||||
|
|
|
@ -4,11 +4,11 @@ error: expected one of `extern` or `fn`, found keyword `async`
|
||||||
LL | unsafe async fn g() {}
|
LL | unsafe async fn g() {}
|
||||||
| ^^^^^ expected one of `extern` or `fn`
|
| ^^^^^ expected one of `extern` or `fn`
|
||||||
|
|
||||||
error: expected one of `extern`, `fn`, or `{`, found keyword `async`
|
error: expected one of `extern` or `fn`, found keyword `async`
|
||||||
--> $DIR/no-unsafe-async.rs:11:8
|
--> $DIR/no-unsafe-async.rs:11:8
|
||||||
|
|
|
|
||||||
LL | unsafe async fn f() {}
|
LL | unsafe async fn f() {}
|
||||||
| ^^^^^ expected one of `extern`, `fn`, or `{`
|
| ^^^^^ expected one of `extern` or `fn`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
// Check that `const extern fn` and `const unsafe extern fn` are feature-gated.
|
// Check that `const extern fn` and `const unsafe extern fn` are feature-gated.
|
||||||
|
|
||||||
#[cfg(FALSE)] const extern fn foo1() {} //~ ERROR `const extern fn` definitions are unstable
|
const extern fn foo1() {} //~ ERROR `const extern fn` definitions are unstable
|
||||||
#[cfg(FALSE)] const extern "C" fn foo2() {} //~ ERROR `const extern fn` definitions are unstable
|
const extern "C" fn foo2() {} //~ ERROR `const extern fn` definitions are unstable
|
||||||
#[cfg(FALSE)] const extern "Rust" fn foo3() {} //~ ERROR `const extern fn` definitions are unstable
|
const extern "Rust" fn foo3() {} //~ ERROR `const extern fn` definitions are unstable
|
||||||
#[cfg(FALSE)] const unsafe extern fn bar1() {} //~ ERROR `const extern fn` definitions are unstable
|
const unsafe extern fn bar1() {} //~ ERROR `const extern fn` definitions are unstable
|
||||||
#[cfg(FALSE)] const unsafe extern "C" fn bar2() {}
|
const unsafe extern "C" fn bar2() {} //~ ERROR `const extern fn` definitions are unstable
|
||||||
//~^ ERROR `const extern fn` definitions are unstable
|
const unsafe extern "Rust" fn bar3() {} //~ ERROR `const extern fn` definitions are unstable
|
||||||
#[cfg(FALSE)] const unsafe extern "Rust" fn bar3() {}
|
|
||||||
//~^ ERROR `const extern fn` definitions are unstable
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
error[E0658]: `const extern fn` definitions are unstable
|
error[E0658]: `const extern fn` definitions are unstable
|
||||||
--> $DIR/feature-gate-const_extern_fn.rs:3:15
|
--> $DIR/feature-gate-const_extern_fn.rs:3:1
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] const extern fn foo1() {}
|
LL | const extern fn foo1() {}
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
||||||
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `const extern fn` definitions are unstable
|
error[E0658]: `const extern fn` definitions are unstable
|
||||||
--> $DIR/feature-gate-const_extern_fn.rs:4:15
|
--> $DIR/feature-gate-const_extern_fn.rs:4:1
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] const extern "C" fn foo2() {}
|
LL | const extern "C" fn foo2() {}
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
||||||
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `const extern fn` definitions are unstable
|
error[E0658]: `const extern fn` definitions are unstable
|
||||||
--> $DIR/feature-gate-const_extern_fn.rs:5:15
|
--> $DIR/feature-gate-const_extern_fn.rs:5:1
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] const extern "Rust" fn foo3() {}
|
LL | const extern "Rust" fn foo3() {}
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
||||||
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `const extern fn` definitions are unstable
|
error[E0658]: `const extern fn` definitions are unstable
|
||||||
--> $DIR/feature-gate-const_extern_fn.rs:6:15
|
--> $DIR/feature-gate-const_extern_fn.rs:6:1
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] const unsafe extern fn bar1() {}
|
LL | const unsafe extern fn bar1() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
||||||
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `const extern fn` definitions are unstable
|
error[E0658]: `const extern fn` definitions are unstable
|
||||||
--> $DIR/feature-gate-const_extern_fn.rs:7:15
|
--> $DIR/feature-gate-const_extern_fn.rs:7:1
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] const unsafe extern "C" fn bar2() {}
|
LL | const unsafe extern "C" fn bar2() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
||||||
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: `const extern fn` definitions are unstable
|
error[E0658]: `const extern fn` definitions are unstable
|
||||||
--> $DIR/feature-gate-const_extern_fn.rs:9:15
|
--> $DIR/feature-gate-const_extern_fn.rs:8:1
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] const unsafe extern "Rust" fn bar3() {}
|
LL | const unsafe extern "Rust" fn bar3() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
= note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
||||||
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
= help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
|
||||||
|
|
|
@ -4,5 +4,4 @@ fn main() {}
|
||||||
fn container() {
|
fn container() {
|
||||||
const extern "Rust" PUT_ANYTHING_YOU_WANT_HERE bug() -> usize { 1 }
|
const extern "Rust" PUT_ANYTHING_YOU_WANT_HERE bug() -> usize { 1 }
|
||||||
//~^ ERROR expected `fn`
|
//~^ ERROR expected `fn`
|
||||||
//~| ERROR `const extern fn` definitions are unstable
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,5 @@ error: expected `fn`, found `PUT_ANYTHING_YOU_WANT_HERE`
|
||||||
LL | const extern "Rust" PUT_ANYTHING_YOU_WANT_HERE bug() -> usize { 1 }
|
LL | const extern "Rust" PUT_ANYTHING_YOU_WANT_HERE bug() -> usize { 1 }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `fn`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `fn`
|
||||||
|
|
||||||
error[E0658]: `const extern fn` definitions are unstable
|
error: aborting due to previous error
|
||||||
--> $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: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
|
|
||||||
= 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`.
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// These are forbidden occurrences of label-break-value
|
// These are forbidden occurrences of label-break-value
|
||||||
|
|
||||||
fn labeled_unsafe() {
|
fn labeled_unsafe() {
|
||||||
unsafe 'b: {} //~ ERROR expected one of `extern`, `fn`, or `{`
|
unsafe 'b: {} //~ ERROR expected `{`, found `'b`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn labeled_if() {
|
fn labeled_if() {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected one of `extern`, `fn`, or `{`, found `'b`
|
error: expected `{`, found `'b`
|
||||||
--> $DIR/label_break_value_illegal_uses.rs:6:12
|
--> $DIR/label_break_value_illegal_uses.rs:6:12
|
||||||
|
|
|
|
||||||
LL | unsafe 'b: {}
|
LL | unsafe 'b: {}
|
||||||
| ^^ expected one of `extern`, `fn`, or `{`
|
| ^^ expected `{`
|
||||||
|
|
||||||
error: expected `{`, found `'b`
|
error: expected `{`, found `'b`
|
||||||
--> $DIR/label_break_value_illegal_uses.rs:10:13
|
--> $DIR/label_break_value_illegal_uses.rs:10:13
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
extern crte foo; //~ ERROR expected one of `crate`, `fn`, or `{`, found `crte`
|
extern crte foo; //~ ERROR expected one of `crate` or `{`, found `crte`
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected one of `crate`, `fn`, or `{`, found `crte`
|
error: expected one of `crate` or `{`, found `crte`
|
||||||
--> $DIR/extern-crate-unexpected-token.rs:1:8
|
--> $DIR/extern-crate-unexpected-token.rs:1:8
|
||||||
|
|
|
|
||||||
LL | extern crte foo;
|
LL | extern crte foo;
|
||||||
| ^^^^ expected one of `crate`, `fn`, or `{`
|
| ^^^^ expected one of `crate` or `{`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// Verifies that the expected token errors for `extern crate` are
|
// Verifies that the expected token errors for `extern crate` are raised.
|
||||||
// raised
|
|
||||||
|
|
||||||
extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found keyword `mod`
|
extern "C" mod foo; //~ERROR expected `{`, found keyword `mod`
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected one of `fn` or `{`, found keyword `mod`
|
error: expected `{`, found keyword `mod`
|
||||||
--> $DIR/extern-expected-fn-or-brace.rs:4:12
|
--> $DIR/extern-expected-fn-or-brace.rs:3:12
|
||||||
|
|
|
|
||||||
LL | extern "C" mod foo;
|
LL | extern "C" mod foo;
|
||||||
| ^^^ expected one of `fn` or `{`
|
| ^^^ expected `{`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ fn main() {
|
||||||
unsafe fn ff2() {} // OK.
|
unsafe fn ff2() {} // OK.
|
||||||
const fn ff3() {} // OK.
|
const fn ff3() {} // OK.
|
||||||
extern "C" fn ff4() {} // OK.
|
extern "C" fn ff4() {} // OK.
|
||||||
const /* async */ unsafe extern "C" fn ff5() {} // OK.
|
const async unsafe extern "C" fn ff5() {} // OK.
|
||||||
//^ FIXME(Centril): `async` should be legal syntactically, ensure it's illegal semantically.
|
//~^ ERROR functions cannot be both `const` and `async`
|
||||||
|
|
||||||
trait X {
|
trait X {
|
||||||
async fn ft1(); //~ ERROR trait fns cannot be declared `async`
|
async fn ft1(); //~ ERROR trait fns cannot be declared `async`
|
||||||
|
@ -21,6 +21,7 @@ fn main() {
|
||||||
const async unsafe extern "C" fn ft5();
|
const async unsafe extern "C" fn ft5();
|
||||||
//~^ ERROR trait fns cannot be declared `async`
|
//~^ ERROR trait fns cannot be declared `async`
|
||||||
//~| ERROR trait fns cannot be declared const
|
//~| ERROR trait fns cannot be declared const
|
||||||
|
//~| ERROR functions cannot be both `const` and `async`
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Y;
|
struct Y;
|
||||||
|
@ -34,6 +35,7 @@ fn main() {
|
||||||
//~^ ERROR trait fns cannot be declared `async`
|
//~^ ERROR trait fns cannot be declared `async`
|
||||||
//~| ERROR trait fns cannot be declared const
|
//~| ERROR trait fns cannot be declared const
|
||||||
//~| ERROR method `ft5` has an incompatible type for trait
|
//~| ERROR method `ft5` has an incompatible type for trait
|
||||||
|
//~| ERROR functions cannot be both `const` and `async`
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Y {
|
impl Y {
|
||||||
|
@ -41,7 +43,8 @@ fn main() {
|
||||||
unsafe fn fi2() {} // OK.
|
unsafe fn fi2() {} // OK.
|
||||||
const fn fi3() {} // OK.
|
const fn fi3() {} // OK.
|
||||||
extern "C" fn fi4() {} // OK.
|
extern "C" fn fi4() {} // OK.
|
||||||
const async unsafe extern "C" fn fi5() {} // OK.
|
const async unsafe extern "C" fn fi5() {}
|
||||||
|
//~^ ERROR functions cannot be both `const` and `async`
|
||||||
}
|
}
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
|
@ -50,5 +53,6 @@ fn main() {
|
||||||
const fn fe3(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
const fn fe3(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
||||||
extern "C" fn fe4(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
extern "C" fn fe4(); //~ ERROR functions in `extern` blocks cannot have qualifiers
|
||||||
const async unsafe extern "C" fn fe5(); //~ ERROR functions in `extern` blocks
|
const async unsafe extern "C" fn fe5(); //~ ERROR functions in `extern` blocks
|
||||||
|
//~^ ERROR functions cannot be both `const` and `async`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
error: functions cannot be both `const` and `async`
|
||||||
|
--> $DIR/fn-header-semantic-fail.rs:13:5
|
||||||
|
|
|
||||||
|
LL | const async unsafe extern "C" fn ff5() {} // OK.
|
||||||
|
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
| | |
|
||||||
|
| | `async` because of this
|
||||||
|
| `const` because of this
|
||||||
|
|
||||||
error[E0706]: trait fns cannot be declared `async`
|
error[E0706]: trait fns cannot be declared `async`
|
||||||
--> $DIR/fn-header-semantic-fail.rs:17:9
|
--> $DIR/fn-header-semantic-fail.rs:17:9
|
||||||
|
|
|
|
||||||
|
@ -32,8 +41,17 @@ LL | const async unsafe extern "C" fn ft5();
|
||||||
= note: `async` trait functions are not currently supported
|
= note: `async` trait functions are not currently supported
|
||||||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
||||||
|
|
||||||
|
error: functions cannot be both `const` and `async`
|
||||||
|
--> $DIR/fn-header-semantic-fail.rs:21:9
|
||||||
|
|
|
||||||
|
LL | const async unsafe extern "C" fn ft5();
|
||||||
|
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
| | |
|
||||||
|
| | `async` because of this
|
||||||
|
| `const` because of this
|
||||||
|
|
||||||
error[E0706]: trait fns cannot be declared `async`
|
error[E0706]: trait fns cannot be declared `async`
|
||||||
--> $DIR/fn-header-semantic-fail.rs:28:9
|
--> $DIR/fn-header-semantic-fail.rs:29:9
|
||||||
|
|
|
|
||||||
LL | async fn ft1() {}
|
LL | async fn ft1() {}
|
||||||
| -----^^^^^^^^^^^^
|
| -----^^^^^^^^^^^^
|
||||||
|
@ -44,19 +62,19 @@ LL | async fn ft1() {}
|
||||||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
||||||
|
|
||||||
error[E0379]: trait fns cannot be declared const
|
error[E0379]: trait fns cannot be declared const
|
||||||
--> $DIR/fn-header-semantic-fail.rs:31:9
|
--> $DIR/fn-header-semantic-fail.rs:32:9
|
||||||
|
|
|
|
||||||
LL | const fn ft3() {}
|
LL | const fn ft3() {}
|
||||||
| ^^^^^ trait fns cannot be const
|
| ^^^^^ trait fns cannot be const
|
||||||
|
|
||||||
error[E0379]: trait fns cannot be declared const
|
error[E0379]: trait fns cannot be declared const
|
||||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn ft5() {}
|
LL | const async unsafe extern "C" fn ft5() {}
|
||||||
| ^^^^^ trait fns cannot be const
|
| ^^^^^ trait fns cannot be const
|
||||||
|
|
||||||
error[E0706]: trait fns cannot be declared `async`
|
error[E0706]: trait fns cannot be declared `async`
|
||||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn ft5() {}
|
LL | const async unsafe extern "C" fn ft5() {}
|
||||||
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -66,8 +84,26 @@ LL | const async unsafe extern "C" fn ft5() {}
|
||||||
= note: `async` trait functions are not currently supported
|
= note: `async` trait functions are not currently supported
|
||||||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
||||||
|
|
||||||
|
error: functions cannot be both `const` and `async`
|
||||||
|
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||||
|
|
|
||||||
|
LL | const async unsafe extern "C" fn ft5() {}
|
||||||
|
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
| | |
|
||||||
|
| | `async` because of this
|
||||||
|
| `const` because of this
|
||||||
|
|
||||||
|
error: functions cannot be both `const` and `async`
|
||||||
|
--> $DIR/fn-header-semantic-fail.rs:46:9
|
||||||
|
|
|
||||||
|
LL | const async unsafe extern "C" fn fi5() {}
|
||||||
|
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
| | |
|
||||||
|
| | `async` because of this
|
||||||
|
| `const` because of this
|
||||||
|
|
||||||
error: functions in `extern` blocks cannot have qualifiers
|
error: functions in `extern` blocks cannot have qualifiers
|
||||||
--> $DIR/fn-header-semantic-fail.rs:48:18
|
--> $DIR/fn-header-semantic-fail.rs:51:18
|
||||||
|
|
|
|
||||||
LL | extern {
|
LL | extern {
|
||||||
| ------ in this `extern` block
|
| ------ in this `extern` block
|
||||||
|
@ -77,7 +113,7 @@ LL | async fn fe1();
|
||||||
| help: remove the qualifiers: `fn`
|
| help: remove the qualifiers: `fn`
|
||||||
|
|
||||||
error: functions in `extern` blocks cannot have qualifiers
|
error: functions in `extern` blocks cannot have qualifiers
|
||||||
--> $DIR/fn-header-semantic-fail.rs:49:19
|
--> $DIR/fn-header-semantic-fail.rs:52:19
|
||||||
|
|
|
|
||||||
LL | extern {
|
LL | extern {
|
||||||
| ------ in this `extern` block
|
| ------ in this `extern` block
|
||||||
|
@ -88,7 +124,7 @@ LL | unsafe fn fe2();
|
||||||
| help: remove the qualifiers: `fn`
|
| help: remove the qualifiers: `fn`
|
||||||
|
|
||||||
error: functions in `extern` blocks cannot have qualifiers
|
error: functions in `extern` blocks cannot have qualifiers
|
||||||
--> $DIR/fn-header-semantic-fail.rs:50:18
|
--> $DIR/fn-header-semantic-fail.rs:53:18
|
||||||
|
|
|
|
||||||
LL | extern {
|
LL | extern {
|
||||||
| ------ in this `extern` block
|
| ------ in this `extern` block
|
||||||
|
@ -99,7 +135,7 @@ LL | const fn fe3();
|
||||||
| help: remove the qualifiers: `fn`
|
| help: remove the qualifiers: `fn`
|
||||||
|
|
||||||
error: functions in `extern` blocks cannot have qualifiers
|
error: functions in `extern` blocks cannot have qualifiers
|
||||||
--> $DIR/fn-header-semantic-fail.rs:51:23
|
--> $DIR/fn-header-semantic-fail.rs:54:23
|
||||||
|
|
|
|
||||||
LL | extern {
|
LL | extern {
|
||||||
| ------ in this `extern` block
|
| ------ in this `extern` block
|
||||||
|
@ -110,7 +146,7 @@ LL | extern "C" fn fe4();
|
||||||
| help: remove the qualifiers: `fn`
|
| help: remove the qualifiers: `fn`
|
||||||
|
|
||||||
error: functions in `extern` blocks cannot have qualifiers
|
error: functions in `extern` blocks cannot have qualifiers
|
||||||
--> $DIR/fn-header-semantic-fail.rs:52:42
|
--> $DIR/fn-header-semantic-fail.rs:55:42
|
||||||
|
|
|
|
||||||
LL | extern {
|
LL | extern {
|
||||||
| ------ in this `extern` block
|
| ------ in this `extern` block
|
||||||
|
@ -120,8 +156,17 @@ LL | const async unsafe extern "C" fn fe5();
|
||||||
| |
|
| |
|
||||||
| help: remove the qualifiers: `fn`
|
| help: remove the qualifiers: `fn`
|
||||||
|
|
||||||
|
error: functions cannot be both `const` and `async`
|
||||||
|
--> $DIR/fn-header-semantic-fail.rs:55:9
|
||||||
|
|
|
||||||
|
LL | const async unsafe extern "C" fn fe5();
|
||||||
|
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
| | |
|
||||||
|
| | `async` because of this
|
||||||
|
| `const` because of this
|
||||||
|
|
||||||
error[E0053]: method `ft1` has an incompatible type for trait
|
error[E0053]: method `ft1` has an incompatible type for trait
|
||||||
--> $DIR/fn-header-semantic-fail.rs:28:24
|
--> $DIR/fn-header-semantic-fail.rs:29:24
|
||||||
|
|
|
|
||||||
LL | async fn ft1();
|
LL | async fn ft1();
|
||||||
| - type in trait
|
| - type in trait
|
||||||
|
@ -136,7 +181,7 @@ LL | async fn ft1() {}
|
||||||
found fn pointer `fn() -> impl std::future::Future`
|
found fn pointer `fn() -> impl std::future::Future`
|
||||||
|
|
||||||
error[E0053]: method `ft5` has an incompatible type for trait
|
error[E0053]: method `ft5` has an incompatible type for trait
|
||||||
--> $DIR/fn-header-semantic-fail.rs:33:48
|
--> $DIR/fn-header-semantic-fail.rs:34:48
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn ft5();
|
LL | const async unsafe extern "C" fn ft5();
|
||||||
| - type in trait
|
| - type in trait
|
||||||
|
@ -150,7 +195,7 @@ LL | const async unsafe extern "C" fn ft5() {}
|
||||||
= note: expected fn pointer `unsafe extern "C" fn()`
|
= note: expected fn pointer `unsafe extern "C" fn()`
|
||||||
found fn pointer `unsafe extern "C" fn() -> impl std::future::Future`
|
found fn pointer `unsafe extern "C" fn() -> impl std::future::Future`
|
||||||
|
|
||||||
error: aborting due to 15 previous errors
|
error: aborting due to 20 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0053, E0379, E0706.
|
Some errors have detailed explanations: E0053, E0379, E0706.
|
||||||
For more information about an error, try `rustc --explain E0053`.
|
For more information about an error, try `rustc --explain E0053`.
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
// check-pass
|
// check-pass
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(const_extern_fn)]
|
|
||||||
//^ FIXME(Centril): move check to ast_validation.
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
#[cfg(FALSE)]
|
#[cfg(FALSE)]
|
||||||
|
@ -14,8 +11,7 @@ fn syntax() {
|
||||||
unsafe fn f();
|
unsafe fn f();
|
||||||
const fn f();
|
const fn f();
|
||||||
extern "C" fn f();
|
extern "C" fn f();
|
||||||
const /* async */ unsafe extern "C" fn f();
|
const async unsafe extern "C" fn f();
|
||||||
//^ FIXME(Centril): `async` should be legal syntactically.
|
|
||||||
|
|
||||||
trait X {
|
trait X {
|
||||||
async fn f();
|
async fn f();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
trait T {
|
trait T {
|
||||||
extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found keyword `unsafe`
|
extern "Rust" unsafe fn foo(); //~ ERROR expected one of `async`, `const`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
error: expected `fn`, found keyword `unsafe`
|
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found keyword `extern`
|
||||||
--> $DIR/issue-19398.rs:2:19
|
--> $DIR/issue-19398.rs:2:5
|
||||||
|
|
|
|
||||||
|
LL | trait T {
|
||||||
|
| - expected one of 10 possible tokens
|
||||||
LL | extern "Rust" unsafe fn foo();
|
LL | extern "Rust" unsafe fn foo();
|
||||||
| ^^^^^^ expected `fn`
|
| ^^^^^^ unexpected token
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,4 @@ fn main() {
|
||||||
std::mem::transmute::<f32, u32>(1.0);
|
std::mem::transmute::<f32, u32>(1.0);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
//~^^^ ERROR expected one of `extern`, `fn`, or `{`, found `std`
|
//~^^^ ERROR expected `{`, found `std`
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected one of `extern`, `fn`, or `{`, found `std`
|
error: expected `{`, found `std`
|
||||||
--> $DIR/unsafe-block-without-braces.rs:3:9
|
--> $DIR/unsafe-block-without-braces.rs:3:9
|
||||||
|
|
|
|
||||||
LL | unsafe //{
|
LL | unsafe //{
|
||||||
| - expected one of `extern`, `fn`, or `{`
|
| - expected `{`
|
||||||
LL | std::mem::transmute::<f32, u32>(1.0);
|
LL | std::mem::transmute::<f32, u32>(1.0);
|
||||||
| ^^^ unexpected token
|
| ^^^ unexpected token
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue