about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-02-22 08:16:39 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-02-24 00:59:38 +0100
commita05c83b2ebc4e85e32f723e708a40dbd3f165cd0 (patch)
tree8a5fe4fb32c7968db725c058c3991bcd4a3cdfd0 /src
parenta63f35daeefc4ae89ba5b6bd0323d97bb0d050e6 (diff)
downloadrust-a05c83b2ebc4e85e32f723e708a40dbd3f165cd0.tar.gz
rust-a05c83b2ebc4e85e32f723e708a40dbd3f165cd0.zip
parse: use `parse_item_common` in `parse_assoc_item_`.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_expand/expand.rs8
-rw-r--r--src/librustc_parse/parser/item.rs216
-rw-r--r--src/test/ui/async-await/no-unsafe-async.stderr5
-rw-r--r--src/test/ui/did_you_mean/issue-40006.rs20
-rw-r--r--src/test/ui/did_you_mean/issue-40006.stderr92
-rw-r--r--src/test/ui/generic-associated-types/empty_generics.stderr5
-rw-r--r--src/test/ui/issues/issue-58856-1.stderr6
-rw-r--r--src/test/ui/issues/issue-58856-2.rs2
-rw-r--r--src/test/ui/issues/issue-58856-2.stderr12
-rw-r--r--src/test/ui/issues/issue-60075.rs5
-rw-r--r--src/test/ui/issues/issue-60075.stderr18
-rw-r--r--src/test/ui/parser/assoc-static-semantic-fail.rs4
-rw-r--r--src/test/ui/parser/assoc-static-semantic-fail.stderr62
-rw-r--r--src/test/ui/parser/attrs-after-extern-mod.stderr4
-rw-r--r--src/test/ui/parser/default-on-wrong-item-kind.rs70
-rw-r--r--src/test/ui/parser/default-on-wrong-item-kind.stderr158
-rw-r--r--src/test/ui/parser/default-unmatched-assoc.rs16
-rw-r--r--src/test/ui/parser/default-unmatched-assoc.stderr50
-rw-r--r--src/test/ui/parser/default.rs3
-rw-r--r--src/test/ui/parser/default.stderr19
-rw-r--r--src/test/ui/parser/extern-no-fn.stderr4
-rw-r--r--src/test/ui/parser/issue-19398.rs2
-rw-r--r--src/test/ui/parser/issue-19398.stderr16
-rw-r--r--src/test/ui/parser/issue-20711-2.stderr6
-rw-r--r--src/test/ui/parser/issue-20711.stderr5
-rw-r--r--src/test/ui/parser/issue-21153.rs2
-rw-r--r--src/test/ui/parser/issue-21153.stderr16
-rw-r--r--src/test/ui/parser/issue-32446.stderr7
-rw-r--r--src/test/ui/parser/issue-41155.rs4
-rw-r--r--src/test/ui/parser/issue-41155.stderr20
-rw-r--r--src/test/ui/parser/issue-6610.stderr6
-rw-r--r--src/test/ui/parser/macro/trait-non-item-macros.rs11
-rw-r--r--src/test/ui/parser/macro/trait-non-item-macros.stderr23
-rw-r--r--src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs5
-rw-r--r--src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr22
-rw-r--r--src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs4
-rw-r--r--src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr21
-rw-r--r--src/test/ui/parser/removed-syntax-static-fn.stderr5
38 files changed, 668 insertions, 286 deletions
diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs
index df2753813f9..e5f957a63de 100644
--- a/src/librustc_expand/expand.rs
+++ b/src/librustc_expand/expand.rs
@@ -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)
         }
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs
index ecd2049963b..8c5add46bfc 100644
--- a/src/librustc_parse/parser/item.rs
+++ b/src/librustc_parse/parser/item.rs
@@ -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>,
-        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>,
+        attrs: 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`).
diff --git a/src/test/ui/async-await/no-unsafe-async.stderr b/src/test/ui/async-await/no-unsafe-async.stderr
index 2651588d597..c97b4ff0f49 100644
--- a/src/test/ui/async-await/no-unsafe-async.stderr
+++ b/src/test/ui/async-await/no-unsafe-async.stderr
@@ -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
diff --git a/src/test/ui/did_you_mean/issue-40006.rs b/src/test/ui/did_you_mean/issue-40006.rs
index 2ed682cea95..74f304d81a0 100644
--- a/src/test/ui/did_you_mean/issue-40006.rs
+++ b/src/test/ui/did_you_mean/issue-40006.rs
@@ -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
diff --git a/src/test/ui/did_you_mean/issue-40006.stderr b/src/test/ui/did_you_mean/issue-40006.stderr
index 119e30a3e0f..613d7eee594 100644
--- a/src/test/ui/did_you_mean/issue-40006.stderr
+++ b/src/test/ui/did_you_mean/issue-40006.stderr
@@ -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
diff --git a/src/test/ui/generic-associated-types/empty_generics.stderr b/src/test/ui/generic-associated-types/empty_generics.stderr
index d3acad47831..bd5708d8140 100644
--- a/src/test/ui/generic-associated-types/empty_generics.stderr
+++ b/src/test/ui/generic-associated-types/empty_generics.stderr
@@ -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
 
diff --git a/src/test/ui/issues/issue-58856-1.stderr b/src/test/ui/issues/issue-58856-1.stderr
index 0ea6b017548..a8db8e8b41a 100644
--- a/src/test/ui/issues/issue-58856-1.stderr
+++ b/src/test/ui/issues/issue-58856-1.stderr
@@ -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
diff --git a/src/test/ui/issues/issue-58856-2.rs b/src/test/ui/issues/issue-58856-2.rs
index 745f0300bd5..9356d57b0e5 100644
--- a/src/test/ui/issues/issue-58856-2.rs
+++ b/src/test/ui/issues/issue-58856-2.rs
@@ -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() {}
diff --git a/src/test/ui/issues/issue-58856-2.stderr b/src/test/ui/issues/issue-58856-2.stderr
index f4ca3c46ea2..303b5eacc32 100644
--- a/src/test/ui/issues/issue-58856-2.stderr
+++ b/src/test/ui/issues/issue-58856-2.stderr
@@ -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
diff --git a/src/test/ui/issues/issue-60075.rs b/src/test/ui/issues/issue-60075.rs
index 1323f646be8..e89d78ee8a6 100644
--- a/src/test/ui/issues/issue-60075.rs
+++ b/src/test/ui/issues/issue-60075.rs
@@ -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)
     }
diff --git a/src/test/ui/issues/issue-60075.stderr b/src/test/ui/issues/issue-60075.stderr
index bab50a53b1a..e3b7f4ad420 100644
--- a/src/test/ui/issues/issue-60075.stderr
+++ b/src/test/ui/issues/issue-60075.stderr
@@ -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
 
diff --git a/src/test/ui/parser/assoc-static-semantic-fail.rs b/src/test/ui/parser/assoc-static-semantic-fail.rs
index cf3debd77cb..da4015a4620 100644
--- a/src/test/ui/parser/assoc-static-semantic-fail.rs
+++ b/src/test/ui/parser/assoc-static-semantic-fail.rs
@@ -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
 }
diff --git a/src/test/ui/parser/assoc-static-semantic-fail.stderr b/src/test/ui/parser/assoc-static-semantic-fail.stderr
index dfd0053fda2..ca05b05e9b1 100644
--- a/src/test/ui/parser/assoc-static-semantic-fail.stderr
+++ b/src/test/ui/parser/assoc-static-semantic-fail.stderr
@@ -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`.
diff --git a/src/test/ui/parser/attrs-after-extern-mod.stderr b/src/test/ui/parser/attrs-after-extern-mod.stderr
index 6060f3afe1e..3862f5c379f 100644
--- a/src/test/ui/parser/attrs-after-extern-mod.stderr
+++ b/src/test/ui/parser/attrs-after-extern-mod.stderr
@@ -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
 
