Rollup merge of #91531 - notriddle:notriddle/issue-87647-expected-semicolon, r=estebank
Do not add `;` to expected tokens list when it's wrong There's a few spots where semicolons are checked for to do error recovery, and should not be suggested (or checked for other stuff). Fixes #87647
This commit is contained in:
commit
87f2c51dcd
19 changed files with 165 additions and 51 deletions
|
@ -1,4 +1,4 @@
|
||||||
use super::{AttrWrapper, Capturing, ForceCollect, Parser, PathStyle};
|
use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast::attr;
|
use rustc_ast::attr;
|
||||||
use rustc_ast::token::{self, Nonterminal};
|
use rustc_ast::token::{self, Nonterminal};
|
||||||
|
@ -177,7 +177,7 @@ impl<'a> Parser<'a> {
|
||||||
AttrWrapper::empty(),
|
AttrWrapper::empty(),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|_| true,
|
FnParseMode { req_name: |_| true, req_body: true },
|
||||||
ForceCollect::No,
|
ForceCollect::No,
|
||||||
) {
|
) {
|
||||||
Ok(Some(item)) => {
|
Ok(Some(item)) => {
|
||||||
|
|
|
@ -1129,7 +1129,8 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn maybe_consume_incorrect_semicolon(&mut self, items: &[P<Item>]) -> bool {
|
pub fn maybe_consume_incorrect_semicolon(&mut self, items: &[P<Item>]) -> bool {
|
||||||
if self.eat(&token::Semi) {
|
if self.token.kind == TokenKind::Semi {
|
||||||
|
self.bump();
|
||||||
let mut err = self.struct_span_err(self.prev_token.span, "expected item, found `;`");
|
let mut err = self.struct_span_err(self.prev_token.span, "expected item, found `;`");
|
||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
|
|
|
@ -78,16 +78,17 @@ pub(super) type ItemInfo = (Ident, ItemKind);
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
pub fn parse_item(&mut self, force_collect: ForceCollect) -> PResult<'a, Option<P<Item>>> {
|
pub fn parse_item(&mut self, force_collect: ForceCollect) -> PResult<'a, Option<P<Item>>> {
|
||||||
self.parse_item_(|_| true, force_collect).map(|i| i.map(P))
|
let fn_parse_mode = FnParseMode { req_name: |_| true, req_body: true };
|
||||||
|
self.parse_item_(fn_parse_mode, force_collect).map(|i| i.map(P))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item_(
|
fn parse_item_(
|
||||||
&mut self,
|
&mut self,
|
||||||
req_name: ReqName,
|
fn_parse_mode: FnParseMode,
|
||||||
force_collect: ForceCollect,
|
force_collect: ForceCollect,
|
||||||
) -> PResult<'a, Option<Item>> {
|
) -> PResult<'a, Option<Item>> {
|
||||||
let attrs = self.parse_outer_attributes()?;
|
let attrs = self.parse_outer_attributes()?;
|
||||||
self.parse_item_common(attrs, true, false, req_name, force_collect)
|
self.parse_item_common(attrs, true, false, fn_parse_mode, force_collect)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn parse_item_common(
|
pub(super) fn parse_item_common(
|
||||||
|
@ -95,7 +96,7 @@ impl<'a> Parser<'a> {
|
||||||
attrs: AttrWrapper,
|
attrs: AttrWrapper,
|
||||||
mac_allowed: bool,
|
mac_allowed: bool,
|
||||||
attrs_allowed: bool,
|
attrs_allowed: bool,
|
||||||
req_name: ReqName,
|
fn_parse_mode: FnParseMode,
|
||||||
force_collect: ForceCollect,
|
force_collect: ForceCollect,
|
||||||
) -> PResult<'a, Option<Item>> {
|
) -> PResult<'a, Option<Item>> {
|
||||||
// Don't use `maybe_whole` so that we have precise control
|
// Don't use `maybe_whole` so that we have precise control
|
||||||
|
@ -113,7 +114,8 @@ impl<'a> Parser<'a> {
|
||||||
let mut unclosed_delims = vec![];
|
let mut unclosed_delims = vec![];
|
||||||
let item =
|
let item =
|
||||||
self.collect_tokens_trailing_token(attrs, force_collect, |this: &mut Self, attrs| {
|
self.collect_tokens_trailing_token(attrs, force_collect, |this: &mut Self, attrs| {
|
||||||
let item = this.parse_item_common_(attrs, mac_allowed, attrs_allowed, req_name);
|
let item =
|
||||||
|
this.parse_item_common_(attrs, mac_allowed, attrs_allowed, fn_parse_mode);
|
||||||
unclosed_delims.append(&mut this.unclosed_delims);
|
unclosed_delims.append(&mut this.unclosed_delims);
|
||||||
Ok((item?, TrailingToken::None))
|
Ok((item?, TrailingToken::None))
|
||||||
})?;
|
})?;
|
||||||
|
@ -127,12 +129,13 @@ impl<'a> Parser<'a> {
|
||||||
mut attrs: Vec<Attribute>,
|
mut attrs: Vec<Attribute>,
|
||||||
mac_allowed: bool,
|
mac_allowed: bool,
|
||||||
attrs_allowed: bool,
|
attrs_allowed: bool,
|
||||||
req_name: ReqName,
|
fn_parse_mode: FnParseMode,
|
||||||
) -> PResult<'a, Option<Item>> {
|
) -> PResult<'a, Option<Item>> {
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
let vis = self.parse_visibility(FollowedByType::No)?;
|
let vis = self.parse_visibility(FollowedByType::No)?;
|
||||||
let mut def = self.parse_defaultness();
|
let mut def = self.parse_defaultness();
|
||||||
let kind = self.parse_item_kind(&mut attrs, mac_allowed, lo, &vis, &mut def, req_name)?;
|
let kind =
|
||||||
|
self.parse_item_kind(&mut attrs, mac_allowed, lo, &vis, &mut def, fn_parse_mode)?;
|
||||||
if let Some((ident, kind)) = kind {
|
if let Some((ident, kind)) = kind {
|
||||||
self.error_on_unconsumed_default(def, &kind);
|
self.error_on_unconsumed_default(def, &kind);
|
||||||
let span = lo.to(self.prev_token.span);
|
let span = lo.to(self.prev_token.span);
|
||||||
|
@ -192,7 +195,7 @@ impl<'a> Parser<'a> {
|
||||||
lo: Span,
|
lo: Span,
|
||||||
vis: &Visibility,
|
vis: &Visibility,
|
||||||
def: &mut Defaultness,
|
def: &mut Defaultness,
|
||||||
req_name: ReqName,
|
fn_parse_mode: FnParseMode,
|
||||||
) -> PResult<'a, Option<ItemInfo>> {
|
) -> PResult<'a, Option<ItemInfo>> {
|
||||||
let def_final = def == &Defaultness::Final;
|
let def_final = def == &Defaultness::Final;
|
||||||
let mut def = || mem::replace(def, Defaultness::Final);
|
let mut def = || mem::replace(def, Defaultness::Final);
|
||||||
|
@ -219,7 +222,7 @@ impl<'a> Parser<'a> {
|
||||||
(Ident::empty(), ItemKind::Use(tree))
|
(Ident::empty(), ItemKind::Use(tree))
|
||||||
} else if self.check_fn_front_matter(def_final) {
|
} else if self.check_fn_front_matter(def_final) {
|
||||||
// FUNCTION ITEM
|
// FUNCTION ITEM
|
||||||
let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?;
|
let (ident, sig, generics, body) = self.parse_fn(attrs, fn_parse_mode, lo)?;
|
||||||
(ident, ItemKind::Fn(Box::new(Fn { defaultness: def(), sig, generics, body })))
|
(ident, ItemKind::Fn(Box::new(Fn { defaultness: def(), sig, generics, body })))
|
||||||
} else if self.eat_keyword(kw::Extern) {
|
} else if self.eat_keyword(kw::Extern) {
|
||||||
if self.eat_keyword(kw::Crate) {
|
if self.eat_keyword(kw::Crate) {
|
||||||
|
@ -733,23 +736,26 @@ impl<'a> Parser<'a> {
|
||||||
&mut self,
|
&mut self,
|
||||||
force_collect: ForceCollect,
|
force_collect: ForceCollect,
|
||||||
) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
||||||
self.parse_assoc_item(|_| true, force_collect)
|
let fn_parse_mode = FnParseMode { req_name: |_| true, req_body: true };
|
||||||
|
self.parse_assoc_item(fn_parse_mode, force_collect)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_trait_item(
|
pub fn parse_trait_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
force_collect: ForceCollect,
|
force_collect: ForceCollect,
|
||||||
) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
||||||
self.parse_assoc_item(|edition| edition >= Edition::Edition2018, force_collect)
|
let fn_parse_mode =
|
||||||
|
FnParseMode { req_name: |edition| edition >= Edition::Edition2018, req_body: false };
|
||||||
|
self.parse_assoc_item(fn_parse_mode, force_collect)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses associated items.
|
/// Parses associated items.
|
||||||
fn parse_assoc_item(
|
fn parse_assoc_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
req_name: ReqName,
|
fn_parse_mode: FnParseMode,
|
||||||
force_collect: ForceCollect,
|
force_collect: ForceCollect,
|
||||||
) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
||||||
Ok(self.parse_item_(req_name, force_collect)?.map(
|
Ok(self.parse_item_(fn_parse_mode, force_collect)?.map(
|
||||||
|Item { attrs, id, span, vis, ident, kind, tokens }| {
|
|Item { attrs, id, span, vis, ident, kind, tokens }| {
|
||||||
let kind = match AssocItemKind::try_from(kind) {
|
let kind = match AssocItemKind::try_from(kind) {
|
||||||
Ok(kind) => kind,
|
Ok(kind) => kind,
|
||||||
|
@ -944,7 +950,8 @@ impl<'a> Parser<'a> {
|
||||||
&mut self,
|
&mut self,
|
||||||
force_collect: ForceCollect,
|
force_collect: ForceCollect,
|
||||||
) -> PResult<'a, Option<Option<P<ForeignItem>>>> {
|
) -> PResult<'a, Option<Option<P<ForeignItem>>>> {
|
||||||
Ok(self.parse_item_(|_| true, force_collect)?.map(
|
let fn_parse_mode = FnParseMode { req_name: |_| true, req_body: false };
|
||||||
|
Ok(self.parse_item_(fn_parse_mode, force_collect)?.map(
|
||||||
|Item { attrs, id, span, vis, ident, kind, tokens }| {
|
|Item { attrs, id, span, vis, ident, kind, tokens }| {
|
||||||
let kind = match ForeignItemKind::try_from(kind) {
|
let kind = match ForeignItemKind::try_from(kind) {
|
||||||
Ok(kind) => kind,
|
Ok(kind) => kind,
|
||||||
|
@ -1484,7 +1491,8 @@ impl<'a> Parser<'a> {
|
||||||
if !is_raw && ident.is_reserved() {
|
if !is_raw && ident.is_reserved() {
|
||||||
let err = if self.check_fn_front_matter(false) {
|
let err = if self.check_fn_front_matter(false) {
|
||||||
// We use `parse_fn` to get a span for the function
|
// We use `parse_fn` to get a span for the function
|
||||||
if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) {
|
let fn_parse_mode = FnParseMode { req_name: |_| true, req_body: true };
|
||||||
|
if let Err(mut db) = self.parse_fn(&mut Vec::new(), fn_parse_mode, lo) {
|
||||||
db.delay_as_bug();
|
db.delay_as_bug();
|
||||||
}
|
}
|
||||||
let mut err = self.struct_span_err(
|
let mut err = self.struct_span_err(
|
||||||
|
@ -1698,25 +1706,82 @@ impl<'a> Parser<'a> {
|
||||||
/// The parsing configuration used to parse a parameter list (see `parse_fn_params`).
|
/// The parsing configuration used to parse a parameter list (see `parse_fn_params`).
|
||||||
///
|
///
|
||||||
/// The function decides if, per-parameter `p`, `p` must have a pattern or just a type.
|
/// The function decides if, per-parameter `p`, `p` must have a pattern or just a type.
|
||||||
|
///
|
||||||
|
/// This function pointer accepts an edition, because in edition 2015, trait declarations
|
||||||
|
/// were allowed to omit parameter names. In 2018, they became required.
|
||||||
type ReqName = fn(Edition) -> bool;
|
type ReqName = fn(Edition) -> bool;
|
||||||
|
|
||||||
|
/// Parsing configuration for functions.
|
||||||
|
///
|
||||||
|
/// The syntax of function items is slightly different within trait definitions,
|
||||||
|
/// impl blocks, and modules. It is still parsed using the same code, just with
|
||||||
|
/// different flags set, so that even when the input is wrong and produces a parse
|
||||||
|
/// error, it still gets into the AST and the rest of the parser and
|
||||||
|
/// type checker can run.
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub(crate) struct FnParseMode {
|
||||||
|
/// A function pointer that decides if, per-parameter `p`, `p` must have a
|
||||||
|
/// pattern or just a type. This field affects parsing of the parameters list.
|
||||||
|
///
|
||||||
|
/// ```text
|
||||||
|
/// fn foo(alef: A) -> X { X::new() }
|
||||||
|
/// -----^^ affects parsing this part of the function signature
|
||||||
|
/// |
|
||||||
|
/// if req_name returns false, then this name is optional
|
||||||
|
///
|
||||||
|
/// fn bar(A) -> X;
|
||||||
|
/// ^
|
||||||
|
/// |
|
||||||
|
/// if req_name returns true, this is an error
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// Calling this function pointer should only return false if:
|
||||||
|
///
|
||||||
|
/// * The item is being parsed inside of a trait definition.
|
||||||
|
/// Within an impl block or a module, it should always evaluate
|
||||||
|
/// to true.
|
||||||
|
/// * The span is from Edition 2015. In particular, you can get a
|
||||||
|
/// 2015 span inside a 2021 crate using macros.
|
||||||
|
pub req_name: ReqName,
|
||||||
|
/// If this flag is set to `true`, then plain, semicolon-terminated function
|
||||||
|
/// prototypes are not allowed here.
|
||||||
|
///
|
||||||
|
/// ```text
|
||||||
|
/// fn foo(alef: A) -> X { X::new() }
|
||||||
|
/// ^^^^^^^^^^^^
|
||||||
|
/// |
|
||||||
|
/// this is always allowed
|
||||||
|
///
|
||||||
|
/// fn bar(alef: A, bet: B) -> X;
|
||||||
|
/// ^
|
||||||
|
/// |
|
||||||
|
/// if req_body is set to true, this is an error
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// This field should only be set to false if the item is inside of a trait
|
||||||
|
/// definition or extern block. Within an impl block or a module, it should
|
||||||
|
/// always be set to true.
|
||||||
|
pub req_body: bool,
|
||||||
|
}
|
||||||
|
|
||||||
/// Parsing of functions and methods.
|
/// Parsing of functions and methods.
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
/// Parse a function starting from the front matter (`const ...`) to the body `{ ... }` or `;`.
|
/// Parse a function starting from the front matter (`const ...`) to the body `{ ... }` or `;`.
|
||||||
fn parse_fn(
|
fn parse_fn(
|
||||||
&mut self,
|
&mut self,
|
||||||
attrs: &mut Vec<Attribute>,
|
attrs: &mut Vec<Attribute>,
|
||||||
req_name: ReqName,
|
fn_parse_mode: FnParseMode,
|
||||||
sig_lo: Span,
|
sig_lo: Span,
|
||||||
) -> PResult<'a, (Ident, FnSig, Generics, Option<P<Block>>)> {
|
) -> PResult<'a, (Ident, FnSig, Generics, Option<P<Block>>)> {
|
||||||
let header = self.parse_fn_front_matter()?; // `const ... fn`
|
let header = self.parse_fn_front_matter()?; // `const ... fn`
|
||||||
let ident = self.parse_ident()?; // `foo`
|
let ident = self.parse_ident()?; // `foo`
|
||||||
let mut generics = self.parse_generics()?; // `<'a, T, ...>`
|
let mut generics = self.parse_generics()?; // `<'a, T, ...>`
|
||||||
let decl = self.parse_fn_decl(req_name, AllowPlus::Yes, RecoverReturnSign::Yes)?; // `(p: u8, ...)`
|
let decl =
|
||||||
|
self.parse_fn_decl(fn_parse_mode.req_name, AllowPlus::Yes, RecoverReturnSign::Yes)?; // `(p: u8, ...)`
|
||||||
generics.where_clause = self.parse_where_clause()?; // `where T: Ord`
|
generics.where_clause = self.parse_where_clause()?; // `where T: Ord`
|
||||||
|
|
||||||
let mut sig_hi = self.prev_token.span;
|
let mut sig_hi = self.prev_token.span;
|
||||||
let body = self.parse_fn_body(attrs, &ident, &mut sig_hi)?; // `;` or `{ ... }`.
|
let body = self.parse_fn_body(attrs, &ident, &mut sig_hi, fn_parse_mode.req_body)?; // `;` or `{ ... }`.
|
||||||
let fn_sig_span = sig_lo.to(sig_hi);
|
let fn_sig_span = sig_lo.to(sig_hi);
|
||||||
Ok((ident, FnSig { header, decl, span: fn_sig_span }, generics, body))
|
Ok((ident, FnSig { header, decl, span: fn_sig_span }, generics, body))
|
||||||
}
|
}
|
||||||
|
@ -1729,9 +1794,17 @@ impl<'a> Parser<'a> {
|
||||||
attrs: &mut Vec<Attribute>,
|
attrs: &mut Vec<Attribute>,
|
||||||
ident: &Ident,
|
ident: &Ident,
|
||||||
sig_hi: &mut Span,
|
sig_hi: &mut Span,
|
||||||
|
req_body: bool,
|
||||||
) -> PResult<'a, Option<P<Block>>> {
|
) -> PResult<'a, Option<P<Block>>> {
|
||||||
let (inner_attrs, body) = if self.eat(&token::Semi) {
|
let has_semi = if req_body {
|
||||||
|
self.token.kind == TokenKind::Semi
|
||||||
|
} else {
|
||||||
|
// Only include `;` in list of expected tokens if body is not required
|
||||||
|
self.check(&TokenKind::Semi)
|
||||||
|
};
|
||||||
|
let (inner_attrs, body) = if has_semi {
|
||||||
// Include the trailing semicolon in the span of the signature
|
// Include the trailing semicolon in the span of the signature
|
||||||
|
self.expect_semi()?;
|
||||||
*sig_hi = self.prev_token.span;
|
*sig_hi = self.prev_token.span;
|
||||||
(Vec::new(), None)
|
(Vec::new(), None)
|
||||||
} else if self.check(&token::OpenDelim(token::Brace)) || self.token.is_whole_block() {
|
} else if self.check(&token::OpenDelim(token::Brace)) || self.token.is_whole_block() {
|
||||||
|
@ -1752,9 +1825,12 @@ impl<'a> Parser<'a> {
|
||||||
.emit();
|
.emit();
|
||||||
(Vec::new(), Some(self.mk_block_err(span)))
|
(Vec::new(), Some(self.mk_block_err(span)))
|
||||||
} else {
|
} else {
|
||||||
if let Err(mut err) =
|
let expected = if req_body {
|
||||||
self.expected_one_of_not_found(&[], &[token::Semi, token::OpenDelim(token::Brace)])
|
&[token::OpenDelim(token::Brace)][..]
|
||||||
{
|
} else {
|
||||||
|
&[token::Semi, token::OpenDelim(token::Brace)]
|
||||||
|
};
|
||||||
|
if let Err(mut err) = self.expected_one_of_not_found(&[], &expected) {
|
||||||
if self.token.kind == token::CloseDelim(token::Brace) {
|
if self.token.kind == token::CloseDelim(token::Brace) {
|
||||||
// The enclosing `mod`, `trait` or `impl` is being closed, so keep the `fn` in
|
// The enclosing `mod`, `trait` or `impl` is being closed, so keep the `fn` in
|
||||||
// the AST for typechecking.
|
// the AST for typechecking.
|
||||||
|
|
|
@ -14,6 +14,7 @@ use crate::lexer::UnmatchedBrace;
|
||||||
pub use attr_wrapper::AttrWrapper;
|
pub use attr_wrapper::AttrWrapper;
|
||||||
pub use diagnostics::AttemptLocalParseRecovery;
|
pub use diagnostics::AttemptLocalParseRecovery;
|
||||||
use diagnostics::Error;
|
use diagnostics::Error;
|
||||||
|
pub(crate) use item::FnParseMode;
|
||||||
pub use pat::{RecoverColon, RecoverComma};
|
pub use pat::{RecoverColon, RecoverComma};
|
||||||
pub use path::PathStyle;
|
pub use path::PathStyle;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ use super::expr::LhsExpr;
|
||||||
use super::pat::RecoverComma;
|
use super::pat::RecoverComma;
|
||||||
use super::path::PathStyle;
|
use super::path::PathStyle;
|
||||||
use super::TrailingToken;
|
use super::TrailingToken;
|
||||||
use super::{AttrWrapper, BlockMode, ForceCollect, Parser, Restrictions, SemiColonMode};
|
use super::{
|
||||||
|
AttrWrapper, BlockMode, FnParseMode, ForceCollect, Parser, Restrictions, SemiColonMode,
|
||||||
|
};
|
||||||
use crate::maybe_whole;
|
use crate::maybe_whole;
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
|
@ -79,9 +81,13 @@ impl<'a> Parser<'a> {
|
||||||
} else {
|
} else {
|
||||||
self.parse_stmt_path_start(lo, attrs)
|
self.parse_stmt_path_start(lo, attrs)
|
||||||
}?
|
}?
|
||||||
} else if let Some(item) =
|
} else if let Some(item) = self.parse_item_common(
|
||||||
self.parse_item_common(attrs.clone(), false, true, |_| true, force_collect)?
|
attrs.clone(),
|
||||||
{
|
false,
|
||||||
|
true,
|
||||||
|
FnParseMode { req_name: |_| true, req_body: true },
|
||||||
|
force_collect,
|
||||||
|
)? {
|
||||||
// FIXME: Bad copy of attrs
|
// FIXME: Bad copy of attrs
|
||||||
self.mk_stmt(lo.to(item.span), StmtKind::Item(P(item)))
|
self.mk_stmt(lo.to(item.span), StmtKind::Item(P(item)))
|
||||||
} else if self.eat(&token::Semi) {
|
} else if self.eat(&token::Semi) {
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
fn foo() => impl Fn() => bool {
|
fn foo() => impl Fn() => bool {
|
||||||
//~^ ERROR return types are denoted using `->`
|
//~^ ERROR return types are denoted using `->`
|
||||||
//~| ERROR expected one of `+`, `->`, `::`, `;`, `where`, or `{`, found `=>`
|
//~| ERROR expected one of `+`, `->`, `::`, `where`, or `{`, found `=>`
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ error: return types are denoted using `->`
|
||||||
LL | fn foo() => impl Fn() => bool {
|
LL | fn foo() => impl Fn() => bool {
|
||||||
| ^^ help: use `->` instead
|
| ^^ help: use `->` instead
|
||||||
|
|
||||||
error: expected one of `+`, `->`, `::`, `;`, `where`, or `{`, found `=>`
|
error: expected one of `+`, `->`, `::`, `where`, or `{`, found `=>`
|
||||||
--> $DIR/fn-recover-return-sign2.rs:4:23
|
--> $DIR/fn-recover-return-sign2.rs:4:23
|
||||||
|
|
|
|
||||||
LL | fn foo() => impl Fn() => bool {
|
LL | fn foo() => impl Fn() => bool {
|
||||||
| ^^ expected one of `+`, `->`, `::`, `;`, `where`, or `{`
|
| ^^ expected one of `+`, `->`, `::`, `where`, or `{`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// to happen in #24780. For example, following should be an error:
|
// to happen in #24780. For example, following should be an error:
|
||||||
// expected one of ..., `>`, ... found `>`.
|
// expected one of ..., `>`, ... found `>`.
|
||||||
|
|
||||||
fn foo() -> Vec<usize>> { //~ ERROR expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
|
fn foo() -> Vec<usize>> { //~ ERROR expected one of `!`, `+`, `::`, `where`, or `{`, found `>`
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
|
error: expected one of `!`, `+`, `::`, `where`, or `{`, found `>`
|
||||||
--> $DIR/issue-24780.rs:5:23
|
--> $DIR/issue-24780.rs:5:23
|
||||||
|
|
|
|
||||||
LL | fn foo() -> Vec<usize>> {
|
LL | fn foo() -> Vec<usize>> {
|
||||||
| ^ expected one of `!`, `+`, `::`, `;`, `where`, or `{`
|
| ^ expected one of `!`, `+`, `::`, `where`, or `{`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ impl A {
|
||||||
//~^ ERROR cannot find type `A` in this scope
|
//~^ ERROR cannot find type `A` in this scope
|
||||||
fn b(self>
|
fn b(self>
|
||||||
//~^ ERROR expected one of `)`, `,`, or `:`, found `>`
|
//~^ ERROR expected one of `)`, `,`, or `:`, found `>`
|
||||||
//~| ERROR expected one of `->`, `;`, `where`, or `{`, found `>`
|
//~| ERROR expected one of `->`, `where`, or `{`, found `>`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -6,14 +6,14 @@ LL | fn b(self>
|
||||||
| |
|
| |
|
||||||
| unclosed delimiter
|
| unclosed delimiter
|
||||||
|
|
||||||
error: expected one of `->`, `;`, `where`, or `{`, found `>`
|
error: expected one of `->`, `where`, or `{`, found `>`
|
||||||
--> $DIR/issue-58856-1.rs:3:14
|
--> $DIR/issue-58856-1.rs:3:14
|
||||||
|
|
|
|
||||||
LL | impl A {
|
LL | impl A {
|
||||||
| - while parsing this item list starting here
|
| - while parsing this item list starting here
|
||||||
LL |
|
LL |
|
||||||
LL | fn b(self>
|
LL | fn b(self>
|
||||||
| ^ expected one of `->`, `;`, `where`, or `{`
|
| ^ expected one of `->`, `where`, or `{`
|
||||||
...
|
...
|
||||||
LL | }
|
LL | }
|
||||||
| - the item list ends here
|
| - the item list ends here
|
||||||
|
|
|
@ -13,11 +13,11 @@ LL | fn f(t:for<>t?)
|
||||||
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
|
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
|
||||||
| help: missing `,`
|
| help: missing `,`
|
||||||
|
|
||||||
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
|
error: expected one of `->`, `where`, or `{`, found `<eof>`
|
||||||
--> $DIR/issue-84148-1.rs:1:15
|
--> $DIR/issue-84148-1.rs:1:15
|
||||||
|
|
|
|
||||||
LL | fn f(t:for<>t?)
|
LL | fn f(t:for<>t?)
|
||||||
| ^ expected one of `->`, `;`, `where`, or `{`
|
| ^ expected one of `->`, `where`, or `{`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,11 @@ LL | fn f(t:for<>t?
|
||||||
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
|
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
|
||||||
| help: missing `,`
|
| help: missing `,`
|
||||||
|
|
||||||
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
|
error: expected one of `->`, `where`, or `{`, found `<eof>`
|
||||||
--> $DIR/issue-84148-2.rs:4:16
|
--> $DIR/issue-84148-2.rs:4:16
|
||||||
|
|
|
|
||||||
LL | fn f(t:for<>t?
|
LL | fn f(t:for<>t?
|
||||||
| ^ expected one of `->`, `;`, `where`, or `{`
|
| ^ expected one of `->`, `where`, or `{`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ struct Foo {}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
pub fn bar()
|
pub fn bar()
|
||||||
//~^ ERROR: expected `;`, found `}`
|
//~^ ERROR: associated function in `impl` without body
|
||||||
//~| ERROR: associated function in `impl` without body
|
|
||||||
}
|
}
|
||||||
|
//~^ERROR expected one of `->`, `where`, or `{`, found `}`
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
error: expected `;`, found `}`
|
error: expected one of `->`, `where`, or `{`, found `}`
|
||||||
--> $DIR/issue-87635.rs:4:17
|
--> $DIR/issue-87635.rs:6:1
|
||||||
|
|
|
|
||||||
LL | pub fn bar()
|
LL | pub fn bar()
|
||||||
| ^ help: add `;` here
|
| --- - expected one of `->`, `where`, or `{`
|
||||||
...
|
| |
|
||||||
|
| while parsing this `fn`
|
||||||
|
LL |
|
||||||
LL | }
|
LL | }
|
||||||
| - unexpected token
|
| ^ unexpected token
|
||||||
|
|
||||||
error: associated function in `impl` without body
|
error: associated function in `impl` without body
|
||||||
--> $DIR/issue-87635.rs:4:5
|
--> $DIR/issue-87635.rs:4:5
|
||||||
|
|
|
@ -22,11 +22,11 @@ error: expected one of `:` or `|`, found `)`
|
||||||
LL | fn main((ؼ
|
LL | fn main((ؼ
|
||||||
| ^ expected one of `:` or `|`
|
| ^ expected one of `:` or `|`
|
||||||
|
|
||||||
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
|
error: expected one of `->`, `where`, or `{`, found `<eof>`
|
||||||
--> $DIR/missing_right_paren.rs:3:11
|
--> $DIR/missing_right_paren.rs:3:11
|
||||||
|
|
|
|
||||||
LL | fn main((ؼ
|
LL | fn main((ؼ
|
||||||
| ^ expected one of `->`, `;`, `where`, or `{`
|
| ^ expected one of `->`, `where`, or `{`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
fn foo(); //~ERROR expected `;`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,9 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
fn foo() //~ERROR expected `;`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,10 @@
|
||||||
|
error: expected `;`, found `}`
|
||||||
|
--> $DIR/suggest-semicolon-for-fn-in-extern-block.rs:6:11
|
||||||
|
|
|
||||||
|
LL | fn foo()
|
||||||
|
| ^ help: add `;` here
|
||||||
|
LL | }
|
||||||
|
| - unexpected token
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue