about summary refs log tree commit diff
path: root/src/libsyntax
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/libsyntax
parent1f21c080ebee10e0ad14197e7d7dbfcb687e303a (diff)
downloadrust-f03cbc313ddc16d7aba6c21c197a52ee4d2e85e9.tar.gz
rust-f03cbc313ddc16d7aba6c21c197a52ee4d2e85e9.zip
Merge hir::Unsafety into ast::Unsafety.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs36
1 files changed, 23 insertions, 13 deletions
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`