Rename Unsafe to Safety
This commit is contained in:
parent
05a2db7624
commit
97bdbd96f1
22
src/items.rs
22
src/items.rs
@ -247,7 +247,7 @@ fn allow_single_line_let_else_block(result: &str, block: &ast::Block) -> bool {
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
struct Item<'a> {
|
||||
unsafety: ast::Unsafe,
|
||||
safety: ast::Safety,
|
||||
abi: Cow<'static, str>,
|
||||
vis: Option<&'a ast::Visibility>,
|
||||
body: Vec<BodyElement<'a>>,
|
||||
@ -257,7 +257,7 @@ struct Item<'a> {
|
||||
impl<'a> Item<'a> {
|
||||
fn from_foreign_mod(fm: &'a ast::ForeignMod, span: Span, config: &Config) -> Item<'a> {
|
||||
Item {
|
||||
unsafety: fm.unsafety,
|
||||
safety: fm.safety,
|
||||
abi: format_extern(
|
||||
ast::Extern::from_abi(fm.abi, DUMMY_SP),
|
||||
config.force_explicit_abi(),
|
||||
@ -290,7 +290,7 @@ pub(crate) struct FnSig<'a> {
|
||||
coroutine_kind: Cow<'a, Option<ast::CoroutineKind>>,
|
||||
constness: ast::Const,
|
||||
defaultness: ast::Defaultness,
|
||||
unsafety: ast::Unsafe,
|
||||
safety: ast::Safety,
|
||||
visibility: &'a ast::Visibility,
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ impl<'a> FnSig<'a> {
|
||||
visibility: &'a ast::Visibility,
|
||||
) -> FnSig<'a> {
|
||||
FnSig {
|
||||
unsafety: method_sig.header.unsafety,
|
||||
safety: method_sig.header.safety,
|
||||
coroutine_kind: Cow::Borrowed(&method_sig.header.coroutine_kind),
|
||||
constness: method_sig.header.constness,
|
||||
defaultness: ast::Defaultness::Final,
|
||||
@ -330,7 +330,7 @@ impl<'a> FnSig<'a> {
|
||||
constness: fn_sig.header.constness,
|
||||
coroutine_kind: Cow::Borrowed(&fn_sig.header.coroutine_kind),
|
||||
defaultness,
|
||||
unsafety: fn_sig.header.unsafety,
|
||||
safety: fn_sig.header.safety,
|
||||
visibility: vis,
|
||||
},
|
||||
_ => unreachable!(),
|
||||
@ -345,7 +345,7 @@ impl<'a> FnSig<'a> {
|
||||
result.push_str(format_constness(self.constness));
|
||||
self.coroutine_kind
|
||||
.map(|coroutine_kind| result.push_str(format_coro(&coroutine_kind)));
|
||||
result.push_str(format_unsafety(self.unsafety));
|
||||
result.push_str(format_safety(self.safety));
|
||||
result.push_str(&format_extern(
|
||||
self.ext,
|
||||
context.config.force_explicit_abi(),
|
||||
@ -356,7 +356,7 @@ impl<'a> FnSig<'a> {
|
||||
|
||||
impl<'a> FmtVisitor<'a> {
|
||||
fn format_item(&mut self, item: &Item<'_>) {
|
||||
self.buffer.push_str(format_unsafety(item.unsafety));
|
||||
self.buffer.push_str(format_safety(item.safety));
|
||||
self.buffer.push_str(&item.abi);
|
||||
|
||||
let snippet = self.snippet(item.span);
|
||||
@ -924,7 +924,7 @@ fn format_impl_ref_and_type(
|
||||
offset: Indent,
|
||||
) -> Option<String> {
|
||||
let ast::Impl {
|
||||
unsafety,
|
||||
safety,
|
||||
polarity,
|
||||
defaultness,
|
||||
constness,
|
||||
@ -937,7 +937,7 @@ fn format_impl_ref_and_type(
|
||||
|
||||
result.push_str(&format_visibility(context, &item.vis));
|
||||
result.push_str(format_defaultness(defaultness));
|
||||
result.push_str(format_unsafety(unsafety));
|
||||
result.push_str(format_safety(safety));
|
||||
|
||||
let shape = if context.config.version() == Version::Two {
|
||||
Shape::indented(offset + last_line_width(&result), context.config)
|
||||
@ -1137,7 +1137,7 @@ pub(crate) fn format_trait(
|
||||
};
|
||||
let ast::Trait {
|
||||
is_auto,
|
||||
unsafety,
|
||||
safety,
|
||||
ref generics,
|
||||
ref bounds,
|
||||
ref items,
|
||||
@ -1147,7 +1147,7 @@ pub(crate) fn format_trait(
|
||||
let header = format!(
|
||||
"{}{}{}trait ",
|
||||
format_visibility(context, &item.vis),
|
||||
format_unsafety(unsafety),
|
||||
format_safety(safety),
|
||||
format_auto(is_auto),
|
||||
);
|
||||
result.push_str(&header);
|
||||
|
@ -899,7 +899,7 @@ fn rewrite_bare_fn(
|
||||
result.push_str("> ");
|
||||
}
|
||||
|
||||
result.push_str(crate::utils::format_unsafety(bare_fn.unsafety));
|
||||
result.push_str(crate::utils::format_safety(bare_fn.safety));
|
||||
|
||||
result.push_str(&format_extern(
|
||||
bare_fn.ext,
|
||||
|
@ -108,10 +108,10 @@ pub(crate) fn format_defaultness(defaultness: ast::Defaultness) -> &'static str
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn format_unsafety(unsafety: ast::Unsafe) -> &'static str {
|
||||
pub(crate) fn format_safety(unsafety: ast::Safety) -> &'static str {
|
||||
match unsafety {
|
||||
ast::Unsafe::Yes(..) => "unsafe ",
|
||||
ast::Unsafe::No => "",
|
||||
ast::Safety::Unsafe(..) => "unsafe ",
|
||||
ast::Safety::Default => "",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ use crate::source_map::{LineRangeUtils, SpanUtils};
|
||||
use crate::spanned::Spanned;
|
||||
use crate::stmt::Stmt;
|
||||
use crate::utils::{
|
||||
self, contains_skip, count_newlines, depr_skip_annotation, format_unsafety, inner_attributes,
|
||||
self, contains_skip, count_newlines, depr_skip_annotation, format_safety, inner_attributes,
|
||||
last_line_width, mk_sp, ptr_vec_to_ref_vec, rewrite_ident, starts_with_newline, stmt_expr,
|
||||
};
|
||||
use crate::{ErrorKind, FormatReport, FormattingError};
|
||||
@ -517,9 +517,9 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
self.visit_enum(item.ident, &item.vis, def, generics, item.span);
|
||||
self.last_pos = source!(self, item.span).hi();
|
||||
}
|
||||
ast::ItemKind::Mod(unsafety, ref mod_kind) => {
|
||||
ast::ItemKind::Mod(safety, ref mod_kind) => {
|
||||
self.format_missing_with_indent(source!(self, item.span).lo());
|
||||
self.format_mod(mod_kind, unsafety, &item.vis, item.span, item.ident, attrs);
|
||||
self.format_mod(mod_kind, safety, &item.vis, item.span, item.ident, attrs);
|
||||
}
|
||||
ast::ItemKind::MacCall(ref mac) => {
|
||||
self.visit_mac(mac, Some(item.ident), MacroPosition::Item);
|
||||
@ -913,7 +913,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
fn format_mod(
|
||||
&mut self,
|
||||
mod_kind: &ast::ModKind,
|
||||
unsafety: ast::Unsafe,
|
||||
safety: ast::Safety,
|
||||
vis: &ast::Visibility,
|
||||
s: Span,
|
||||
ident: symbol::Ident,
|
||||
@ -921,7 +921,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
) {
|
||||
let vis_str = utils::format_visibility(&self.get_context(), vis);
|
||||
self.push_str(&*vis_str);
|
||||
self.push_str(format_unsafety(unsafety));
|
||||
self.push_str(format_safety(safety));
|
||||
self.push_str("mod ");
|
||||
// Calling `to_owned()` to work around borrow checker.
|
||||
let ident_str = rewrite_ident(&self.get_context(), ident).to_owned();
|
||||
|
Loading…
x
Reference in New Issue
Block a user