From daff3e346c4d8a79fdf20fcc92a7919c28f53840 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 18:38:35 +0100 Subject: [PATCH] Merge hir::ImplPolarity into ast::ImplPolarity. --- src/librustc/hir/lowering/item.rs | 9 +-------- src/librustc/hir/mod.rs | 20 +------------------- src/librustc/ich/impls_syntax.rs | 1 + 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index c40834d12de1..beb10edd1484 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -434,7 +434,7 @@ impl LoweringContext<'_> { hir::ItemKind::Impl( unsafety, - self.lower_impl_polarity(polarity), + polarity, self.lower_defaultness(defaultness, true /* [1] */), generics, trait_ref, @@ -1011,13 +1011,6 @@ impl LoweringContext<'_> { } } - fn lower_impl_polarity(&mut self, i: ImplPolarity) -> hir::ImplPolarity { - match i { - ImplPolarity::Positive => hir::ImplPolarity::Positive, - ImplPolarity::Negative => hir::ImplPolarity::Negative, - } - } - fn record_body(&mut self, params: HirVec, value: hir::Expr) -> hir::BodyId { let body = hir::Body { generator_kind: self.generator_kind, diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 6f60f7ffdcfc..bbd3b40e1be9 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -21,7 +21,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan}; use syntax::source_map::Spanned; use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect}; use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy}; -pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy, IsAuto}; +pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy, IsAuto, ImplPolarity}; use syntax::attr::{InlineAttr, OptimizeAttr}; use syntax::symbol::{Symbol, kw}; use syntax::tokenstream::TokenStream; @@ -2155,24 +2155,6 @@ impl Defaultness { } } -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)] -pub enum ImplPolarity { - /// `impl Trait for Type` - Positive, - /// `impl !Trait for Type` - Negative, -} - -impl fmt::Debug for ImplPolarity { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(match self { - ImplPolarity::Positive => "positive", - ImplPolarity::Negative => "negative", - }) - } -} - - #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum FunctionRetTy { /// Return type is not specified. diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 075b7409f4f6..b3d82e5522cf 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -171,6 +171,7 @@ impl_stable_hash_for!(enum ::syntax::ast::AttrStyle { Outer, Inner }); impl_stable_hash_for!(enum ::syntax::ast::Movability { Static, Movable }); impl_stable_hash_for!(enum ::syntax::ast::CaptureBy { Value, Ref }); impl_stable_hash_for!(enum ::syntax::ast::IsAuto { Yes, No }); +impl_stable_hash_for!(enum ::syntax::ast::ImplPolarity { Positive, Negative }); impl<'a> HashStable> for [ast::Attribute] { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {