parser: tweak item kind wording

This commit is contained in:
Mazdak Farrokhzad 2020-02-23 06:04:37 +01:00
parent ab84914fe4
commit b01c1e2092
12 changed files with 115 additions and 112 deletions

View File

@ -378,8 +378,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
self.cx.span_err( self.cx.span_err(
span, span,
&format!( &format!(
"expected crate top-level item to be a module after macro expansion, found a {}", "expected crate top-level item to be a module after macro expansion, found {} {}",
kind.descriptive_variant() kind.article(), kind.descr()
), ),
); );
} }

View File

@ -2500,16 +2500,16 @@ pub enum ItemKind<'hir> {
} }
impl ItemKind<'_> { impl ItemKind<'_> {
pub fn descriptive_variant(&self) -> &str { pub fn descr(&self) -> &str {
match *self { match *self {
ItemKind::ExternCrate(..) => "extern crate", ItemKind::ExternCrate(..) => "extern crate",
ItemKind::Use(..) => "use", ItemKind::Use(..) => "`use` import",
ItemKind::Static(..) => "static item", ItemKind::Static(..) => "static item",
ItemKind::Const(..) => "constant item", ItemKind::Const(..) => "constant item",
ItemKind::Fn(..) => "function", ItemKind::Fn(..) => "function",
ItemKind::Mod(..) => "module", ItemKind::Mod(..) => "module",
ItemKind::ForeignMod(..) => "foreign module", ItemKind::ForeignMod(..) => "extern block",
ItemKind::GlobalAsm(..) => "global asm", ItemKind::GlobalAsm(..) => "global asm item",
ItemKind::TyAlias(..) => "type alias", ItemKind::TyAlias(..) => "type alias",
ItemKind::OpaqueTy(..) => "opaque type", ItemKind::OpaqueTy(..) => "opaque type",
ItemKind::Enum(..) => "enum", ItemKind::Enum(..) => "enum",
@ -2517,7 +2517,7 @@ impl ItemKind<'_> {
ItemKind::Union(..) => "union", ItemKind::Union(..) => "union",
ItemKind::Trait(..) => "trait", ItemKind::Trait(..) => "trait",
ItemKind::TraitAlias(..) => "trait alias", ItemKind::TraitAlias(..) => "trait alias",
ItemKind::Impl { .. } => "impl", ItemKind::Impl { .. } => "implementation",
} }
} }

View File

@ -661,12 +661,7 @@ impl<'a> Parser<'a> {
self.struct_span_err(span, "associated `static` items are not allowed").emit(); self.struct_span_err(span, "associated `static` items are not allowed").emit();
AssocItemKind::Const(a, b) AssocItemKind::Const(a, b)
} }
_ => { _ => return self.error_bad_item_kind(span, &kind, "`trait` or `impl`"),
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 })) Some(P(Item { attrs, id, span, vis, ident, defaultness, kind, tokens }))
})) }))
@ -858,16 +853,19 @@ impl<'a> Parser<'a> {
self.error_on_foreign_const(span, ident); self.error_on_foreign_const(span, ident);
ForeignItemKind::Static(a, Mutability::Not, b) ForeignItemKind::Static(a, Mutability::Not, b)
} }
_ => { _ => return self.error_bad_item_kind(span, &kind, "`extern` block"),
let span = self.sess.source_map().def_span(span);
self.struct_span_err(span, "item kind not supported in `extern` block").emit();
return None;
}
}; };
Some(P(Item { attrs, id, span, vis, ident, defaultness, kind, tokens })) Some(P(Item { attrs, id, span, vis, ident, defaultness, kind, tokens }))
})) }))
} }
fn error_bad_item_kind<T>(&self, span: Span, kind: &ItemKind, ctx: &str) -> Option<T> {
let span = self.sess.source_map().def_span(span);
let msg = format!("{} not supported in {}", kind.descr(), ctx);
self.struct_span_err(span, &msg).emit();
return None;
}
fn error_on_foreign_const(&self, span: Span, ident: Ident) { fn error_on_foreign_const(&self, span: Span, ident: Ident) {
self.struct_span_err(ident.span, "extern items cannot be `const`") self.struct_span_err(ident.span, "extern items cannot be `const`")
.span_suggestion( .span_suggestion(

View File

@ -601,13 +601,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
hir::ItemKind::Struct(..) => "constructed", // Issue #52325 hir::ItemKind::Struct(..) => "constructed", // Issue #52325
_ => "used", _ => "used",
}; };
self.warn_dead_code( self.warn_dead_code(item.hir_id, span, item.ident.name, item.kind.descr(), participle);
item.hir_id,
span,
item.ident.name,
item.kind.descriptive_variant(),
participle,
);
} else { } else {
// Only continue if we didn't warn // Only continue if we didn't warn
intravisit::walk_item(self, item); intravisit::walk_item(self, item);

View File

@ -362,7 +362,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
// optional. They inherit stability from their parents when unannotated. // optional. They inherit stability from their parents when unannotated.
hir::ItemKind::Impl { of_trait: None, .. } | hir::ItemKind::ForeignMod(..) => {} hir::ItemKind::Impl { of_trait: None, .. } | hir::ItemKind::ForeignMod(..) => {}
_ => self.check_missing_stability(i.hir_id, i.span, i.kind.descriptive_variant()), _ => self.check_missing_stability(i.hir_id, i.span, i.kind.descr()),
} }
intravisit::walk_item(self, i) intravisit::walk_item(self, i)

View File

@ -2574,23 +2574,34 @@ pub enum ItemKind {
} }
impl ItemKind { impl ItemKind {
pub fn descriptive_variant(&self) -> &str { pub fn article(&self) -> &str {
match *self { use ItemKind::*;
match self {
Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
| Struct(..) | Union(..) | Trait(..) | TraitAlias(..) | MacroDef(..) => "a",
ExternCrate(..) | ForeignMod(..) | Mac(..) | Enum(..) | Impl { .. } => "an",
}
}
pub fn descr(&self) -> &str {
match self {
ItemKind::ExternCrate(..) => "extern crate", ItemKind::ExternCrate(..) => "extern crate",
ItemKind::Use(..) => "use", ItemKind::Use(..) => "`use` import",
ItemKind::Static(..) => "static item", ItemKind::Static(..) => "static item",
ItemKind::Const(..) => "constant item", ItemKind::Const(..) => "constant item",
ItemKind::Fn(..) => "function", ItemKind::Fn(..) => "function",
ItemKind::Mod(..) => "module", ItemKind::Mod(..) => "module",
ItemKind::ForeignMod(..) => "foreign module", ItemKind::ForeignMod(..) => "extern block",
ItemKind::GlobalAsm(..) => "global asm", ItemKind::GlobalAsm(..) => "global asm item",
ItemKind::TyAlias(..) => "type alias", ItemKind::TyAlias(..) => "type alias",
ItemKind::Enum(..) => "enum", ItemKind::Enum(..) => "enum",
ItemKind::Struct(..) => "struct", ItemKind::Struct(..) => "struct",
ItemKind::Union(..) => "union", ItemKind::Union(..) => "union",
ItemKind::Trait(..) => "trait", ItemKind::Trait(..) => "trait",
ItemKind::TraitAlias(..) => "trait alias", ItemKind::TraitAlias(..) => "trait alias",
ItemKind::Mac(..) | ItemKind::MacroDef(..) | ItemKind::Impl { .. } => "item", ItemKind::Mac(..) => "item macro invocation",
ItemKind::MacroDef(..) => "macro definition",
ItemKind::Impl { .. } => "implementation",
} }
} }

View File

@ -31,110 +31,110 @@ mod free_items {
#[cfg(FALSE)] #[cfg(FALSE)]
extern "C" { extern "C" {
default extern crate foo; //~ ERROR item cannot be `default` default extern crate foo; //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR extern crate not supported in `extern` block
default use foo; //~ ERROR item cannot be `default` default use foo; //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR `use` import not supported in `extern` block
default static foo: u8; //~ ERROR item cannot be `default` default static foo: u8; //~ ERROR item cannot be `default`
default const foo: u8; //~ ERROR item cannot be `default` default const foo: u8; //~ ERROR item cannot be `default`
//~^ ERROR extern items cannot be `const` //~^ ERROR extern items cannot be `const`
default fn foo(); //~ ERROR item cannot be `default` default fn foo(); //~ ERROR item cannot be `default`
default mod foo {} //~ ERROR item cannot be `default` default mod foo {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR module not supported in `extern` block
default extern "C" {} //~ ERROR item cannot be `default` default extern "C" {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR extern block not supported in `extern` block
default type foo = u8; //~ ERROR item cannot be `default` default type foo = u8; //~ ERROR item cannot be `default`
default enum foo {} //~ ERROR item cannot be `default` default enum foo {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR enum not supported in `extern` block
default struct foo {} //~ ERROR item cannot be `default` default struct foo {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR struct not supported in `extern` block
default union foo {} //~ ERROR item cannot be `default` default union foo {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR union not supported in `extern` block
default trait foo {} //~ ERROR item cannot be `default` default trait foo {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR trait not supported in `extern` block
default trait foo = Ord; //~ ERROR item cannot be `default` default trait foo = Ord; //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR trait alias not supported in `extern` block
default impl foo {} default impl foo {}
//~^ ERROR item kind not supported in `extern` block //~^ ERROR implementation not supported in `extern` block
default!(); default!();
default::foo::bar!(); default::foo::bar!();
default default!(); //~ ERROR item cannot be `default` default default!(); //~ ERROR item cannot be `default`
default default::foo::bar!(); //~ ERROR item cannot be `default` default default::foo::bar!(); //~ ERROR item cannot be `default`
default macro foo {} //~ ERROR item cannot be `default` default macro foo {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR macro definition not supported in `extern` block
default macro_rules! foo {} //~ ERROR item cannot be `default` default macro_rules! foo {} //~ ERROR item cannot be `default`
//~^ ERROR item kind not supported in `extern` block //~^ ERROR macro definition not supported in `extern` block
} }
#[cfg(FALSE)] #[cfg(FALSE)]
impl S { impl S {
default extern crate foo; default extern crate foo;
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR extern crate not supported in `trait` or `impl`
default use foo; default use foo;
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR `use` import not supported in `trait` or `impl`
default static foo: u8; default static foo: u8;
//~^ ERROR associated `static` items are not allowed //~^ ERROR associated `static` items are not allowed
default const foo: u8; default const foo: u8;
default fn foo(); default fn foo();
default mod foo {} default mod foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR module not supported in `trait` or `impl`
default extern "C" {} default extern "C" {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR extern block not supported in `trait` or `impl`
default type foo = u8; default type foo = u8;
default enum foo {} default enum foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR enum not supported in `trait` or `impl`
default struct foo {} default struct foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR struct not supported in `trait` or `impl`
default union foo {} default union foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR union not supported in `trait` or `impl`
default trait foo {} default trait foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR trait not supported in `trait` or `impl`
default trait foo = Ord; default trait foo = Ord;
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR trait alias not supported in `trait` or `impl`
default impl foo {} default impl foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR implementation not supported in `trait` or `impl`
default!(); default!();
default::foo::bar!(); default::foo::bar!();
default default!(); default default!();
default default::foo::bar!(); default default::foo::bar!();
default macro foo {} default macro foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR macro definition not supported in `trait` or `impl`
default macro_rules! foo {} default macro_rules! foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR macro definition not supported in `trait` or `impl`
} }
#[cfg(FALSE)] #[cfg(FALSE)]
trait T { trait T {
default extern crate foo; default extern crate foo;
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR extern crate not supported in `trait` or `impl`
default use foo; default use foo;
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR `use` import not supported in `trait` or `impl`
default static foo: u8; default static foo: u8;
//~^ ERROR associated `static` items are not allowed //~^ ERROR associated `static` items are not allowed
default const foo: u8; default const foo: u8;
default fn foo(); default fn foo();
default mod foo {} default mod foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR module not supported in `trait` or `impl`
default extern "C" {} default extern "C" {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR extern block not supported in `trait` or `impl`
default type foo = u8; default type foo = u8;
default enum foo {} default enum foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR enum not supported in `trait` or `impl`
default struct foo {} default struct foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR struct not supported in `trait` or `impl`
default union foo {} default union foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR union not supported in `trait` or `impl`
default trait foo {} default trait foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR trait not supported in `trait` or `impl`
default trait foo = Ord; default trait foo = Ord;
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR trait alias not supported in `trait` or `impl`
default impl foo {} default impl foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR implementation not supported in `trait` or `impl`
default!(); default!();
default::foo::bar!(); default::foo::bar!();
default default!(); default default!();
default default::foo::bar!(); default default::foo::bar!();
default macro foo {} default macro foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR macro definition not supported in `trait` or `impl`
default macro_rules! foo {} default macro_rules! foo {}
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR macro definition not supported in `trait` or `impl`
} }

View File

@ -142,7 +142,7 @@ LL | default extern crate foo;
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: extern crate not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:33:5 --> $DIR/default-on-wrong-item-kind.rs:33:5
| |
LL | default extern crate foo; LL | default extern crate foo;
@ -156,7 +156,7 @@ LL | default use foo;
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: `use` import not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:35:5 --> $DIR/default-on-wrong-item-kind.rs:35:5
| |
LL | default use foo; LL | default use foo;
@ -204,7 +204,7 @@ LL | default mod foo {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: module not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:41:5 --> $DIR/default-on-wrong-item-kind.rs:41:5
| |
LL | default mod foo {} LL | default mod foo {}
@ -218,7 +218,7 @@ LL | default extern "C" {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: extern block not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:43:5 --> $DIR/default-on-wrong-item-kind.rs:43:5
| |
LL | default extern "C" {} LL | default extern "C" {}
@ -240,7 +240,7 @@ LL | default enum foo {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: enum not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:46:5 --> $DIR/default-on-wrong-item-kind.rs:46:5
| |
LL | default enum foo {} LL | default enum foo {}
@ -254,7 +254,7 @@ LL | default struct foo {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: struct not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:48:5 --> $DIR/default-on-wrong-item-kind.rs:48:5
| |
LL | default struct foo {} LL | default struct foo {}
@ -268,7 +268,7 @@ LL | default union foo {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: union not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:50:5 --> $DIR/default-on-wrong-item-kind.rs:50:5
| |
LL | default union foo {} LL | default union foo {}
@ -282,7 +282,7 @@ LL | default trait foo {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: trait not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:52:5 --> $DIR/default-on-wrong-item-kind.rs:52:5
| |
LL | default trait foo {} LL | default trait foo {}
@ -296,13 +296,13 @@ LL | default trait foo = Ord;
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: trait alias not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:54:5 --> $DIR/default-on-wrong-item-kind.rs:54:5
| |
LL | default trait foo = Ord; LL | default trait foo = Ord;
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `extern` block error: implementation not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:56:5 --> $DIR/default-on-wrong-item-kind.rs:56:5
| |
LL | default impl foo {} LL | default impl foo {}
@ -332,7 +332,7 @@ LL | default macro foo {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: macro definition not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:62:5 --> $DIR/default-on-wrong-item-kind.rs:62:5
| |
LL | default macro foo {} LL | default macro foo {}
@ -346,19 +346,19 @@ LL | default macro_rules! foo {}
| |
= note: only associated `fn`, `const`, and `type` items can be `default` = note: only associated `fn`, `const`, and `type` items can be `default`
error: item kind not supported in `extern` block error: macro definition not supported in `extern` block
--> $DIR/default-on-wrong-item-kind.rs:64:5 --> $DIR/default-on-wrong-item-kind.rs:64:5
| |
LL | default macro_rules! foo {} LL | default macro_rules! foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: extern crate not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:70:5 --> $DIR/default-on-wrong-item-kind.rs:70:5
| |
LL | default extern crate foo; LL | default extern crate foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: `use` import not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:72:5 --> $DIR/default-on-wrong-item-kind.rs:72:5
| |
LL | default use foo; LL | default use foo;
@ -370,73 +370,73 @@ error: associated `static` items are not allowed
LL | default static foo: u8; LL | default static foo: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: module not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:78:5 --> $DIR/default-on-wrong-item-kind.rs:78:5
| |
LL | default mod foo {} LL | default mod foo {}
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: extern block not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:80:5 --> $DIR/default-on-wrong-item-kind.rs:80:5
| |
LL | default extern "C" {} LL | default extern "C" {}
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: enum not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:83:5 --> $DIR/default-on-wrong-item-kind.rs:83:5
| |
LL | default enum foo {} LL | default enum foo {}
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: struct not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:85:5 --> $DIR/default-on-wrong-item-kind.rs:85:5
| |
LL | default struct foo {} LL | default struct foo {}
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: union not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:87:5 --> $DIR/default-on-wrong-item-kind.rs:87:5
| |
LL | default union foo {} LL | default union foo {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: trait not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:89:5 --> $DIR/default-on-wrong-item-kind.rs:89:5
| |
LL | default trait foo {} LL | default trait foo {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: trait alias not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:91:5 --> $DIR/default-on-wrong-item-kind.rs:91:5
| |
LL | default trait foo = Ord; LL | default trait foo = Ord;
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: implementation not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:93:5 --> $DIR/default-on-wrong-item-kind.rs:93:5
| |
LL | default impl foo {} LL | default impl foo {}
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: macro definition not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:99:5 --> $DIR/default-on-wrong-item-kind.rs:99:5
| |
LL | default macro foo {} LL | default macro foo {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: macro definition not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:101:5 --> $DIR/default-on-wrong-item-kind.rs:101:5
| |
LL | default macro_rules! foo {} LL | default macro_rules! foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: extern crate not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:107:5 --> $DIR/default-on-wrong-item-kind.rs:107:5
| |
LL | default extern crate foo; LL | default extern crate foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: `use` import not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:109:5 --> $DIR/default-on-wrong-item-kind.rs:109:5
| |
LL | default use foo; LL | default use foo;
@ -448,61 +448,61 @@ error: associated `static` items are not allowed
LL | default static foo: u8; LL | default static foo: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: module not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:115:5 --> $DIR/default-on-wrong-item-kind.rs:115:5
| |
LL | default mod foo {} LL | default mod foo {}
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: extern block not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:117:5 --> $DIR/default-on-wrong-item-kind.rs:117:5
| |
LL | default extern "C" {} LL | default extern "C" {}
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: enum not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:120:5 --> $DIR/default-on-wrong-item-kind.rs:120:5
| |
LL | default enum foo {} LL | default enum foo {}
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: struct not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:122:5 --> $DIR/default-on-wrong-item-kind.rs:122:5
| |
LL | default struct foo {} LL | default struct foo {}
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: union not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:124:5 --> $DIR/default-on-wrong-item-kind.rs:124:5
| |
LL | default union foo {} LL | default union foo {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: trait not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:126:5 --> $DIR/default-on-wrong-item-kind.rs:126:5
| |
LL | default trait foo {} LL | default trait foo {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: trait alias not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:128:5 --> $DIR/default-on-wrong-item-kind.rs:128:5
| |
LL | default trait foo = Ord; LL | default trait foo = Ord;
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: implementation not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:130:5 --> $DIR/default-on-wrong-item-kind.rs:130:5
| |
LL | default impl foo {} LL | default impl foo {}
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: macro definition not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:136:5 --> $DIR/default-on-wrong-item-kind.rs:136:5
| |
LL | default macro foo {} LL | default macro foo {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: macro definition not supported in `trait` or `impl`
--> $DIR/default-on-wrong-item-kind.rs:138:5 --> $DIR/default-on-wrong-item-kind.rs:138:5
| |
LL | default macro_rules! foo {} LL | default macro_rules! foo {}

View File

@ -4,10 +4,10 @@ impl T for () { //~ ERROR cannot find trait `T` in this scope
fn foo(&self) {} fn foo(&self) {}
trait T { //~ ERROR item kind not supported in `trait` or `impl` trait T { //~ ERROR trait not supported in `trait` or `impl`
fn foo(&self); fn foo(&self);
} }
pub(crate) struct Bar<T>(); //~ ERROR item kind not supported in `trait` or `impl` pub(crate) struct Bar<T>(); //~ ERROR struct not supported in `trait` or `impl`
//~ ERROR this file contains an unclosed delimiter //~ ERROR this file contains an unclosed delimiter

View File

@ -7,13 +7,13 @@ LL | impl T for () {
LL | LL |
| ^ | ^
error: item kind not supported in `trait` or `impl` error: trait not supported in `trait` or `impl`
--> $DIR/missing-close-brace-in-impl-trait.rs:7:1 --> $DIR/missing-close-brace-in-impl-trait.rs:7:1
| |
LL | trait T { LL | trait T {
| ^^^^^^^ | ^^^^^^^
error: item kind not supported in `trait` or `impl` error: struct not supported in `trait` or `impl`
--> $DIR/missing-close-brace-in-impl-trait.rs:11:1 --> $DIR/missing-close-brace-in-impl-trait.rs:11:1
| |
LL | pub(crate) struct Bar<T>(); LL | pub(crate) struct Bar<T>();

View File

@ -2,10 +2,10 @@ trait T {
fn foo(&self); fn foo(&self);
pub(crate) struct Bar<T>(); pub(crate) struct Bar<T>();
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR struct not supported in `trait` or `impl`
impl T for Bar<usize> { impl T for Bar<usize> {
//~^ ERROR item kind not supported in `trait` or `impl` //~^ ERROR implementation not supported in `trait` or `impl`
fn foo(&self) {} fn foo(&self) {}
} }

View File

@ -7,13 +7,13 @@ LL | trait T {
LL | fn main() {} LL | fn main() {}
| ^ | ^
error: item kind not supported in `trait` or `impl` error: struct not supported in `trait` or `impl`
--> $DIR/missing-close-brace-in-trait.rs:4:1 --> $DIR/missing-close-brace-in-trait.rs:4:1
| |
LL | pub(crate) struct Bar<T>(); LL | pub(crate) struct Bar<T>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: item kind not supported in `trait` or `impl` error: implementation not supported in `trait` or `impl`
--> $DIR/missing-close-brace-in-trait.rs:7:1 --> $DIR/missing-close-brace-in-trait.rs:7:1
| |
LL | impl T for Bar<usize> { LL | impl T for Bar<usize> {