X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_hir%2Fsrc%2Fdef.rs;h=e7c26bd726fbfd69fa45532d5658d752de9a4232;hb=cafca7d2197e3fbfbd9efe8870fb0fa559e11fb3;hp=2d2648a8f35af5e586d70b998e4407a8e5251713;hpb=75e7bb842a23dcc39ace3032adf99c7e03b5e442;p=rust.git diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 2d2648a8f35..e7c26bd726f 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -109,6 +109,8 @@ pub enum DefKind { InlineConst, /// Opaque type, aka `impl Trait`. OpaqueTy, + /// A return-position `impl Trait` in a trait definition + ImplTraitPlaceholder, Field, /// Lifetime parameter: the `'a` in `struct Foo<'a> { ... }` LifetimeParam, @@ -138,6 +140,7 @@ pub fn descr(self, def_id: DefId) -> &'static str { panic!("impossible struct constructor") } DefKind::OpaqueTy => "opaque type", + DefKind::ImplTraitPlaceholder => "opaque type in trait", DefKind::TyAlias => "type alias", DefKind::TraitAlias => "trait alias", DefKind::AssocTy => "associated type", @@ -217,7 +220,8 @@ pub fn ns(&self) -> Option { | DefKind::Use | DefKind::ForeignMod | DefKind::GlobalAsm - | DefKind::Impl => None, + | DefKind::Impl + | DefKind::ImplTraitPlaceholder => None, } } @@ -254,6 +258,7 @@ pub fn has_codegen_attrs(self) -> bool { | DefKind::Use | DefKind::ForeignMod | DefKind::OpaqueTy + | DefKind::ImplTraitPlaceholder | DefKind::Impl | DefKind::Field | DefKind::TyParam @@ -308,6 +313,7 @@ pub enum Res { /// /// **Belongs to the type namespace.** PrimTy(hir::PrimTy), + /// The `Self` type, optionally with the [`DefId`] of the trait it belongs to and /// optionally with the [`DefId`] of the item introducing the `Self` type alias. /// @@ -355,7 +361,8 @@ pub enum Res { /// const fn baz() -> usize { 10 } /// ``` /// We do however allow `Self` in repeat expression even if it is generic to not break code - /// which already works on stable while causing the `const_evaluatable_unchecked` future compat lint: + /// which already works on stable while causing the `const_evaluatable_unchecked` future compat + /// lint: /// ``` /// fn foo() { /// let _bar = [1_u8; std::mem::size_of::<*mut T>()]; @@ -370,6 +377,7 @@ pub enum Res { /// from mentioning generics (i.e. when used in an anonymous constant). alias_to: Option<(DefId, bool)>, }, + /// A tool attribute module; e.g., the `rustfmt` in `#[rustfmt::skip]`. /// /// **Belongs to the type namespace.** @@ -383,6 +391,7 @@ pub enum Res { /// /// *See also [`Res::SelfTy`].* SelfCtor(DefId), + /// A local variable or function parameter. /// /// **Belongs to the value namespace.** @@ -453,7 +462,7 @@ pub fn unresolved_segments(&self) -> usize { /// Different kinds of symbols can coexist even if they share the same textual name. /// Therefore, they each have a separate universe (known as a "namespace"). -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum Namespace { /// The type namespace includes `struct`s, `enum`s, `union`s, `trait`s, and `mod`s /// (and, by extension, crates).