From f03cbc313ddc16d7aba6c21c197a52ee4d2e85e9 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 18:01:12 +0100 Subject: Merge hir::Unsafety into ast::Unsafety. --- src/libsyntax/ast.rs | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/libsyntax') 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` -- cgit 1.4.1-3-g733a5