Skip to content

Commit 37dfd97

Browse files
committed
Auto merge of rust-lang#125077 - spastorino:add-new-fnsafety-enum2, r=jackh726
Rename Unsafe to Safety Alternative to rust-lang#124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks. This leaves us today with: ```rust enum ast::Safety { Unsafe(Span), Default, // Safe (going to be added for unsafe extern blocks) } enum hir::Safety { Unsafe, Safe, } ``` We would convert from `ast::Safety::Default` into the right Safety level according the context.
2 parents 4f589e3 + 0590d71 commit 37dfd97

17 files changed

+57
-62
lines changed

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_errors::Applicability;
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, Visitor};
77
use rustc_hir::{
8-
self as hir, BlockCheckMode, BodyId, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, UnsafeSource, Unsafety,
8+
self as hir, BlockCheckMode, BodyId, Expr, ExprKind, FnDecl, Safety, Impl, Item, ItemKind, UnsafeSource,
99
};
1010
use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::hir::nested_filter;
@@ -415,7 +415,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
415415
}
416416

417417
if let Some(header) = kind.header()
418-
&& header.unsafety == Unsafety::Unsafe
418+
&& header.safety == Safety::Unsafe
419419
{
420420
self.has_unsafe = true;
421421
}

clippy_lints/src/doc/missing_headers.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint, span_lint_and_note};
22
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
33
use clippy_utils::{is_doc_hidden, return_ty};
4-
use rustc_hir::{BodyId, FnSig, OwnerId, Unsafety};
4+
use rustc_hir::{BodyId, FnSig, OwnerId, Safety};
55
use rustc_lint::LateContext;
66
use rustc_middle::ty;
77
use rustc_span::{sym, Span};
@@ -33,14 +33,14 @@ pub fn check(
3333
}
3434

3535
let span = cx.tcx.def_span(owner_id);
36-
match (headers.safety, sig.header.unsafety) {
37-
(false, Unsafety::Unsafe) => span_lint(
36+
match (headers.safety, sig.header.safety) {
37+
(false, Safety::Unsafe) => span_lint(
3838
cx,
3939
MISSING_SAFETY_DOC,
4040
span,
4141
"unsafe function's docs miss `# Safety` section",
4242
),
43-
(true, Unsafety::Normal) => span_lint(
43+
(true, Safety::Safe) => span_lint(
4444
cx,
4545
UNNECESSARY_SAFETY_DOC,
4646
span,

clippy_lints/src/doc/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use pulldown_cmark::{BrokenLink, CodeBlockKind, CowStr, Options};
1212
use rustc_ast::ast::Attribute;
1313
use rustc_data_structures::fx::FxHashSet;
1414
use rustc_hir::intravisit::{self, Visitor};
15-
use rustc_hir::{AnonConst, Expr, ImplItemKind, ItemKind, Node, TraitItemKind, Unsafety};
15+
use rustc_hir::{AnonConst, Expr, ImplItemKind, ItemKind, Node, Safety, TraitItemKind};
1616
use rustc_lint::{LateContext, LateLintPass, LintContext};
1717
use rustc_middle::hir::nested_filter;
1818
use rustc_middle::lint::in_external_macro;
@@ -415,13 +415,13 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
415415
}
416416
},
417417
ItemKind::Trait(_, unsafety, ..) => match (headers.safety, unsafety) {
418-
(false, Unsafety::Unsafe) => span_lint(
418+
(false, Safety::Unsafe) => span_lint(
419419
cx,
420420
MISSING_SAFETY_DOC,
421421
cx.tcx.def_span(item.owner_id),
422422
"docs for unsafe trait missing `# Safety` section",
423423
),
424-
(true, Unsafety::Normal) => span_lint(
424+
(true, Safety::Safe) => span_lint(
425425
cx,
426426
UNNECESSARY_SAFETY_DOC,
427427
cx.tcx.def_span(item.owner_id),

clippy_lints/src/eta_reduction.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::ty::type_diagnostic_name;
55
use clippy_utils::usage::{local_used_after_expr, local_used_in};
66
use clippy_utils::{get_path_from_caller_to_method_type, is_adjusted, path_to_local, path_to_local_id};
77
use rustc_errors::Applicability;
8-
use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety};
8+
use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, Safety, TyKind};
99
use rustc_infer::infer::TyCtxtInferExt;
1010
use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::ty::{
@@ -146,15 +146,15 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
146146
ty::FnPtr(sig) => sig.skip_binder(),
147147
ty::Closure(_, subs) => cx
148148
.tcx
149-
.signature_unclosure(subs.as_closure().sig(), Unsafety::Normal)
149+
.signature_unclosure(subs.as_closure().sig(), Safety::Safe)
150150
.skip_binder(),
151151
_ => {
152152
if typeck.type_dependent_def_id(body.value.hir_id).is_some()
153153
&& let subs = typeck.node_args(body.value.hir_id)
154154
&& let output = typeck.expr_ty(body.value)
155155
&& let ty::Tuple(tys) = *subs.type_at(1).kind()
156156
{
157-
cx.tcx.mk_fn_sig(tys, output, false, Unsafety::Normal, Abi::Rust)
157+
cx.tcx.mk_fn_sig(tys, output, false, Safety::Safe, Abi::Rust)
158158
} else {
159159
return;
160160
}
@@ -241,11 +241,9 @@ fn check_inputs(
241241
}
242242

243243
fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure: ClosureArgs<'tcx>, call_sig: FnSig<'_>) -> bool {
244-
call_sig.unsafety == Unsafety::Normal
244+
call_sig.safety == Safety::Safe
245245
&& !has_late_bound_to_non_late_bound_regions(
246-
cx.tcx
247-
.signature_unclosure(closure.sig(), Unsafety::Normal)
248-
.skip_binder(),
246+
cx.tcx.signature_unclosure(closure.sig(), Safety::Safe).skip_binder(),
249247
call_sig,
250248
)
251249
}

clippy_lints/src/functions/misnamed_getters.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::source::snippet;
33
use rustc_errors::Applicability;
44
use rustc_hir::intravisit::FnKind;
5-
use rustc_hir::{Body, ExprKind, FnDecl, ImplicitSelfKind, Unsafety};
5+
use rustc_hir::{Body, ExprKind, FnDecl, Safety, ImplicitSelfKind};
66
use rustc_lint::LateContext;
77
use rustc_middle::ty;
88
use rustc_span::Span;
@@ -34,7 +34,7 @@ pub fn check_fn(cx: &LateContext<'_>, kind: FnKind<'_>, decl: &FnDecl<'_>, body:
3434
ImplicitSelfKind::None => return,
3535
};
3636

37-
let name = if sig.header.unsafety == Unsafety::Unsafe {
37+
let name = if sig.header.safety == Safety::Unsafe {
3838
name.strip_suffix("_unchecked").unwrap_or(name)
3939
} else {
4040
name

clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,30 @@ pub(super) fn check_fn<'tcx>(
1919
body: &'tcx hir::Body<'tcx>,
2020
def_id: LocalDefId,
2121
) {
22-
let unsafety = match kind {
23-
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }) => unsafety,
24-
intravisit::FnKind::Method(_, sig) => sig.header.unsafety,
22+
let safety = match kind {
23+
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { safety, .. }) => safety,
24+
intravisit::FnKind::Method(_, sig) => sig.header.safety,
2525
intravisit::FnKind::Closure => return,
2626
};
2727

28-
check_raw_ptr(cx, unsafety, decl, body, def_id);
28+
check_raw_ptr(cx, safety, decl, body, def_id);
2929
}
3030

3131
pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
3232
if let hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(eid)) = item.kind {
3333
let body = cx.tcx.hir().body(eid);
34-
check_raw_ptr(cx, sig.header.unsafety, sig.decl, body, item.owner_id.def_id);
34+
check_raw_ptr(cx, sig.header.safety, sig.decl, body, item.owner_id.def_id);
3535
}
3636
}
3737

3838
fn check_raw_ptr<'tcx>(
3939
cx: &LateContext<'tcx>,
40-
unsafety: hir::Unsafety,
40+
safety: hir::Safety,
4141
decl: &'tcx hir::FnDecl<'tcx>,
4242
body: &'tcx hir::Body<'tcx>,
4343
def_id: LocalDefId,
4444
) {
45-
if unsafety == hir::Unsafety::Normal && cx.effective_visibilities.is_exported(def_id) {
45+
if safety == hir::Safety::Safe && cx.effective_visibilities.is_exported(def_id) {
4646
let raw_ptrs = iter_input_pats(decl, body)
4747
.filter_map(|arg| raw_ptr_arg(cx, arg))
4848
.collect::<HirIdSet>();
@@ -58,7 +58,7 @@ fn check_raw_ptr<'tcx>(
5858
},
5959
hir::ExprKind::MethodCall(_, recv, args, _) => {
6060
let def_id = typeck.type_dependent_def_id(e.hir_id).unwrap();
61-
if cx.tcx.fn_sig(def_id).skip_binder().skip_binder().unsafety == hir::Unsafety::Unsafe {
61+
if cx.tcx.fn_sig(def_id).skip_binder().skip_binder().safety == hir::Safety::Unsafe {
6262
check_arg(cx, &raw_ptrs, recv);
6363
for arg in args {
6464
check_arg(cx, &raw_ptrs, arg);

clippy_lints/src/inherent_to_string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::ty::{implements_trait, is_type_lang_item};
33
use clippy_utils::{return_ty, trait_ref_of_method};
4-
use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind, LangItem, Unsafety};
4+
use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind, LangItem, Safety};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::declare_lint_pass;
77
use rustc_span::sym;
@@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
9999
if let ImplItemKind::Fn(ref signature, _) = impl_item.kind
100100
// #11201
101101
&& let header = signature.header
102-
&& header.unsafety == Unsafety::Normal
102+
&& header.safety == Safety::Safe
103103
&& header.abi == Abi::Rust
104104
&& impl_item.ident.name == sym::to_string
105105
&& let decl = signature.decl

clippy_lints/src/methods/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -5038,7 +5038,7 @@ fn lint_binary_expr_with_method_call(cx: &LateContext<'_>, info: &mut BinaryExpr
50385038
}
50395039

50405040
const FN_HEADER: hir::FnHeader = hir::FnHeader {
5041-
unsafety: hir::Unsafety::Normal,
5041+
safety: hir::Safety::Safe,
50425042
constness: hir::Constness::NotConst,
50435043
asyncness: hir::IsAsync::NotAsync,
50445044
abi: rustc_target::spec::abi::Abi::Rust,
@@ -5214,7 +5214,5 @@ impl OutType {
52145214
}
52155215

52165216
fn fn_header_equals(expected: hir::FnHeader, actual: hir::FnHeader) -> bool {
5217-
expected.constness == actual.constness
5218-
&& expected.unsafety == actual.unsafety
5219-
&& expected.asyncness == actual.asyncness
5217+
expected.constness == actual.constness && expected.safety == actual.safety && expected.asyncness == actual.asyncness
52205218
}

clippy_lints/src/multiple_unsafe_ops_per_block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::visitors::{for_each_expr_with_closures, Descend, Visitable};
33
use core::ops::ControlFlow::Continue;
44
use hir::def::{DefKind, Res};
5-
use hir::{BlockCheckMode, ExprKind, QPath, UnOp, Unsafety};
5+
use hir::{BlockCheckMode, ExprKind, Safety, QPath, UnOp};
66
use rustc_ast::Mutability;
77
use rustc_hir as hir;
88
use rustc_lint::{LateContext, LateLintPass};
@@ -133,7 +133,7 @@ fn collect_unsafe_exprs<'tcx>(
133133
ty::FnPtr(sig) => sig,
134134
_ => return Continue(Descend::Yes),
135135
};
136-
if sig.unsafety() == Unsafety::Unsafe {
136+
if sig.safety() == Safety::Unsafe {
137137
unsafe_ops.push(("unsafe function call occurs here", expr.span));
138138
}
139139
},
@@ -144,7 +144,7 @@ fn collect_unsafe_exprs<'tcx>(
144144
.type_dependent_def_id(expr.hir_id)
145145
.map(|def_id| cx.tcx.fn_sig(def_id))
146146
{
147-
if sig.skip_binder().unsafety() == Unsafety::Unsafe {
147+
if sig.skip_binder().safety() == Safety::Unsafe {
148148
unsafe_ops.push(("unsafe method call occurs here", expr.span));
149149
}
150150
}

clippy_lints/src/new_without_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
7575
if let hir::ImplItemKind::Fn(ref sig, _) = impl_item.kind {
7676
let name = impl_item.ident.name;
7777
let id = impl_item.owner_id;
78-
if sig.header.unsafety == hir::Unsafety::Unsafe {
78+
if sig.header.safety == hir::Safety::Unsafe {
7979
// can't be implemented for unsafe new
8080
return;
8181
}

clippy_lints/src/ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir::hir_id::{HirId, HirIdMap};
1212
use rustc_hir::intravisit::{walk_expr, Visitor};
1313
use rustc_hir::{
1414
self as hir, AnonConst, BinOpKind, BindingMode, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg, ImplItemKind,
15-
ItemKind, Lifetime, Mutability, Node, Param, PatKind, QPath, TraitFn, TraitItem, TraitItemKind, TyKind, Unsafety,
15+
ItemKind, Lifetime, Mutability, Node, Param, PatKind, QPath, Safety, TraitFn, TraitItem, TraitItemKind, TyKind,
1616
};
1717
use rustc_infer::infer::TyCtxtInferExt;
1818
use rustc_infer::traits::{Obligation, ObligationCause};
@@ -542,7 +542,7 @@ fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Optio
542542
if let Some(args) = args
543543
&& !args.is_empty()
544544
&& body.map_or(true, |body| {
545-
sig.header.unsafety == Unsafety::Unsafe || contains_unsafe_block(cx, body.value)
545+
sig.header.safety == Safety::Unsafe || contains_unsafe_block(cx, body.value)
546546
})
547547
{
548548
span_lint_and_then(

clippy_lints/src/undocumented_unsafe_blocks.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'tcx> LateLintPass<'tcx> for UndocumentedUnsafeBlocks {
200200
let item_has_safety_comment = item_has_safety_comment(cx, item);
201201
match (&item.kind, item_has_safety_comment) {
202202
// lint unsafe impl without safety comment
203-
(ItemKind::Impl(impl_), HasSafetyComment::No) if impl_.unsafety == hir::Unsafety::Unsafe => {
203+
(ItemKind::Impl(impl_), HasSafetyComment::No) if impl_.safety == hir::Safety::Unsafe => {
204204
if !is_lint_allowed(cx, UNDOCUMENTED_UNSAFE_BLOCKS, item.hir_id())
205205
&& !is_unsafe_from_proc_macro(cx, item.span)
206206
{
@@ -222,7 +222,7 @@ impl<'tcx> LateLintPass<'tcx> for UndocumentedUnsafeBlocks {
222222
}
223223
},
224224
// lint safe impl with unnecessary safety comment
225-
(ItemKind::Impl(impl_), HasSafetyComment::Yes(pos)) if impl_.unsafety == hir::Unsafety::Normal => {
225+
(ItemKind::Impl(impl_), HasSafetyComment::Yes(pos)) if impl_.safety == hir::Safety::Safe => {
226226
if !is_lint_allowed(cx, UNNECESSARY_SAFETY_COMMENT, item.hir_id()) {
227227
let (span, help_span) = mk_spans(pos);
228228

clippy_utils/src/ast_utils.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -386,29 +386,29 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
386386
(
387387
Trait(box ast::Trait {
388388
is_auto: la,
389-
unsafety: lu,
389+
safety: lu,
390390
generics: lg,
391391
bounds: lb,
392392
items: li,
393393
}),
394394
Trait(box ast::Trait {
395395
is_auto: ra,
396-
unsafety: ru,
396+
safety: ru,
397397
generics: rg,
398398
bounds: rb,
399399
items: ri,
400400
}),
401401
) => {
402402
la == ra
403-
&& matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No)
403+
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
404404
&& eq_generics(lg, rg)
405405
&& over(lb, rb, eq_generic_bound)
406406
&& over(li, ri, |l, r| eq_item(l, r, eq_assoc_item_kind))
407407
},
408408
(TraitAlias(lg, lb), TraitAlias(rg, rb)) => eq_generics(lg, rg) && over(lb, rb, eq_generic_bound),
409409
(
410410
Impl(box ast::Impl {
411-
unsafety: lu,
411+
safety: lu,
412412
polarity: lp,
413413
defaultness: ld,
414414
constness: lc,
@@ -418,7 +418,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
418418
items: li,
419419
}),
420420
Impl(box ast::Impl {
421-
unsafety: ru,
421+
safety: ru,
422422
polarity: rp,
423423
defaultness: rd,
424424
constness: rc,
@@ -428,7 +428,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
428428
items: ri,
429429
}),
430430
) => {
431-
matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No)
431+
matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
432432
&& matches!(lp, ImplPolarity::Positive) == matches!(rp, ImplPolarity::Positive)
433433
&& eq_defaultness(*ld, *rd)
434434
&& matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
@@ -605,7 +605,7 @@ fn eq_opt_coroutine_kind(l: Option<CoroutineKind>, r: Option<CoroutineKind>) ->
605605
}
606606

607607
pub fn eq_fn_header(l: &FnHeader, r: &FnHeader) -> bool {
608-
matches!(l.unsafety, Unsafe::No) == matches!(r.unsafety, Unsafe::No)
608+
matches!(l.safety, Safety::Default) == matches!(r.safety, Safety::Default)
609609
&& eq_opt_coroutine_kind(l.coroutine_kind, r.coroutine_kind)
610610
&& matches!(l.constness, Const::No) == matches!(r.constness, Const::No)
611611
&& eq_ext(&l.ext, &r.ext)
@@ -712,7 +712,7 @@ pub fn eq_ty(l: &Ty, r: &Ty) -> bool {
712712
both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty)
713713
},
714714
(BareFn(l), BareFn(r)) => {
715-
l.unsafety == r.unsafety
715+
l.safety == r.safety
716716
&& eq_ext(&l.ext, &r.ext)
717717
&& over(&l.generic_params, &r.generic_params, eq_generic_param)
718718
&& eq_fn_decl(&l.decl, &r.decl)

clippy_utils/src/check_proc_macro.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use rustc_ast::AttrStyle;
1818
use rustc_hir::intravisit::FnKind;
1919
use rustc_hir::{
2020
Block, BlockCheckMode, Body, Closure, Destination, Expr, ExprKind, FieldDef, FnHeader, FnRetTy, HirId, Impl,
21-
ImplItem, ImplItemKind, IsAuto, Item, ItemKind, LoopSource, MatchSource, MutTy, Node, QPath, TraitItem,
22-
TraitItemKind, Ty, TyKind, UnOp, UnsafeSource, Unsafety, Variant, VariantData, YieldSource,
21+
ImplItem, ImplItemKind, IsAuto, Item, ItemKind, LoopSource, MatchSource, MutTy, Node, QPath, Safety, TraitItem,
22+
TraitItemKind, Ty, TyKind, UnOp, UnsafeSource, Variant, VariantData, YieldSource,
2323
};
2424
use rustc_lint::{LateContext, LintContext};
2525
use rustc_middle::ty::TyCtxt;
@@ -207,10 +207,9 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
207207
ItemKind::Struct(VariantData::Struct { .. }, _) => (Pat::Str("struct"), Pat::Str("}")),
208208
ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")),
209209
ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")),
210-
ItemKind::Trait(_, Unsafety::Unsafe, ..)
210+
ItemKind::Trait(_, Safety::Unsafe, ..)
211211
| ItemKind::Impl(Impl {
212-
unsafety: Unsafety::Unsafe,
213-
..
212+
safety: Safety::Unsafe, ..
214213
}) => (Pat::Str("unsafe"), Pat::Str("}")),
215214
ItemKind::Trait(IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
216215
ItemKind::Trait(..) => (Pat::Str("trait"), Pat::Str("}")),
@@ -323,7 +322,7 @@ fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) {
323322
TyKind::Ptr(MutTy { ty, .. }) => (Pat::Str("*"), ty_search_pat(ty).1),
324323
TyKind::Ref(_, MutTy { ty, .. }) => (Pat::Str("&"), ty_search_pat(ty).1),
325324
TyKind::BareFn(bare_fn) => (
326-
if bare_fn.unsafety == Unsafety::Unsafe {
325+
if bare_fn.safety == Safety::Unsafe {
327326
Pat::Str("unsafe")
328327
} else if bare_fn.abi != Abi::Rust {
329328
Pat::Str("extern")

clippy_utils/src/hir_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
10821082
mut_ty.mutbl.hash(&mut self.s);
10831083
},
10841084
TyKind::BareFn(bfn) => {
1085-
bfn.unsafety.hash(&mut self.s);
1085+
bfn.safety.hash(&mut self.s);
10861086
bfn.abi.hash(&mut self.s);
10871087
for arg in bfn.decl.inputs {
10881088
self.hash_ty(arg);

0 commit comments

Comments
 (0)