Merge hir::Unsafety into ast::Unsafety.
This commit is contained in:
parent
1f21c080eb
commit
f03cbc313d
4 changed files with 28 additions and 50 deletions
|
@ -1213,7 +1213,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
&NodeMap::default(),
|
&NodeMap::default(),
|
||||||
ImplTraitContext::disallowed(),
|
ImplTraitContext::disallowed(),
|
||||||
),
|
),
|
||||||
unsafety: this.lower_unsafety(f.unsafety),
|
unsafety: f.unsafety,
|
||||||
abi: this.lower_abi(f.abi),
|
abi: this.lower_abi(f.abi),
|
||||||
decl: this.lower_fn_decl(&f.decl, None, false, None),
|
decl: this.lower_fn_decl(&f.decl, None, false, None),
|
||||||
param_names: this.lower_fn_params_to_names(&f.decl),
|
param_names: this.lower_fn_params_to_names(&f.decl),
|
||||||
|
|
|
@ -433,7 +433,7 @@ impl LoweringContext<'_> {
|
||||||
);
|
);
|
||||||
|
|
||||||
hir::ItemKind::Impl(
|
hir::ItemKind::Impl(
|
||||||
self.lower_unsafety(unsafety),
|
unsafety,
|
||||||
self.lower_impl_polarity(polarity),
|
self.lower_impl_polarity(polarity),
|
||||||
self.lower_defaultness(defaultness, true /* [1] */),
|
self.lower_defaultness(defaultness, true /* [1] */),
|
||||||
generics,
|
generics,
|
||||||
|
@ -450,7 +450,7 @@ impl LoweringContext<'_> {
|
||||||
.collect();
|
.collect();
|
||||||
hir::ItemKind::Trait(
|
hir::ItemKind::Trait(
|
||||||
self.lower_is_auto(is_auto),
|
self.lower_is_auto(is_auto),
|
||||||
self.lower_unsafety(unsafety),
|
unsafety,
|
||||||
self.lower_generics(generics, ImplTraitContext::disallowed()),
|
self.lower_generics(generics, ImplTraitContext::disallowed()),
|
||||||
bounds,
|
bounds,
|
||||||
items,
|
items,
|
||||||
|
@ -1284,7 +1284,7 @@ impl LoweringContext<'_> {
|
||||||
|
|
||||||
fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
|
fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
|
||||||
hir::FnHeader {
|
hir::FnHeader {
|
||||||
unsafety: self.lower_unsafety(h.unsafety),
|
unsafety: h.unsafety,
|
||||||
asyncness: self.lower_asyncness(h.asyncness.node),
|
asyncness: self.lower_asyncness(h.asyncness.node),
|
||||||
constness: h.constness.node,
|
constness: h.constness.node,
|
||||||
abi: self.lower_abi(h.abi),
|
abi: self.lower_abi(h.abi),
|
||||||
|
@ -1311,13 +1311,6 @@ impl LoweringContext<'_> {
|
||||||
.emit();
|
.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 {
|
fn lower_asyncness(&mut self, a: IsAsync) -> hir::IsAsync {
|
||||||
match a {
|
match a {
|
||||||
IsAsync::Async { .. } => hir::IsAsync::Async,
|
IsAsync::Async { .. } => hir::IsAsync::Async,
|
||||||
|
|
|
@ -22,7 +22,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
||||||
use syntax::source_map::Spanned;
|
use syntax::source_map::Spanned;
|
||||||
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
||||||
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
|
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::attr::{InlineAttr, OptimizeAttr};
|
||||||
use syntax::symbol::{Symbol, kw};
|
use syntax::symbol::{Symbol, kw};
|
||||||
use syntax::tokenstream::TokenStream;
|
use syntax::tokenstream::TokenStream;
|
||||||
|
@ -2154,22 +2154,6 @@ pub enum IsAsync {
|
||||||
NotAsync,
|
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)]
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||||
pub enum Defaultness {
|
pub enum Defaultness {
|
||||||
Default { has_value: bool },
|
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)]
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
|
||||||
pub enum ImplPolarity {
|
pub enum ImplPolarity {
|
||||||
/// `impl Trait for Type`
|
/// `impl Trait for Type`
|
||||||
|
|
|
@ -1991,12 +1991,34 @@ pub enum IsAuto {
|
||||||
No,
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
|
||||||
|
RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub enum Unsafety {
|
pub enum Unsafety {
|
||||||
Unsafe,
|
Unsafe,
|
||||||
Normal,
|
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)]
|
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub enum IsAsync {
|
pub enum IsAsync {
|
||||||
Async {
|
Async {
|
||||||
|
@ -2041,18 +2063,6 @@ pub enum Defaultness {
|
||||||
Final,
|
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)]
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||||
pub enum ImplPolarity {
|
pub enum ImplPolarity {
|
||||||
/// `impl Trait for Type`
|
/// `impl Trait for Type`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue