parse: use `parse_item_common` in `parse_assoc_item_`.
This commit is contained in:
parent
a63f35daee
commit
a05c83b2eb
|
@ -865,15 +865,15 @@ pub fn parse_ast_fragment<'a>(
|
|||
}
|
||||
AstFragmentKind::TraitItems => {
|
||||
let mut items = SmallVec::new();
|
||||
while this.token != token::Eof {
|
||||
items.push(this.parse_trait_item(&mut false)?);
|
||||
while let Some(item) = this.parse_trait_item()? {
|
||||
items.extend(item);
|
||||
}
|
||||
AstFragment::TraitItems(items)
|
||||
}
|
||||
AstFragmentKind::ImplItems => {
|
||||
let mut items = SmallVec::new();
|
||||
while this.token != token::Eof {
|
||||
items.push(this.parse_impl_item(&mut false)?);
|
||||
while let Some(item) = this.parse_impl_item()? {
|
||||
items.extend(item);
|
||||
}
|
||||
AstFragment::ImplItems(items)
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ use super::{FollowedByType, Parser, PathStyle};
|
|||
use crate::maybe_whole;
|
||||
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, PResult, StashKey};
|
||||
use rustc_errors::{struct_span_err, Applicability, PResult, StashKey};
|
||||
use rustc_span::source_map::{self, Span};
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use syntax::ast::{self, AttrStyle, AttrVec, Attribute, Ident, DUMMY_NODE_ID};
|
||||
use syntax::ast::{AssocItem, AssocItemKind, Item, ItemKind, UseTree, UseTreeKind};
|
||||
use syntax::ast::{Async, Const, Defaultness, IsAuto, PathSegment, Unsafe};
|
||||
use syntax::ast::{AssocItem, AssocItemKind, ForeignItemKind, Item, ItemKind};
|
||||
use syntax::ast::{Async, Const, Defaultness, IsAuto, PathSegment, Unsafe, UseTree, UseTreeKind};
|
||||
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::{FnHeader, ForeignItem, Mutability, Visibility, VisibilityKind};
|
||||
|
@ -81,7 +81,7 @@ impl<'a> Parser<'a> {
|
|||
Some(item)
|
||||
});
|
||||
|
||||
let item = self.parse_item_common(attrs, macros_allowed, attributes_allowed)?;
|
||||
let item = self.parse_item_common(attrs, macros_allowed, attributes_allowed, |_| true)?;
|
||||
if let Some(ref item) = item {
|
||||
self.error_on_illegal_default(item.defaultness);
|
||||
}
|
||||
|
@ -91,21 +91,25 @@ impl<'a> Parser<'a> {
|
|||
fn parse_item_common(
|
||||
&mut self,
|
||||
mut attrs: Vec<Attribute>,
|
||||
macros_allowed: bool,
|
||||
attributes_allowed: bool,
|
||||
mac_allowed: bool,
|
||||
attrs_allowed: bool,
|
||||
req_name: ReqName,
|
||||
) -> PResult<'a, Option<Item>> {
|
||||
let lo = self.token.span;
|
||||
let vis = self.parse_visibility(FollowedByType::No)?;
|
||||
let mut def = self.parse_defaultness();
|
||||
let kind = self.parse_item_kind(&mut attrs, macros_allowed, lo, &vis, &mut def)?;
|
||||
let kind = self.parse_item_kind(&mut attrs, mac_allowed, lo, &vis, &mut def, req_name)?;
|
||||
if let Some((ident, kind)) = kind {
|
||||
return Ok(Some(self.mk_item(lo, ident, kind, vis, def, attrs)));
|
||||
let span = lo.to(self.prev_span);
|
||||
let id = DUMMY_NODE_ID;
|
||||
let item = Item { ident, attrs, id, kind, vis, defaultness: def, span, tokens: None };
|
||||
return Ok(Some(item));
|
||||
}
|
||||
|
||||
// At this point, we have failed to parse an item.
|
||||
self.error_on_unmatched_vis(&vis);
|
||||
self.error_on_unmatched_defaultness(def);
|
||||
if !attributes_allowed {
|
||||
if !attrs_allowed {
|
||||
self.recover_attrs_no_item(&attrs)?;
|
||||
}
|
||||
Ok(None)
|
||||
|
@ -151,6 +155,7 @@ impl<'a> Parser<'a> {
|
|||
lo: Span,
|
||||
vis: &Visibility,
|
||||
def: &mut Defaultness,
|
||||
req_name: ReqName,
|
||||
) -> PResult<'a, Option<ItemInfo>> {
|
||||
let info = if self.eat_keyword(kw::Use) {
|
||||
// USE ITEM
|
||||
|
@ -159,7 +164,7 @@ impl<'a> Parser<'a> {
|
|||
(Ident::invalid(), ItemKind::Use(P(tree)))
|
||||
} else if self.check_fn_front_matter() {
|
||||
// FUNCTION ITEM
|
||||
let (ident, sig, generics, body) = self.parse_fn(&mut false, attrs, |_| true)?;
|
||||
let (ident, sig, generics, body) = self.parse_fn(&mut false, attrs, req_name)?;
|
||||
(ident, ItemKind::Fn(sig, generics, body))
|
||||
} else if self.eat_keyword(kw::Extern) {
|
||||
if self.eat_keyword(kw::Crate) {
|
||||
|
@ -367,23 +372,6 @@ impl<'a> Parser<'a> {
|
|||
self.token.is_keyword(kw::Async) && self.is_keyword_ahead(1, &[kw::Fn])
|
||||
}
|
||||
|
||||
/// Given this code `path(`, it seems like this is not
|
||||
/// setting the visibility of a macro invocation,
|
||||
/// but rather a mistyped method declaration.
|
||||
/// Create a diagnostic pointing out that `fn` is missing.
|
||||
///
|
||||
/// ```
|
||||
/// x | pub path(&self) {
|
||||
/// | ^ missing `fn`, `type`, `const`, or `static`
|
||||
/// ```
|
||||
fn missing_nested_item_kind_err(&self, prev_span: Span) -> DiagnosticBuilder<'a> {
|
||||
let sp = prev_span.between(self.token.span);
|
||||
let expected_kinds = "missing `fn`, `type`, `const`, or `static`";
|
||||
let mut err = self.struct_span_err(sp, &format!("{} for item declaration", expected_kinds));
|
||||
err.span_label(sp, expected_kinds);
|
||||
err
|
||||
}
|
||||
|
||||
/// Parses an implementation item.
|
||||
///
|
||||
/// ```
|
||||
|
@ -457,8 +445,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
generics.where_clause = self.parse_where_clause()?;
|
||||
|
||||
let impl_items =
|
||||
self.parse_item_list(attrs, |p, at_end| p.parse_impl_item(at_end).map(Some).map(Some))?;
|
||||
let impl_items = self.parse_item_list(attrs, |p| p.parse_impl_item())?;
|
||||
|
||||
let item_kind = match ty_second {
|
||||
Some(ty_second) => {
|
||||
|
@ -517,7 +504,7 @@ impl<'a> Parser<'a> {
|
|||
fn parse_item_list<T>(
|
||||
&mut self,
|
||||
attrs: &mut Vec<Attribute>,
|
||||
mut parse_item: impl FnMut(&mut Parser<'a>, &mut bool) -> PResult<'a, Option<Option<T>>>,
|
||||
mut parse_item: impl FnMut(&mut Parser<'a>) -> PResult<'a, Option<Option<T>>>,
|
||||
) -> PResult<'a, Vec<T>> {
|
||||
let open_brace_span = self.token.span;
|
||||
self.expect(&token::OpenDelim(token::Brace))?;
|
||||
|
@ -528,8 +515,7 @@ impl<'a> Parser<'a> {
|
|||
if self.recover_doc_comment_before_brace() {
|
||||
continue;
|
||||
}
|
||||
let mut at_end = false;
|
||||
match parse_item(self, &mut at_end) {
|
||||
match parse_item(self) {
|
||||
Ok(None) => {
|
||||
// We have to bail or we'll potentially never make progress.
|
||||
let non_item_span = self.token.span;
|
||||
|
@ -543,11 +529,11 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
Ok(Some(item)) => items.extend(item),
|
||||
Err(mut err) => {
|
||||
err.emit();
|
||||
if !at_end {
|
||||
self.consume_block(token::Brace, ConsumeClosingDelim::Yes);
|
||||
break;
|
||||
}
|
||||
self.consume_block(token::Brace, ConsumeClosingDelim::Yes);
|
||||
err.span_label(open_brace_span, "while parsing this item list starting here")
|
||||
.span_label(self.prev_span, "the item list ends here")
|
||||
.emit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -644,103 +630,69 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
// It's a normal trait.
|
||||
tps.where_clause = self.parse_where_clause()?;
|
||||
let items = self.parse_item_list(attrs, |p, at_end| {
|
||||
p.parse_trait_item(at_end).map(Some).map(Some)
|
||||
})?;
|
||||
let items = self.parse_item_list(attrs, |p| p.parse_trait_item())?;
|
||||
Ok((ident, ItemKind::Trait(is_auto, unsafety, tps, bounds, items)))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_impl_item(&mut self, at_end: &mut bool) -> PResult<'a, P<AssocItem>> {
|
||||
maybe_whole!(self, NtImplItem, |x| x);
|
||||
self.parse_assoc_item(at_end, |_| true)
|
||||
pub fn parse_impl_item(&mut self) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
||||
maybe_whole!(self, NtImplItem, |x| Some(Some(x)));
|
||||
self.parse_assoc_item(|_| true)
|
||||
}
|
||||
|
||||
pub fn parse_trait_item(&mut self, at_end: &mut bool) -> PResult<'a, P<AssocItem>> {
|
||||
maybe_whole!(self, NtTraitItem, |x| x);
|
||||
pub fn parse_trait_item(&mut self) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
||||
maybe_whole!(self, NtTraitItem, |x| Some(Some(x)));
|
||||
// This is somewhat dubious; We don't want to allow
|
||||
// param names to be left off if there is a definition...
|
||||
//
|
||||
// We don't allow param names to be left off in edition 2018.
|
||||
self.parse_assoc_item(at_end, |t| t.span.rust_2018())
|
||||
self.parse_assoc_item(|t| t.span.rust_2018())
|
||||
}
|
||||
|
||||
/// Parses associated items.
|
||||
fn parse_assoc_item(
|
||||
&mut self,
|
||||
at_end: &mut bool,
|
||||
req_name: ReqName,
|
||||
) -> PResult<'a, P<AssocItem>> {
|
||||
fn parse_assoc_item(&mut self, req_name: ReqName) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
||||
let attrs = self.parse_outer_attributes()?;
|
||||
let mut unclosed_delims = vec![];
|
||||
let (mut item, tokens) = self.collect_tokens(|this| {
|
||||
let item = this.parse_assoc_item_(at_end, attrs, req_name);
|
||||
let item = this.parse_assoc_item_(attrs, req_name);
|
||||
unclosed_delims.append(&mut this.unclosed_delims);
|
||||
item
|
||||
})?;
|
||||
self.unclosed_delims.append(&mut unclosed_delims);
|
||||
// See `parse_item` for why this clause is here.
|
||||
if !item.attrs.iter().any(|attr| attr.style == AttrStyle::Inner) {
|
||||
item.tokens = Some(tokens);
|
||||
}
|
||||
self.error_on_assoc_static(&item);
|
||||
Ok(P(item))
|
||||
}
|
||||
|
||||
fn error_on_assoc_static(&self, item: &AssocItem) {
|
||||
if let AssocItemKind::Static(..) = item.kind {
|
||||
self.struct_span_err(item.span, "associated `static` items are not allowed").emit();
|
||||
if let Some(Some(item)) = &mut item {
|
||||
if !item.attrs.iter().any(|attr| attr.style == AttrStyle::Inner) {
|
||||
item.tokens = Some(tokens);
|
||||
}
|
||||
}
|
||||
Ok(item)
|
||||
}
|
||||
|
||||
fn parse_assoc_item_(
|
||||
&mut self,
|
||||
at_end: &mut bool,
|
||||
mut attrs: Vec<Attribute>,
|
||||
attrs: Vec<Attribute>,
|
||||
req_name: ReqName,
|
||||
) -> PResult<'a, AssocItem> {
|
||||
let lo = self.token.span;
|
||||
let vis = self.parse_visibility(FollowedByType::No)?;
|
||||
let defaultness = self.parse_defaultness();
|
||||
let (ident, kind) = self.parse_assoc_item_kind(at_end, &mut attrs, req_name, &vis)?;
|
||||
let span = lo.to(self.prev_span);
|
||||
let id = DUMMY_NODE_ID;
|
||||
Ok(AssocItem { id, span, ident, attrs, vis, defaultness, kind, tokens: None })
|
||||
}
|
||||
|
||||
fn parse_assoc_item_kind(
|
||||
&mut self,
|
||||
at_end: &mut bool,
|
||||
attrs: &mut Vec<Attribute>,
|
||||
req_name: ReqName,
|
||||
vis: &Visibility,
|
||||
) -> PResult<'a, (Ident, AssocItemKind)> {
|
||||
if self.eat_keyword(kw::Type) {
|
||||
match self.parse_type_alias()? {
|
||||
(ident, ItemKind::TyAlias(a, b, c)) => Ok((ident, AssocItemKind::TyAlias(a, b, c))),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else if self.check_fn_front_matter() {
|
||||
let (ident, sig, generics, body) = self.parse_fn(at_end, attrs, req_name)?;
|
||||
Ok((ident, AssocItemKind::Fn(sig, generics, body)))
|
||||
} else if self.is_static_global() {
|
||||
self.bump(); // `static`
|
||||
let mutbl = self.parse_mutability();
|
||||
let (ident, ty, expr) = self.parse_item_const_common(Some(mutbl))?;
|
||||
Ok((ident, AssocItemKind::Static(ty, mutbl, expr)))
|
||||
} else if self.eat_keyword(kw::Const) {
|
||||
let (ident, ty, expr) = self.parse_item_const_common(None)?;
|
||||
Ok((ident, AssocItemKind::Const(ty, expr)))
|
||||
} else if self.isnt_macro_invocation() {
|
||||
Err(self.missing_nested_item_kind_err(self.prev_span))
|
||||
} else if self.token.is_path_start() {
|
||||
let mac = self.parse_item_macro(&vis)?;
|
||||
*at_end = true;
|
||||
Ok((Ident::invalid(), AssocItemKind::Macro(mac)))
|
||||
} else {
|
||||
self.recover_attrs_no_item(attrs)?;
|
||||
self.unexpected()
|
||||
}
|
||||
) -> PResult<'a, Option<Option<P<AssocItem>>>> {
|
||||
let it = self.parse_item_common(attrs, true, false, req_name)?;
|
||||
Ok(it.map(|Item { attrs, id, span, vis, ident, defaultness, kind, tokens }| {
|
||||
let kind = match kind {
|
||||
ItemKind::Mac(a) => AssocItemKind::Macro(a),
|
||||
ItemKind::Fn(a, b, c) => AssocItemKind::Fn(a, b, c),
|
||||
ItemKind::TyAlias(a, b, c) => AssocItemKind::TyAlias(a, b, c),
|
||||
ItemKind::Const(a, c) => AssocItemKind::Const(a, c),
|
||||
ItemKind::Static(a, _, b) => {
|
||||
self.struct_span_err(span, "associated `static` items are not allowed").emit();
|
||||
AssocItemKind::Const(a, b)
|
||||
}
|
||||
_ => {
|
||||
let span = self.sess.source_map().def_span(span);
|
||||
self.struct_span_err(span, "item kind not supported in `trait` or `impl`")
|
||||
.emit();
|
||||
return None;
|
||||
}
|
||||
};
|
||||
Some(P(Item { attrs, id, span, vis, ident, defaultness, kind, tokens }))
|
||||
}))
|
||||
}
|
||||
|
||||
/// Parses a `type` alias with the following grammar:
|
||||
|
@ -907,7 +859,7 @@ impl<'a> Parser<'a> {
|
|||
/// ```
|
||||
fn parse_item_foreign_mod(&mut self, attrs: &mut Vec<Attribute>) -> PResult<'a, ItemInfo> {
|
||||
let abi = self.parse_abi(); // ABI?
|
||||
let items = self.parse_item_list(attrs, |p, _| p.parse_foreign_item())?;
|
||||
let items = self.parse_item_list(attrs, |p| p.parse_foreign_item())?;
|
||||
let module = ast::ForeignMod { abi, items };
|
||||
Ok((Ident::invalid(), ItemKind::ForeignMod(module)))
|
||||
}
|
||||
|
@ -917,17 +869,17 @@ impl<'a> Parser<'a> {
|
|||
maybe_whole!(self, NtForeignItem, |item| Some(Some(item)));
|
||||
|
||||
let attrs = self.parse_outer_attributes()?;
|
||||
let it = self.parse_item_common(attrs, true, false)?;
|
||||
let it = self.parse_item_common(attrs, true, false, |_| true)?;
|
||||
Ok(it.map(|Item { attrs, id, span, vis, ident, defaultness, kind, tokens }| {
|
||||
self.error_on_illegal_default(defaultness);
|
||||
let kind = match kind {
|
||||
ItemKind::Mac(a) => AssocItemKind::Macro(a),
|
||||
ItemKind::Fn(a, b, c) => AssocItemKind::Fn(a, b, c),
|
||||
ItemKind::TyAlias(a, b, c) => AssocItemKind::TyAlias(a, b, c),
|
||||
ItemKind::Static(a, b, c) => AssocItemKind::Static(a, b, c),
|
||||
ItemKind::Mac(a) => ForeignItemKind::Macro(a),
|
||||
ItemKind::Fn(a, b, c) => ForeignItemKind::Fn(a, b, c),
|
||||
ItemKind::TyAlias(a, b, c) => ForeignItemKind::TyAlias(a, b, c),
|
||||
ItemKind::Static(a, b, c) => ForeignItemKind::Static(a, b, c),
|
||||
ItemKind::Const(a, b) => {
|
||||
self.error_on_foreign_const(span, ident);
|
||||
AssocItemKind::Static(a, Mutability::Not, b)
|
||||
ForeignItemKind::Static(a, Mutability::Not, b)
|
||||
}
|
||||
_ => {
|
||||
let span = self.sess.source_map().def_span(span);
|
||||
|
@ -989,22 +941,6 @@ impl<'a> Parser<'a> {
|
|||
///
|
||||
/// When `m` is `"const"`, `$ident` may also be `"_"`.
|
||||
fn parse_item_const(&mut self, m: Option<Mutability>) -> PResult<'a, ItemInfo> {
|
||||
let (id, ty, expr) = self.parse_item_const_common(m)?;
|
||||
let item = match m {
|
||||
Some(m) => ItemKind::Static(ty, m, expr),
|
||||
None => ItemKind::Const(ty, expr),
|
||||
};
|
||||
Ok((id, item))
|
||||
}
|
||||
|
||||
/// Parse `["const" | ("static" "mut"?)] $ident ":" $ty (= $expr)?` with
|
||||
/// `["const" | ("static" "mut"?)]` already parsed and stored in `m`.
|
||||
///
|
||||
/// When `m` is `"const"`, `$ident` may also be `"_"`.
|
||||
fn parse_item_const_common(
|
||||
&mut self,
|
||||
m: Option<Mutability>,
|
||||
) -> PResult<'a, (Ident, P<Ty>, Option<P<ast::Expr>>)> {
|
||||
let id = if m.is_none() { self.parse_ident_or_underscore() } else { self.parse_ident() }?;
|
||||
|
||||
// Parse the type of a `const` or `static mut?` item.
|
||||
|
@ -1017,7 +953,12 @@ impl<'a> Parser<'a> {
|
|||
|
||||
let expr = if self.eat(&token::Eq) { Some(self.parse_expr()?) } else { None };
|
||||
self.expect_semi()?;
|
||||
Ok((id, ty, expr))
|
||||
|
||||
let item = match m {
|
||||
Some(m) => ItemKind::Static(ty, m, expr),
|
||||
None => ItemKind::Const(ty, expr),
|
||||
};
|
||||
Ok((id, item))
|
||||
}
|
||||
|
||||
/// We were supposed to parse `:` but the `:` was missing.
|
||||
|
@ -1477,19 +1418,6 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn mk_item<K>(
|
||||
&self,
|
||||
lo: Span,
|
||||
ident: Ident,
|
||||
kind: K,
|
||||
vis: Visibility,
|
||||
defaultness: Defaultness,
|
||||
attrs: Vec<Attribute>,
|
||||
) -> Item<K> {
|
||||
let span = lo.to(self.prev_span);
|
||||
Item { ident, attrs, id: DUMMY_NODE_ID, kind, vis, defaultness, span, tokens: None }
|
||||
}
|
||||
}
|
||||
|
||||
/// The parsing configuration used to parse a parameter list (see `parse_fn_params`).
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
error: expected one of `extern` or `fn`, found keyword `async`
|
||||
--> $DIR/no-unsafe-async.rs:7:12
|
||||
|
|
||||
LL | impl S {
|
||||
| - while parsing this item list starting here
|
||||
LL | #[cfg(FALSE)]
|
||||
LL | unsafe async fn g() {}
|
||||
| ^^^^^ expected one of `extern` or `fn`
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: expected one of `extern` or `fn`, found keyword `async`
|
||||
--> $DIR/no-unsafe-async.rs:11:8
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
impl dyn A { //~ ERROR missing
|
||||
impl dyn A {
|
||||
Y
|
||||
}
|
||||
} //~ ERROR expected one of `!` or `::`, found `}`
|
||||
|
||||
struct S;
|
||||
|
||||
trait X { //~ ERROR missing
|
||||
X() {}
|
||||
trait X {
|
||||
X() {} //~ ERROR expected one of `!` or `::`, found `(`
|
||||
fn xxx() { ### }
|
||||
L = M;
|
||||
Z = { 2 + 3 };
|
||||
::Y ();
|
||||
}
|
||||
|
||||
trait A { //~ ERROR missing
|
||||
X() {}
|
||||
trait A {
|
||||
X() {} //~ ERROR expected one of `!` or `::`, found `(`
|
||||
}
|
||||
trait B {
|
||||
fn xxx() { ### } //~ ERROR expected
|
||||
}
|
||||
trait C { //~ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
L = M;
|
||||
trait C {
|
||||
L = M; //~ ERROR expected one of `!` or `::`, found `=`
|
||||
}
|
||||
trait D { //~ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
Z = { 2 + 3 };
|
||||
trait D {
|
||||
Z = { 2 + 3 }; //~ ERROR expected one of `!` or `::`, found `=`
|
||||
}
|
||||
trait E {
|
||||
::Y (); //~ ERROR expected one of
|
||||
|
|
|
@ -1,26 +1,36 @@
|
|||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-40006.rs:1:13
|
||||
error: expected one of `!` or `::`, found `}`
|
||||
--> $DIR/issue-40006.rs:3:1
|
||||
|
|
||||
LL | impl dyn A {
|
||||
| _____________^
|
||||
LL | | Y
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | impl dyn A {
|
||||
| - while parsing this item list starting here
|
||||
LL | Y
|
||||
| - expected one of `!` or `::`
|
||||
LL | }
|
||||
| ^
|
||||
| |
|
||||
| unexpected token
|
||||
| the item list ends here
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-40006.rs:7:10
|
||||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/issue-40006.rs:8:6
|
||||
|
|
||||
LL | trait X {
|
||||
| __________^
|
||||
LL | | X() {}
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait X {
|
||||
| - while parsing this item list starting here
|
||||
LL | X() {}
|
||||
| ^ expected one of `!` or `::`
|
||||
...
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-40006.rs:15:10
|
||||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/issue-40006.rs:16:6
|
||||
|
|
||||
LL | trait A {
|
||||
| __________^
|
||||
LL | | X() {}
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait A {
|
||||
| - while parsing this item list starting here
|
||||
LL | X() {}
|
||||
| ^ expected one of `!` or `::`
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: expected `[`, found `#`
|
||||
--> $DIR/issue-40006.rs:19:17
|
||||
|
@ -28,33 +38,51 @@ error: expected `[`, found `#`
|
|||
LL | fn xxx() { ### }
|
||||
| ^ expected `[`
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-40006.rs:21:10
|
||||
error: expected one of `!` or `::`, found `=`
|
||||
--> $DIR/issue-40006.rs:22:7
|
||||
|
|
||||
LL | trait C {
|
||||
| __________^
|
||||
LL | | L = M;
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait C {
|
||||
| - while parsing this item list starting here
|
||||
LL | L = M;
|
||||
| ^ expected one of `!` or `::`
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-40006.rs:24:10
|
||||
error: expected one of `!` or `::`, found `=`
|
||||
--> $DIR/issue-40006.rs:25:7
|
||||
|
|
||||
LL | trait D {
|
||||
| __________^
|
||||
LL | | Z = { 2 + 3 };
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait D {
|
||||
| - while parsing this item list starting here
|
||||
LL | Z = { 2 + 3 };
|
||||
| ^ expected one of `!` or `::`
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/issue-40006.rs:28:9
|
||||
|
|
||||
LL | trait E {
|
||||
| - while parsing this item list starting here
|
||||
LL | ::Y ();
|
||||
| ^ expected one of `!` or `::`
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
error: missing `fn` for method definition
|
||||
--> $DIR/issue-40006.rs:32:8
|
||||
|
|
||||
LL | impl S {
|
||||
| - while parsing this item list starting here
|
||||
LL | pub hello_method(&self) {
|
||||
| ^ missing `fn`, `type`, `const`, or `static`
|
||||
| ^
|
||||
...
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
|
||||
help: add `fn` here to parse `hello_method` as a public method
|
||||
|
|
||||
LL | pub fn hello_method(&self) {
|
||||
| ^^
|
||||
|
||||
error[E0599]: no method named `hello_method` found for struct `S` in the current scope
|
||||
--> $DIR/issue-40006.rs:38:7
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
error: expected one of `>`, `const`, identifier, or lifetime, found `,`
|
||||
--> $DIR/empty_generics.rs:5:14
|
||||
|
|
||||
LL | trait Foo {
|
||||
| - while parsing this item list starting here
|
||||
LL | type Bar<,>;
|
||||
| ^ expected one of `>`, `const`, identifier, or lifetime
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -9,8 +9,14 @@ LL | fn b(self>
|
|||
error: expected `;` or `{`, found `>`
|
||||
--> $DIR/issue-58856-1.rs:3:14
|
||||
|
|
||||
LL | impl A {
|
||||
| - while parsing this item list starting here
|
||||
LL |
|
||||
LL | fn b(self>
|
||||
| ^ expected `;` or `{`
|
||||
...
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error[E0412]: cannot find type `A` in this scope
|
||||
--> $DIR/issue-58856-1.rs:1:6
|
||||
|
|
|
@ -9,6 +9,6 @@ impl Howness for () {
|
|||
Empty
|
||||
}
|
||||
}
|
||||
//~^ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`,
|
||||
//~^ ERROR non-item in item list
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -7,13 +7,17 @@ LL | fn how_are_you(&self -> Empty {
|
|||
| | help: `)` may belong here
|
||||
| unclosed delimiter
|
||||
|
||||
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, `}`, or identifier, found `)`
|
||||
error: non-item in item list
|
||||
--> $DIR/issue-58856-2.rs:11:1
|
||||
|
|
||||
LL | }
|
||||
| - expected one of 12 possible tokens
|
||||
LL | impl Howness for () {
|
||||
| - item list starts here
|
||||
...
|
||||
LL | }
|
||||
| ^ unexpected token
|
||||
| ^
|
||||
| |
|
||||
| non-item starts here
|
||||
| item list ends here
|
||||
|
||||
error[E0407]: method `how_are_you` is not a member of trait `Howness`
|
||||
--> $DIR/issue-58856-2.rs:6:5
|
||||
|
|
|
@ -4,7 +4,8 @@ trait T {
|
|||
fn qux() -> Option<usize> {
|
||||
let _ = if true {
|
||||
});
|
||||
//~^ ERROR expected one of `async`
|
||||
//~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `}`
|
||||
//~^ ERROR non-item in item list
|
||||
//~| ERROR mismatched closing delimiter: `)`
|
||||
//~| ERROR expected one of `.`, `;`
|
||||
Some(4)
|
||||
}
|
||||
|
|
|
@ -4,14 +4,26 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}`
|
|||
LL | });
|
||||
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
||||
|
||||
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, `}`, or identifier, found `;`
|
||||
error: non-item in item list
|
||||
--> $DIR/issue-60075.rs:6:11
|
||||
|
|
||||
LL | trait T {
|
||||
| - item list starts here
|
||||
...
|
||||
LL | });
|
||||
| ^ non-item starts here
|
||||
...
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error: mismatched closing delimiter: `)`
|
||||
--> $DIR/issue-60075.rs:6:10
|
||||
|
|
||||
LL | fn qux() -> Option<usize> {
|
||||
| - unclosed delimiter
|
||||
LL | let _ = if true {
|
||||
LL | });
|
||||
| ^ help: `}` may belong here
|
||||
| ^ mismatched closing delimiter
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -10,10 +10,12 @@ impl S {
|
|||
//~^ ERROR associated `static` items are not allowed
|
||||
static IB: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
default static IC: u8 = 0;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
pub(crate) default static ID: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
}
|
||||
|
||||
trait T {
|
||||
|
@ -35,9 +37,11 @@ impl T for S {
|
|||
//~^ ERROR associated `static` items are not allowed
|
||||
static TB: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
default static TC: u8 = 0;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
pub default static TD: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
//~| ERROR associated constant in `impl` without body
|
||||
//~| ERROR unnecessary visibility qualifier
|
||||
}
|
||||
|
|
|
@ -11,67 +11,83 @@ LL | static IB: u8;
|
|||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:13:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:14:5
|
||||
|
|
||||
LL | default static IC: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:15:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:16:5
|
||||
|
|
||||
LL | pub(crate) default static ID: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:20:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:22:5
|
||||
|
|
||||
LL | static TA: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:22:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:24:5
|
||||
|
|
||||
LL | static TB: u8;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:24:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:26:5
|
||||
|
|
||||
LL | default static TC: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:27:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:29:5
|
||||
|
|
||||
LL | pub(crate) default static TD: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:34:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:36:5
|
||||
|
|
||||
LL | static TA: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:36:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:38:5
|
||||
|
|
||||
LL | static TB: u8;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:38:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:41:5
|
||||
|
|
||||
LL | default static TC: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/assoc-static-semantic-fail.rs:40:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:43:5
|
||||
|
|
||||
LL | pub default static TD: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:11:5
|
||||
|
|
||||
LL | static IB: u8;
|
||||
| ^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:16:5
|
||||
|
|
||||
LL | pub(crate) default static ID: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error: `default` is only allowed on items in `impl` definitions
|
||||
--> $DIR/assoc-static-semantic-fail.rs:24:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:26:5
|
||||
|
|
||||
LL | default static TC: u8 = 0;
|
||||
| -------^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -79,7 +95,7 @@ LL | default static TC: u8 = 0;
|
|||
| `default` because of this
|
||||
|
||||
error: `default` is only allowed on items in `impl` definitions
|
||||
--> $DIR/assoc-static-semantic-fail.rs:27:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:29:5
|
||||
|
|
||||
LL | pub(crate) default static TD: u8;
|
||||
| ^^^^^^^^^^^-------^^^^^^^^^^^^^^^
|
||||
|
@ -87,17 +103,33 @@ LL | pub(crate) default static TD: u8;
|
|||
| `default` because of this
|
||||
|
||||
error[E0449]: unnecessary visibility qualifier
|
||||
--> $DIR/assoc-static-semantic-fail.rs:27:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:29:5
|
||||
|
|
||||
LL | pub(crate) default static TD: u8;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:38:5
|
||||
|
|
||||
LL | static TB: u8;
|
||||
| ^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/assoc-static-semantic-fail.rs:43:5
|
||||
|
|
||||
LL | pub default static TD: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error[E0449]: unnecessary visibility qualifier
|
||||
--> $DIR/assoc-static-semantic-fail.rs:40:5
|
||||
--> $DIR/assoc-static-semantic-fail.rs:43:5
|
||||
|
|
||||
LL | pub default static TD: u8;
|
||||
| ^^^ `pub` not permitted here because it's implied
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0449`.
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
error: expected item after attributes
|
||||
--> $DIR/attrs-after-extern-mod.rs:6:5
|
||||
|
|
||||
LL | extern {
|
||||
| - while parsing this item list starting here
|
||||
LL | #[cfg(stage37)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -60,3 +60,73 @@ extern "C" {
|
|||
default macro_rules! foo {} //~ ERROR item cannot be `default`
|
||||
//~^ ERROR item kind not supported in `extern` block
|
||||
}
|
||||
|
||||
#[cfg(FALSE)]
|
||||
impl S {
|
||||
default extern crate foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default use foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default static foo: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
default const foo: u8;
|
||||
default fn foo();
|
||||
default mod foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default extern "C" {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default type foo = u8;
|
||||
default enum foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default struct foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default union foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo = Ord;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default impl foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default!();
|
||||
default::foo::bar!();
|
||||
default macro foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default macro_rules! foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
}
|
||||
|
||||
#[cfg(FALSE)]
|
||||
trait T {
|
||||
default extern crate foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default use foo;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default static foo: u8;
|
||||
//~^ ERROR associated `static` items are not allowed
|
||||
default const foo: u8;
|
||||
default fn foo();
|
||||
default mod foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default extern "C" {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default type foo = u8;
|
||||
default enum foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default struct foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default union foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default trait foo = Ord;
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default impl foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default!();
|
||||
default::foo::bar!();
|
||||
default macro foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
default macro_rules! foo {}
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
}
|
||||
|
|
|
@ -320,5 +320,161 @@ error: item kind not supported in `extern` block
|
|||
LL | default macro_rules! foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 43 previous errors
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:66:5
|
||||
|
|
||||
LL | default extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:68:5
|
||||
|
|
||||
LL | default use foo;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/default-on-wrong-item-kind.rs:70:5
|
||||
|
|
||||
LL | default static foo: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:74:5
|
||||
|
|
||||
LL | default mod foo {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:76:5
|
||||
|
|
||||
LL | default extern "C" {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:79:5
|
||||
|
|
||||
LL | default enum foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:81:5
|
||||
|
|
||||
LL | default struct foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:83:5
|
||||
|
|
||||
LL | default union foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:85:5
|
||||
|
|
||||
LL | default trait foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:87:5
|
||||
|
|
||||
LL | default trait foo = Ord;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:89:5
|
||||
|
|
||||
LL | default impl foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:93:5
|
||||
|
|
||||
LL | default macro foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:95:5
|
||||
|
|
||||
LL | default macro_rules! foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:101:5
|
||||
|
|
||||
LL | default extern crate foo;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:103:5
|
||||
|
|
||||
LL | default use foo;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated `static` items are not allowed
|
||||
--> $DIR/default-on-wrong-item-kind.rs:105:5
|
||||
|
|
||||
LL | default static foo: u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:109:5
|
||||
|
|
||||
LL | default mod foo {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:111:5
|
||||
|
|
||||
LL | default extern "C" {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:114:5
|
||||
|
|
||||
LL | default enum foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:116:5
|
||||
|
|
||||
LL | default struct foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:118:5
|
||||
|
|
||||
LL | default union foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:120:5
|
||||
|
|
||||
LL | default trait foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:122:5
|
||||
|
|
||||
LL | default trait foo = Ord;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:124:5
|
||||
|
|
||||
LL | default impl foo {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:128:5
|
||||
|
|
||||
LL | default macro foo {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/default-on-wrong-item-kind.rs:130:5
|
||||
|
|
||||
LL | default macro_rules! foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 69 previous errors
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
fn main() {}
|
||||
|
||||
trait Foo {
|
||||
default!(); //~ ERROR cannot find macro `default` in this scope
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
||||
struct S;
|
||||
impl S {
|
||||
default!(); //~ ERROR cannot find macro `default` in this scope
|
||||
default do
|
||||
//~^ ERROR unmatched `default`
|
||||
//~| ERROR non-item in item list
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
error: unmatched `default`
|
||||
--> $DIR/default-unmatched-assoc.rs:5:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default-unmatched-assoc.rs:5:13
|
||||
|
|
||||
LL | trait Foo {
|
||||
| - item list starts here
|
||||
LL | default!();
|
||||
LL | default do
|
||||
| ^^ non-item starts here
|
||||
...
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error: unmatched `default`
|
||||
--> $DIR/default-unmatched-assoc.rs:13:5
|
||||
|
|
||||
LL | default do
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default-unmatched-assoc.rs:13:13
|
||||
|
|
||||
LL | impl S {
|
||||
| - item list starts here
|
||||
LL | default!();
|
||||
LL | default do
|
||||
| ^^ non-item starts here
|
||||
...
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error: cannot find macro `default` in this scope
|
||||
--> $DIR/default-unmatched-assoc.rs:12:5
|
||||
|
|
||||
LL | default!();
|
||||
| ^^^^^^^
|
||||
|
||||
error: cannot find macro `default` in this scope
|
||||
--> $DIR/default-unmatched-assoc.rs:4:5
|
||||
|
|
||||
LL | default!();
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
|
@ -20,7 +20,8 @@ impl Foo for u16 {
|
|||
|
||||
impl Foo for u32 { //~ ERROR not all trait items implemented, missing: `foo`
|
||||
default pub fn foo<T: Default>() -> T { T::default() }
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
//~^ ERROR unmatched `default`
|
||||
//~| ERROR non-item in item list
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/default.rs:22:12
|
||||
error: unmatched `default`
|
||||
--> $DIR/default.rs:22:5
|
||||
|
|
||||
LL | default pub fn foo<T: Default>() -> T { T::default() }
|
||||
| ^ missing `fn`, `type`, `const`, or `static`
|
||||
| ^^^^^^^ the unmatched `default`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/default.rs:22:13
|
||||
|
|
||||
LL | impl Foo for u32 {
|
||||
| - item list starts here
|
||||
LL | default pub fn foo<T: Default>() -> T { T::default() }
|
||||
| ^^^ non-item starts here
|
||||
...
|
||||
LL | }
|
||||
| - item list ends here
|
||||
|
||||
error[E0449]: unnecessary visibility qualifier
|
||||
--> $DIR/default.rs:16:5
|
||||
|
@ -19,7 +30,7 @@ LL | fn foo<T: Default>() -> T;
|
|||
LL | impl Foo for u32 {
|
||||
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0046, E0449.
|
||||
For more information about an error, try `rustc --explain E0046`.
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
error: expected one of `!` or `::`, found `(`
|
||||
--> $DIR/extern-no-fn.rs:2:6
|
||||
|
|
||||
LL | extern {
|
||||
| - while parsing this item list starting here
|
||||
LL | f();
|
||||
| ^ expected one of `!` or `::`
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
trait T {
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
extern "Rust" unsafe fn foo();
|
||||
//~^ ERROR expected `{`, found keyword `unsafe`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-19398.rs:1:10
|
||||
error: expected `{`, found keyword `unsafe`
|
||||
--> $DIR/issue-19398.rs:2:19
|
||||
|
|
||||
LL | trait T {
|
||||
| __________^
|
||||
LL | |
|
||||
LL | | extern "Rust" unsafe fn foo();
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait T {
|
||||
| - while parsing this item list starting here
|
||||
LL | extern "Rust" unsafe fn foo();
|
||||
| ^^^^^^ expected `{`
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
error: expected item after attributes
|
||||
--> $DIR/issue-20711-2.rs:6:5
|
||||
|
|
||||
LL | impl Foo {
|
||||
| - while parsing this item list starting here
|
||||
...
|
||||
LL | #[stable(feature = "rust1", since = "1.0.0")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
error: expected item after attributes
|
||||
--> $DIR/issue-20711.rs:4:5
|
||||
|
|
||||
LL | impl Foo {
|
||||
| - while parsing this item list starting here
|
||||
LL | #[stable(feature = "rust1", since = "1.0.0")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
trait MyTrait<T>: Iterator {
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
Item = T;
|
||||
//~^ ERROR expected one of `!` or `::`, found `=`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/issue-21153.rs:1:29
|
||||
error: expected one of `!` or `::`, found `=`
|
||||
--> $DIR/issue-21153.rs:2:10
|
||||
|
|
||||
LL | trait MyTrait<T>: Iterator {
|
||||
| _____________________________^
|
||||
LL | |
|
||||
LL | | Item = T;
|
||||
| |____^ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait MyTrait<T>: Iterator {
|
||||
| - while parsing this item list starting here
|
||||
LL | Item = T;
|
||||
| ^ expected one of `!` or `::`
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, `}`, or identifier, found `...`
|
||||
error: non-item in item list
|
||||
--> $DIR/issue-32446.rs:4:11
|
||||
|
|
||||
LL | trait T { ... }
|
||||
| ^^^ expected one of 12 possible tokens
|
||||
| - ^^^ - item list ends here
|
||||
| | |
|
||||
| | non-item starts here
|
||||
| item list starts here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
struct S;
|
||||
|
||||
impl S {
|
||||
pub
|
||||
} //~ ERROR expected one of
|
||||
pub //~ ERROR unmatched visibility `pub`
|
||||
} //~ ERROR non-item in item list
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `static`, `type`, `unsafe`, or identifier, found `}`
|
||||
--> $DIR/issue-41155.rs:5:1
|
||||
error: unmatched visibility `pub`
|
||||
--> $DIR/issue-41155.rs:4:5
|
||||
|
|
||||
LL | pub
|
||||
| - expected one of 10 possible tokens
|
||||
| ^^^ the unmatched visibility
|
||||
|
|
||||
= help: you likely meant to define an item, e.g., `pub fn foo() {}`
|
||||
|
||||
error: non-item in item list
|
||||
--> $DIR/issue-41155.rs:5:1
|
||||
|
|
||||
LL | impl S {
|
||||
| - item list starts here
|
||||
LL | pub
|
||||
LL | }
|
||||
| ^ unexpected token
|
||||
| ^
|
||||
| |
|
||||
| non-item starts here
|
||||
| item list ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,7 +2,11 @@ error: expected `;` or `{`, found `}`
|
|||
--> $DIR/issue-6610.rs:1:20
|
||||
|
|
||||
LL | trait Foo { fn a() }
|
||||
| ^ expected `;` or `{`
|
||||
| - ^
|
||||
| | |
|
||||
| | expected `;` or `{`
|
||||
| | the item list ends here
|
||||
| while parsing this item list starting here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
macro_rules! bah {
|
||||
($a:expr) => ($a)
|
||||
//~^ ERROR expected one of `async`
|
||||
($a:expr) => {
|
||||
$a
|
||||
}; //~^ ERROR macro expansion ignores token `2` and any following
|
||||
}
|
||||
|
||||
trait bar {
|
||||
trait Bar {
|
||||
bah!(2);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() {
|
||||
let _recovery_witness: () = 0; //~ ERROR mismatched types
|
||||
}
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, or identifier, found `2`
|
||||
--> $DIR/trait-non-item-macros.rs:2:19
|
||||
error: macro expansion ignores token `2` and any following
|
||||
--> $DIR/trait-non-item-macros.rs:3:9
|
||||
|
|
||||
LL | ($a:expr) => ($a)
|
||||
| ^^ expected one of 11 possible tokens
|
||||
LL | $a
|
||||
| ^^
|
||||
...
|
||||
LL | bah!(2);
|
||||
| -------- in this macro invocation
|
||||
| -------- caused by the macro expansion here
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: the usage of `bah!` is likely invalid in trait item context
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/trait-non-item-macros.rs:12:33
|
||||
|
|
||||
LL | let _recovery_witness: () = 0;
|
||||
| -- ^ expected `()`, found integer
|
||||
| |
|
||||
| expected due to this
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
@ -3,12 +3,11 @@ fn main() {}
|
|||
impl T for () { //~ ERROR cannot find trait `T` in this scope
|
||||
|
||||
fn foo(&self) {}
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
|
||||
trait T {
|
||||
trait T { //~ ERROR item kind not supported in `trait` or `impl`
|
||||
fn foo(&self);
|
||||
}
|
||||
|
||||
pub(crate) struct Bar<T>();
|
||||
pub(crate) struct Bar<T>(); //~ ERROR item kind not supported in `trait` or `impl`
|
||||
|
||||
//~ ERROR this file contains an unclosed delimiter
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: this file contains an unclosed delimiter
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:14:52
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:13:52
|
||||
|
|
||||
LL | impl T for () {
|
||||
| - unclosed delimiter
|
||||
|
@ -7,15 +7,17 @@ LL | impl T for () {
|
|||
LL |
|
||||
| ^
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:5:17
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:7:1
|
||||
|
|
||||
LL | fn foo(&self) {}
|
||||
| _________________^
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | trait T {
|
||||
| |_ missing `fn`, `type`, `const`, or `static`
|
||||
LL | trait T {
|
||||
| ^^^^^^^
|
||||
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:11:1
|
||||
|
|
||||
LL | pub(crate) struct Bar<T>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0405]: cannot find trait `T` in this scope
|
||||
--> $DIR/missing-close-brace-in-impl-trait.rs:3:6
|
||||
|
@ -23,6 +25,6 @@ error[E0405]: cannot find trait `T` in this scope
|
|||
LL | impl T for () {
|
||||
| ^ not found in this scope
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0405`.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
trait T {
|
||||
//~^ ERROR `main` function not found in crate `missing_close_brace_in_trait`
|
||||
fn foo(&self);
|
||||
|
||||
pub(crate) struct Bar<T>();
|
||||
//~^ ERROR missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
|
||||
impl T for Bar<usize> {
|
||||
//~^ ERROR item kind not supported in `trait` or `impl`
|
||||
fn foo(&self) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,24 +7,17 @@ LL | trait T {
|
|||
LL | fn main() {}
|
||||
| ^
|
||||
|
||||
error: missing `fn`, `type`, `const`, or `static` for item declaration
|
||||
--> $DIR/missing-close-brace-in-trait.rs:5:11
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-trait.rs:4:1
|
||||
|
|
||||
LL | pub(crate) struct Bar<T>();
|
||||
| ^ missing `fn`, `type`, `const`, or `static`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0601]: `main` function not found in crate `missing_close_brace_in_trait`
|
||||
--> $DIR/missing-close-brace-in-trait.rs:1:1
|
||||
error: item kind not supported in `trait` or `impl`
|
||||
--> $DIR/missing-close-brace-in-trait.rs:7:1
|
||||
|
|
||||
LL | / trait T {
|
||||
LL | |
|
||||
LL | | fn foo(&self);
|
||||
LL | |
|
||||
... |
|
||||
LL | |
|
||||
LL | | fn main() {}
|
||||
| |________________________________________________________________^ consider adding a `main` function to `$DIR/missing-close-brace-in-trait.rs`
|
||||
LL | impl T for Bar<usize> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0601`.
|
||||
|
|
|
@ -7,8 +7,13 @@ LL | static fn f() {}
|
|||
error: expected one of `:`, `;`, or `=`, found `f`
|
||||
--> $DIR/removed-syntax-static-fn.rs:4:15
|
||||
|
|
||||
LL | impl S {
|
||||
| - while parsing this item list starting here
|
||||
LL | static fn f() {}
|
||||
| ^ expected one of `:`, `;`, or `=`
|
||||
...
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
|
||||
error: missing type for `static` item
|
||||
--> $DIR/removed-syntax-static-fn.rs:4:12
|
||||
|
|
Loading…
Reference in New Issue