diff --git a/src/test/ui/parser/default-on-wrong-item-kind.rs b/src/test/ui/parser/default-on-wrong-item-kind.rs
index 0fe20473587..16bb7735c90 100644
--- a/src/test/ui/parser/default-on-wrong-item-kind.rs
+++ b/src/test/ui/parser/default-on-wrong-item-kind.rs
@@ -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`
+}
diff --git a/src/test/ui/parser/default-on-wrong-item-kind.stderr b/src/test/ui/parser/default-on-wrong-item-kind.stderr
index e089bbbddde..1812c45eba6 100644
--- a/src/test/ui/parser/default-on-wrong-item-kind.stderr
+++ b/src/test/ui/parser/default-on-wrong-item-kind.stderr
@@ -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
 
diff --git a/src/test/ui/parser/default-unmatched-assoc.rs b/src/test/ui/parser/default-unmatched-assoc.rs
new file mode 100644
index 00000000000..bca6f5654db
--- /dev/null
+++ b/src/test/ui/parser/default-unmatched-assoc.rs
@@ -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
+}
diff --git a/src/test/ui/parser/default-unmatched-assoc.stderr b/src/test/ui/parser/default-unmatched-assoc.stderr
new file mode 100644
index 00000000000..f3877f2ca6d
--- /dev/null
+++ b/src/test/ui/parser/default-unmatched-assoc.stderr
@@ -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
+
diff --git a/src/test/ui/parser/default.rs b/src/test/ui/parser/default.rs
index 50952eef22f..bd9ed0f4524 100644
--- a/src/test/ui/parser/default.rs
+++ b/src/test/ui/parser/default.rs
@@ -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() {}
diff --git a/src/test/ui/parser/default.stderr b/src/test/ui/parser/default.stderr
index 07b051ece2b..fbf8101c36a 100644
--- a/src/test/ui/parser/default.stderr
+++ b/src/test/ui/parser/default.stderr
@@ -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`.
diff --git a/src/test/ui/parser/extern-no-fn.stderr b/src/test/ui/parser/extern-no-fn.stderr
index 02320125014..0151cb4235b 100644
--- a/src/test/ui/parser/extern-no-fn.stderr
+++ b/src/test/ui/parser/extern-no-fn.stderr
@@ -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
 
diff --git a/src/test/ui/parser/issue-19398.rs b/src/test/ui/parser/issue-19398.rs
index 014c930ef82..46eb320a172 100644
--- a/src/test/ui/parser/issue-19398.rs
+++ b/src/test/ui/parser/issue-19398.rs
@@ -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() {}
diff --git a/src/test/ui/parser/issue-19398.stderr b/src/test/ui/parser/issue-19398.stderr
index b38b39f9bd9..1da00960adf 100644
--- a/src/test/ui/parser/issue-19398.stderr
+++ b/src/test/ui/parser/issue-19398.stderr
@@ -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
 
diff --git a/src/test/ui/parser/issue-20711-2.stderr b/src/test/ui/parser/issue-20711-2.stderr
index 10ef31584de..12b18bbc594 100644
--- a/src/test/ui/parser/issue-20711-2.stderr
+++ b/src/test/ui/parser/issue-20711-2.stderr
@@ -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
 
diff --git a/src/test/ui/parser/issue-20711.stderr b/src/test/ui/parser/issue-20711.stderr
index 66768de5694..4af4b22bee2 100644
--- a/src/test/ui/parser/issue-20711.stderr
+++ b/src/test/ui/parser/issue-20711.stderr
@@ -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
 
diff --git a/src/test/ui/parser/issue-21153.rs b/src/test/ui/parser/issue-21153.rs
index 4fe05e6f041..bf5fdb1f3c6 100644
--- a/src/test/ui/parser/issue-21153.rs
+++ b/src/test/ui/parser/issue-21153.rs
@@ -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() {}
diff --git a/src/test/ui/parser/issue-21153.stderr b/src/test/ui/parser/issue-21153.stderr
index e9824bd7290..cbfa9ded3c3 100644
--- a/src/test/ui/parser/issue-21153.stderr
+++ b/src/test/ui/parser/issue-21153.stderr
@@ -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
 
diff --git a/src/test/ui/parser/issue-32446.stderr b/src/test/ui/parser/issue-32446.stderr
index d25828da0b9..7515369aaa0 100644
--- a/src/test/ui/parser/issue-32446.stderr
+++ b/src/test/ui/parser/issue-32446.stderr
@@ -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
 
diff --git a/src/test/ui/parser/issue-41155.rs b/src/test/ui/parser/issue-41155.rs
index 3c24d2b447d..bed4805e7ce 100644
--- a/src/test/ui/parser/issue-41155.rs
+++ b/src/test/ui/parser/issue-41155.rs
@@ -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() {}
diff --git a/src/test/ui/parser/issue-41155.stderr b/src/test/ui/parser/issue-41155.stderr
index a91ef6c67e8..a9c1035f4d8 100644
--- a/src/test/ui/parser/issue-41155.stderr
+++ b/src/test/ui/parser/issue-41155.stderr
@@ -1,10 +1,22 @@
-error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `static`, `type`, `unsafe`, or identifier, found `}`
+error: unmatched visibility `pub`
+  --> $DIR/issue-41155.rs:4:5
+   |
+LL |     pub
+   |     ^^^ 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
-   |        - expected one of 10 possible tokens
 LL | }
-   | ^ unexpected token
+   | ^
+   | |
+   | non-item starts here
+   | item list ends here
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/parser/issue-6610.stderr b/src/test/ui/parser/issue-6610.stderr
index 22d93bffead..a9804208946 100644
--- a/src/test/ui/parser/issue-6610.stderr
+++ b/src/test/ui/parser/issue-6610.stderr
@@ -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
 
diff --git a/src/test/ui/parser/macro/trait-non-item-macros.rs b/src/test/ui/parser/macro/trait-non-item-macros.rs
index 5021886bf98..97fb564bf64 100644
--- a/src/test/ui/parser/macro/trait-non-item-macros.rs
+++ b/src/test/ui/parser/macro/trait-non-item-macros.rs
@@ -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
+}
diff --git a/src/test/ui/parser/macro/trait-non-item-macros.stderr b/src/test/ui/parser/macro/trait-non-item-macros.stderr
index c76b096a1eb..35e5bfe62f5 100644
--- a/src/test/ui/parser/macro/trait-non-item-macros.stderr
+++ b/src/test/ui/parser/macro/trait-non-item-macros.stderr
@@ -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`.
diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs
index 748db8983b5..d85255328f7 100644
--- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs
+++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.rs
@@ -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
diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr
index 240be39eace..2b72c06c9c7 100644
--- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr
+++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr
@@ -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`.
diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs
index 4e8cc6489bc..b2515b17ff3 100644
--- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs
+++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.rs
@@ -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) {}
 }
 
diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr
index 54afad5755b..89bf2916510 100644
--- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr
+++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr
@@ -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`.
diff --git a/src/test/ui/parser/removed-syntax-static-fn.stderr b/src/test/ui/parser/removed-syntax-static-fn.stderr
index dc5625bdade..04e34dc16a8 100644
--- a/src/test/ui/parser/removed-syntax-static-fn.stderr
+++ b/src/test/ui/parser/removed-syntax-static-fn.stderr
@@ -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