Rename Unsafe to Safety
This commit is contained in:
parent
2d89cee625
commit
6b46a919e1
115 changed files with 460 additions and 494 deletions
|
@ -2105,7 +2105,7 @@ impl Ty {
|
|||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct BareFnTy {
|
||||
pub unsafety: Unsafe,
|
||||
pub safety: Safety,
|
||||
pub ext: Extern,
|
||||
pub generic_params: ThinVec<GenericParam>,
|
||||
pub decl: P<FnDecl>,
|
||||
|
@ -2484,11 +2484,15 @@ pub enum IsAuto {
|
|||
No,
|
||||
}
|
||||
|
||||
/// Safety of items.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)]
|
||||
#[derive(HashStable_Generic)]
|
||||
pub enum Unsafe {
|
||||
Yes(Span),
|
||||
No,
|
||||
pub enum Safety {
|
||||
/// `unsafe` an item is explicitly marked as `unsafe`.
|
||||
Unsafe(Span),
|
||||
/// Default means no value was provided, it will take a default value given the context in
|
||||
/// which is used.
|
||||
Default,
|
||||
}
|
||||
|
||||
/// Describes what kind of coroutine markers, if any, a function has.
|
||||
|
@ -2692,7 +2696,7 @@ pub struct ModSpans {
|
|||
pub struct ForeignMod {
|
||||
/// `unsafe` keyword accepted syntactically for macro DSLs, but not
|
||||
/// semantically by Rust.
|
||||
pub unsafety: Unsafe,
|
||||
pub safety: Safety,
|
||||
pub abi: Option<StrLit>,
|
||||
pub items: ThinVec<P<ForeignItem>>,
|
||||
}
|
||||
|
@ -3011,8 +3015,8 @@ impl Extern {
|
|||
/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
|
||||
#[derive(Clone, Copy, Encodable, Decodable, Debug)]
|
||||
pub struct FnHeader {
|
||||
/// The `unsafe` keyword, if any
|
||||
pub unsafety: Unsafe,
|
||||
/// Whether this is `unsafe`, or has a default safety
|
||||
pub safety: Safety,
|
||||
/// Whether this is `async`, `gen`, or nothing.
|
||||
pub coroutine_kind: Option<CoroutineKind>,
|
||||
/// The `const` keyword, if any
|
||||
|
@ -3024,8 +3028,8 @@ pub struct FnHeader {
|
|||
impl FnHeader {
|
||||
/// Does this function header have any qualifiers or is it empty?
|
||||
pub fn has_qualifiers(&self) -> bool {
|
||||
let Self { unsafety, coroutine_kind, constness, ext } = self;
|
||||
matches!(unsafety, Unsafe::Yes(_))
|
||||
let Self { safety, coroutine_kind, constness, ext } = self;
|
||||
matches!(safety, Safety::Unsafe(_))
|
||||
|| coroutine_kind.is_some()
|
||||
|| matches!(constness, Const::Yes(_))
|
||||
|| !matches!(ext, Extern::None)
|
||||
|
@ -3035,7 +3039,7 @@ impl FnHeader {
|
|||
impl Default for FnHeader {
|
||||
fn default() -> FnHeader {
|
||||
FnHeader {
|
||||
unsafety: Unsafe::No,
|
||||
safety: Safety::Default,
|
||||
coroutine_kind: None,
|
||||
constness: Const::No,
|
||||
ext: Extern::None,
|
||||
|
@ -3045,7 +3049,7 @@ impl Default for FnHeader {
|
|||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct Trait {
|
||||
pub unsafety: Unsafe,
|
||||
pub safety: Safety,
|
||||
pub is_auto: IsAuto,
|
||||
pub generics: Generics,
|
||||
pub bounds: GenericBounds,
|
||||
|
@ -3101,7 +3105,7 @@ pub struct TyAlias {
|
|||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct Impl {
|
||||
pub defaultness: Defaultness,
|
||||
pub unsafety: Unsafe,
|
||||
pub safety: Safety,
|
||||
pub generics: Generics,
|
||||
pub constness: Const,
|
||||
pub polarity: ImplPolarity,
|
||||
|
@ -3209,7 +3213,7 @@ pub enum ItemKind {
|
|||
/// E.g., `mod foo;` or `mod foo { .. }`.
|
||||
/// `unsafe` keyword on modules is accepted syntactically for macro DSLs, but not
|
||||
/// semantically by Rust.
|
||||
Mod(Unsafe, ModKind),
|
||||
Mod(Safety, ModKind),
|
||||
/// An external module (`extern`).
|
||||
///
|
||||
/// E.g., `extern {}` or `extern "C" {}`.
|
||||
|
|
|
@ -499,8 +499,8 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
|
|||
vis.visit_mt(mt);
|
||||
}
|
||||
TyKind::BareFn(bft) => {
|
||||
let BareFnTy { unsafety, ext: _, generic_params, decl, decl_span } = bft.deref_mut();
|
||||
visit_unsafety(unsafety, vis);
|
||||
let BareFnTy { safety, ext: _, generic_params, decl, decl_span } = bft.deref_mut();
|
||||
visit_safety(safety, vis);
|
||||
generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
|
||||
vis.visit_fn_decl(decl);
|
||||
vis.visit_span(decl_span);
|
||||
|
@ -543,8 +543,8 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
|
|||
}
|
||||
|
||||
fn noop_visit_foreign_mod<T: MutVisitor>(foreign_mod: &mut ForeignMod, vis: &mut T) {
|
||||
let ForeignMod { unsafety, abi: _, items } = foreign_mod;
|
||||
visit_unsafety(unsafety, vis);
|
||||
let ForeignMod { safety, abi: _, items } = foreign_mod;
|
||||
visit_safety(safety, vis);
|
||||
items.flat_map_in_place(|item| vis.flat_map_foreign_item(item));
|
||||
}
|
||||
|
||||
|
@ -859,10 +859,10 @@ fn visit_defaultness<T: MutVisitor>(defaultness: &mut Defaultness, vis: &mut T)
|
|||
}
|
||||
|
||||
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
|
||||
fn visit_unsafety<T: MutVisitor>(unsafety: &mut Unsafe, vis: &mut T) {
|
||||
match unsafety {
|
||||
Unsafe::Yes(span) => vis.visit_span(span),
|
||||
Unsafe::No => {}
|
||||
fn visit_safety<T: MutVisitor>(safety: &mut Safety, vis: &mut T) {
|
||||
match safety {
|
||||
Safety::Unsafe(span) => vis.visit_span(span),
|
||||
Safety::Default => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1092,8 +1092,8 @@ impl NoopVisitItemKind for ItemKind {
|
|||
vis.visit_generics(generics);
|
||||
visit_opt(body, |body| vis.visit_block(body));
|
||||
}
|
||||
ItemKind::Mod(unsafety, mod_kind) => {
|
||||
visit_unsafety(unsafety, vis);
|
||||
ItemKind::Mod(safety, mod_kind) => {
|
||||
visit_safety(safety, vis);
|
||||
match mod_kind {
|
||||
ModKind::Loaded(items, _inline, ModSpans { inner_span, inject_use_span }) => {
|
||||
vis.visit_span(inner_span);
|
||||
|
@ -1130,7 +1130,7 @@ impl NoopVisitItemKind for ItemKind {
|
|||
}
|
||||
ItemKind::Impl(box Impl {
|
||||
defaultness,
|
||||
unsafety,
|
||||
safety,
|
||||
generics,
|
||||
constness,
|
||||
polarity,
|
||||
|
@ -1139,7 +1139,7 @@ impl NoopVisitItemKind for ItemKind {
|
|||
items,
|
||||
}) => {
|
||||
visit_defaultness(defaultness, vis);
|
||||
visit_unsafety(unsafety, vis);
|
||||
visit_safety(safety, vis);
|
||||
vis.visit_generics(generics);
|
||||
visit_constness(constness, vis);
|
||||
visit_polarity(polarity, vis);
|
||||
|
@ -1147,8 +1147,8 @@ impl NoopVisitItemKind for ItemKind {
|
|||
vis.visit_ty(self_ty);
|
||||
items.flat_map_in_place(|item| vis.flat_map_impl_item(item));
|
||||
}
|
||||
ItemKind::Trait(box Trait { unsafety, is_auto: _, generics, bounds, items }) => {
|
||||
visit_unsafety(unsafety, vis);
|
||||
ItemKind::Trait(box Trait { safety, is_auto: _, generics, bounds, items }) => {
|
||||
visit_safety(safety, vis);
|
||||
vis.visit_generics(generics);
|
||||
visit_bounds(bounds, vis);
|
||||
items.flat_map_in_place(|item| vis.flat_map_trait_item(item));
|
||||
|
@ -1254,10 +1254,10 @@ fn visit_const_item<T: MutVisitor>(
|
|||
}
|
||||
|
||||
fn noop_visit_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) {
|
||||
let FnHeader { unsafety, coroutine_kind, constness, ext: _ } = header;
|
||||
let FnHeader { safety, coroutine_kind, constness, ext: _ } = header;
|
||||
visit_constness(constness, vis);
|
||||
coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind));
|
||||
visit_unsafety(unsafety, vis);
|
||||
visit_safety(safety, vis);
|
||||
}
|
||||
|
||||
pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
||||
|
|
|
@ -366,7 +366,7 @@ impl WalkItemKind for ItemKind {
|
|||
}
|
||||
ItemKind::Impl(box Impl {
|
||||
defaultness: _,
|
||||
unsafety: _,
|
||||
safety: _,
|
||||
generics,
|
||||
constness: _,
|
||||
polarity: _,
|
||||
|
@ -384,7 +384,7 @@ impl WalkItemKind for ItemKind {
|
|||
try_visit!(visitor.visit_generics(generics));
|
||||
try_visit!(visitor.visit_variant_data(struct_definition));
|
||||
}
|
||||
ItemKind::Trait(box Trait { unsafety: _, is_auto: _, generics, bounds, items }) => {
|
||||
ItemKind::Trait(box Trait { safety: _, is_auto: _, generics, bounds, items }) => {
|
||||
try_visit!(visitor.visit_generics(generics));
|
||||
walk_list!(visitor, visit_param_bound, bounds, BoundKind::SuperTraits);
|
||||
walk_list!(visitor, visit_assoc_item, items, AssocCtxt::Trait);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue