Skip to content

Commit f03cbc3

Browse files
committed
Merge hir::Unsafety into ast::Unsafety.
1 parent 1f21c08 commit f03cbc3

File tree

4 files changed

+28
-50
lines changed

4 files changed

+28
-50
lines changed

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ impl<'a> LoweringContext<'a> {
12131213
&NodeMap::default(),
12141214
ImplTraitContext::disallowed(),
12151215
),
1216-
unsafety: this.lower_unsafety(f.unsafety),
1216+
unsafety: f.unsafety,
12171217
abi: this.lower_abi(f.abi),
12181218
decl: this.lower_fn_decl(&f.decl, None, false, None),
12191219
param_names: this.lower_fn_params_to_names(&f.decl),

src/librustc/hir/lowering/item.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl LoweringContext<'_> {
433433
);
434434

435435
hir::ItemKind::Impl(
436-
self.lower_unsafety(unsafety),
436+
unsafety,
437437
self.lower_impl_polarity(polarity),
438438
self.lower_defaultness(defaultness, true /* [1] */),
439439
generics,
@@ -450,7 +450,7 @@ impl LoweringContext<'_> {
450450
.collect();
451451
hir::ItemKind::Trait(
452452
self.lower_is_auto(is_auto),
453-
self.lower_unsafety(unsafety),
453+
unsafety,
454454
self.lower_generics(generics, ImplTraitContext::disallowed()),
455455
bounds,
456456
items,
@@ -1284,7 +1284,7 @@ impl LoweringContext<'_> {
12841284

12851285
fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
12861286
hir::FnHeader {
1287-
unsafety: self.lower_unsafety(h.unsafety),
1287+
unsafety: h.unsafety,
12881288
asyncness: self.lower_asyncness(h.asyncness.node),
12891289
constness: h.constness.node,
12901290
abi: self.lower_abi(h.abi),
@@ -1311,13 +1311,6 @@ impl LoweringContext<'_> {
13111311
.emit();
13121312
}
13131313

1314-
pub(super) fn lower_unsafety(&mut self, u: Unsafety) -> hir::Unsafety {
1315-
match u {
1316-
Unsafety::Unsafe => hir::Unsafety::Unsafe,
1317-
Unsafety::Normal => hir::Unsafety::Normal,
1318-
}
1319-
}
1320-
13211314
fn lower_asyncness(&mut self, a: IsAsync) -> hir::IsAsync {
13221315
match a {
13231316
IsAsync::Async { .. } => hir::IsAsync::Async,

src/librustc/hir/mod.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan};
2222
use syntax::source_map::Spanned;
2323
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
2424
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
25-
pub use syntax::ast::{Mutability, Constness};
25+
pub use syntax::ast::{Mutability, Constness, Unsafety};
2626
use syntax::attr::{InlineAttr, OptimizeAttr};
2727
use syntax::symbol::{Symbol, kw};
2828
use syntax::tokenstream::TokenStream;
@@ -2154,22 +2154,6 @@ pub enum IsAsync {
21542154
NotAsync,
21552155
}
21562156

2157-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
2158-
RustcEncodable, RustcDecodable, Hash, Debug)]
2159-
pub enum Unsafety {
2160-
Unsafe,
2161-
Normal,
2162-
}
2163-
2164-
impl Unsafety {
2165-
pub fn prefix_str(&self) -> &'static str {
2166-
match self {
2167-
Unsafety::Unsafe => "unsafe ",
2168-
Unsafety::Normal => "",
2169-
}
2170-
}
2171-
}
2172-
21732157
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
21742158
pub enum Defaultness {
21752159
Default { has_value: bool },
@@ -2196,15 +2180,6 @@ impl Defaultness {
21962180
}
21972181
}
21982182

2199-
impl fmt::Display for Unsafety {
2200-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2201-
f.write_str(match self {
2202-
Unsafety::Normal => "normal",
2203-
Unsafety::Unsafe => "unsafe",
2204-
})
2205-
}
2206-
}
2207-
22082183
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
22092184
pub enum ImplPolarity {
22102185
/// `impl Trait for Type`

src/libsyntax/ast.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,12 +1991,34 @@ pub enum IsAuto {
19911991
No,
19921992
}
19931993

1994-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
1994+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
1995+
RustcEncodable, RustcDecodable, Debug)]
19951996
pub enum Unsafety {
19961997
Unsafe,
19971998
Normal,
19981999
}
19992000

2001+
impl Unsafety {
2002+
pub fn prefix_str(&self) -> &'static str {
2003+
match self {
2004+
Unsafety::Unsafe => "unsafe ",
2005+
Unsafety::Normal => "",
2006+
}
2007+
}
2008+
}
2009+
2010+
impl fmt::Display for Unsafety {
2011+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2012+
fmt::Display::fmt(
2013+
match *self {
2014+
Unsafety::Normal => "normal",
2015+
Unsafety::Unsafe => "unsafe",
2016+
},
2017+
f,
2018+
)
2019+
}
2020+
}
2021+
20002022
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
20012023
pub enum IsAsync {
20022024
Async {
@@ -2041,18 +2063,6 @@ pub enum Defaultness {
20412063
Final,
20422064
}
20432065

2044-
impl fmt::Display for Unsafety {
2045-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2046-
fmt::Display::fmt(
2047-
match *self {
2048-
Unsafety::Normal => "normal",
2049-
Unsafety::Unsafe => "unsafe",
2050-
},
2051-
f,
2052-
)
2053-
}
2054-
}
2055-
20562066
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
20572067
pub enum ImplPolarity {
20582068
/// `impl Trait for Type`

0 commit comments

Comments
 (0)