about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2019-11-09 18:01:12 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2019-11-10 12:24:22 +0100
commitf03cbc313ddc16d7aba6c21c197a52ee4d2e85e9 (patch)
treec56c0afcbd78bbec0d00c556dacf89b65b2f0e94 /src
parent1f21c080ebee10e0ad14197e7d7dbfcb687e303a (diff)
Merge hir::Unsafety into ast::Unsafety.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/lowering.rs2
-rw-r--r--src/librustc/hir/lowering/item.rs13
-rw-r--r--src/librustc/hir/mod.rs27
-rw-r--r--src/libsyntax/ast.rs36
4 files changed, 28 insertions, 50 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
index a22db239d28..02afdc27acd 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -1213,7 +1213,7 @@ impl<'a> LoweringContext<'a> {
                                     &NodeMap::default(),
                                     ImplTraitContext::disallowed(),
                                 ),
-                                unsafety: this.lower_unsafety(f.unsafety),
+                                unsafety: f.unsafety,
                                 abi: this.lower_abi(f.abi),
                                 decl: this.lower_fn_decl(&f.decl, None, false, None),
                                 param_names: this.lower_fn_params_to_names(&f.decl),
diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs
index 2d03e92139e..bf288f271a6 100644
--- a/src/librustc/hir/lowering/item.rs
+++ b/src/librustc/hir/lowering/item.rs
@@ -433,7 +433,7 @@ impl LoweringContext<'_> {
                 );
 
                 hir::ItemKind::Impl(
-                    self.lower_unsafety(unsafety),
+                    unsafety,
                     self.lower_impl_polarity(polarity),
                     self.lower_defaultness(defaultness, true /* [1] */),
                     generics,
@@ -450,7 +450,7 @@ impl LoweringContext<'_> {
                     .collect();
                 hir::ItemKind::Trait(
                     self.lower_is_auto(is_auto),
-                    self.lower_unsafety(unsafety),
+                    unsafety,
                     self.lower_generics(generics, ImplTraitContext::disallowed()),
                     bounds,
                     items,
@@ -1284,7 +1284,7 @@ impl LoweringContext<'_> {
 
     fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
         hir::FnHeader {
-            unsafety: self.lower_unsafety(h.unsafety),
+            unsafety: h.unsafety,
             asyncness: self.lower_asyncness(h.asyncness.node),
             constness: h.constness.node,
             abi: self.lower_abi(h.abi),
@@ -1311,13 +1311,6 @@ impl LoweringContext<'_> {
         .emit();
     }
 
-    pub(super) fn lower_unsafety(&mut self, u: Unsafety) -> hir::Unsafety {
-        match u {
-            Unsafety::Unsafe => hir::Unsafety::Unsafe,
-            Unsafety::Normal => hir::Unsafety::Normal,
-        }
-    }
-
     fn lower_asyncness(&mut self, a: IsAsync) -> hir::IsAsync {
         match a {
             IsAsync::Async { .. } => hir::IsAsync::Async,
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 63d4ba6d8b7..645d7b5fdb0 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -22,7 +22,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};
+pub use syntax::ast::{Mutability, Constness, Unsafety};
 use syntax::attr::{InlineAttr, OptimizeAttr};
 use syntax::symbol::{Symbol, kw};
 use syntax::tokenstream::TokenStream;
@@ -2154,22 +2154,6 @@ pub enum IsAsync {
     NotAsync,
 }
 
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
-         RustcEncodable, RustcDecodable, Hash, Debug)]
-pub enum Unsafety {
-    Unsafe,
-    Normal,
-}
-
-impl Unsafety {
-    pub fn prefix_str(&self) -> &'static str {
-        match self {
-            Unsafety::Unsafe => "unsafe ",
-            Unsafety::Normal => "",
-        }
-    }
-}
-
 #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
 pub enum Defaultness {
     Default { has_value: bool },
@@ -2196,15 +2180,6 @@ impl Defaultness {
     }
 }
 
-impl fmt::Display for Unsafety {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.write_str(match self {
-            Unsafety::Normal => "normal",
-            Unsafety::Unsafe => "unsafe",
-        })
-    }
-}
-
 #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
 pub enum ImplPolarity {
     /// `impl Trait for Type`
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index b0f83f03f62..887d7beed6d 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1991,12 +1991,34 @@ pub enum IsAuto {
     No,
 }
 
-#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
+         RustcEncodable, RustcDecodable, Debug)]
 pub enum Unsafety {
     Unsafe,
     Normal,
 }
 
+impl Unsafety {
+    pub fn prefix_str(&self) -> &'static str {
+        match self {
+            Unsafety::Unsafe => "unsafe ",
+            Unsafety::Normal => "",
+        }
+    }
+}
+
+impl fmt::Display for Unsafety {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        fmt::Display::fmt(
+            match *self {
+                Unsafety::Normal => "normal",
+                Unsafety::Unsafe => "unsafe",
+            },
+            f,
+        )
+    }
+}
+
 #[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
 pub enum IsAsync {
     Async {
@@ -2041,18 +2063,6 @@ pub enum Defaultness {
     Final,
 }
 
-impl fmt::Display for Unsafety {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        fmt::Display::fmt(
-            match *self {
-                Unsafety::Normal => "normal",
-                Unsafety::Unsafe => "unsafe",
-            },
-            f,
-        )
-    }
-}
-
 #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
 pub enum ImplPolarity {
     /// `impl Trait for Type`