Skip to content

Commit 7ac65c1

Browse files
Appease rustdoc and clippy
1 parent eb9e79c commit 7ac65c1

39 files changed

+124
-114
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,12 +2062,19 @@ pub(crate) fn clean_middle_ty<'tcx>(
20622062
let n = print_const(cx, n);
20632063
Array(Box::new(clean_middle_ty(bound_ty.rebind(ty), cx, None, None)), n.into())
20642064
}
2065-
ty::RawPtr(mt) => {
2066-
RawPointer(mt.mutbl, Box::new(clean_middle_ty(bound_ty.rebind(mt.ty), cx, None, None)))
2067-
}
2065+
ty::RawPtr(mt) => RawPointer(
2066+
match mt.mutbl {
2067+
ty::Mutability::Mut => hir::Mutability::Mut,
2068+
ty::Mutability::Not => hir::Mutability::Not,
2069+
},
2070+
Box::new(clean_middle_ty(bound_ty.rebind(mt.ty), cx, None, None)),
2071+
),
20682072
ty::Ref(r, ty, mutbl) => BorrowedRef {
20692073
lifetime: clean_middle_region(r),
2070-
mutability: mutbl,
2074+
mutability: match mutbl {
2075+
ty::Mutability::Mut => hir::Mutability::Mut,
2076+
ty::Mutability::Not => hir::Mutability::Not,
2077+
},
20712078
type_: Box::new(clean_middle_ty(
20722079
bound_ty.rebind(ty),
20732080
cx,

src/librustdoc/clean/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,8 +1836,8 @@ impl PrimitiveType {
18361836
// or start with a more complex refactoring.
18371837
Tuple => [SimplifiedType::Tuple(1), SimplifiedType::Tuple(2), SimplifiedType::Tuple(3)].into(),
18381838
Unit => single(SimplifiedType::Tuple(0)),
1839-
RawPointer => [SimplifiedType::Ptr(Mutability::Not), SimplifiedType::Ptr(Mutability::Mut)].into_iter().collect(),
1840-
Reference => [SimplifiedType::Ref(Mutability::Not), SimplifiedType::Ref(Mutability::Mut)].into_iter().collect(),
1839+
RawPointer => [SimplifiedType::Ptr(ty::Mutability::Not), SimplifiedType::Ptr(ty::Mutability::Mut)].into_iter().collect(),
1840+
Reference => [SimplifiedType::Ref(ty::Mutability::Not), SimplifiedType::Ref(ty::Mutability::Mut)].into_iter().collect(),
18411841
// FIXME: This will be wrong if we ever add inherent impls
18421842
// for function pointers.
18431843
Fn => single(SimplifiedType::Function(1)),

src/tools/clippy/clippy_lints/src/borrow_deref_ref.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use clippy_utils::source::snippet_opt;
44
use clippy_utils::ty::implements_trait;
55
use clippy_utils::{get_parent_expr, is_from_proc_macro, is_lint_allowed};
66
use rustc_errors::Applicability;
7-
use rustc_hir::{ExprKind, UnOp};
7+
use rustc_hir::{ExprKind, UnOp, Mutability};
88
use rustc_lint::{LateContext, LateLintPass};
9-
use rustc_middle::mir::Mutability;
109
use rustc_middle::ty;
1110
use rustc_session::{declare_lint_pass, declare_tool_lint};
1211

@@ -57,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for BorrowDerefRef {
5756
if !deref_target.span.from_expansion();
5857
if !matches!(deref_target.kind, ExprKind::Unary(UnOp::Deref, ..) );
5958
let ref_ty = cx.typeck_results().expr_ty(deref_target);
60-
if let ty::Ref(_, inner_ty, Mutability::Not) = ref_ty.kind();
59+
if let ty::Ref(_, inner_ty, ty::Mutability::Not) = ref_ty.kind();
6160
if !is_from_proc_macro(cx, e);
6261
then{
6362

src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::msrvs::{self, Msrv};
33
use clippy_utils::source;
44
use if_chain::if_chain;
5-
use rustc_ast::Mutability;
65
use rustc_hir::{Expr, ExprKind, Node};
76
use rustc_lint::LateContext;
87
use rustc_middle::ty::layout::LayoutOf;
9-
use rustc_middle::ty::{self, Ty, TypeAndMut};
8+
use rustc_middle::ty::{self, Ty, TypeAndMut, Mutability};
109

1110
use super::CAST_SLICE_DIFFERENT_SIZES;
1211

src/tools/clippy/clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use clippy_utils::msrvs::{self, Msrv};
33
use clippy_utils::source::snippet_with_applicability;
44
use clippy_utils::sugg::Sugg;
55
use rustc_errors::Applicability;
6-
use rustc_hir::{Expr, ExprKind, Mutability, TyKind};
6+
use rustc_hir::{Expr, ExprKind, TyKind};
77
use rustc_lint::LateContext;
8-
use rustc_middle::ty::{self, TypeAndMut};
8+
use rustc_middle::ty::{self, TypeAndMut, Mutability};
99

1010
use super::PTR_AS_PTR;
1111

src/tools/clippy/clippy_lints/src/casts/ptr_cast_constness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use clippy_utils::msrvs::{Msrv, POINTER_CAST_CONSTNESS};
33
use clippy_utils::sugg::Sugg;
44
use if_chain::if_chain;
55
use rustc_errors::Applicability;
6-
use rustc_hir::{Expr, Mutability};
6+
use rustc_hir::{Expr};
77
use rustc_lint::LateContext;
8-
use rustc_middle::ty::{self, Ty, TypeAndMut};
8+
use rustc_middle::ty::{self, Ty, TypeAndMut, Mutability};
99

1010
use super::PTR_CAST_CONSTNESS;
1111

src/tools/clippy/clippy_lints/src/dereference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
598598
if !pat.span.from_expansion();
599599
if let ty::Ref(_, tam, _) = *cx.typeck_results().pat_ty(pat).kind();
600600
// only lint immutable refs, because borrowed `&mut T` cannot be moved out
601-
if let ty::Ref(_, _, Mutability::Not) = *tam.kind();
601+
if let ty::Ref(_, _, ty::Mutability::Not) = *tam.kind();
602602
then {
603603
let mut app = Applicability::MachineApplicable;
604604
let snip = snippet_with_context(cx, name.span, pat.span.ctxt(), "..", &mut app).0;
@@ -913,7 +913,7 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data
913913
};
914914
let addr_of_str = if ty_changed_count < ref_count {
915915
// Check if a reborrow from &mut T -> &T is required.
916-
if mutbl == Mutability::Not && matches!(ty.kind(), ty::Ref(_, _, Mutability::Mut)) {
916+
if mutbl == Mutability::Not && matches!(ty.kind(), ty::Ref(_, _, ty::Mutability::Mut)) {
917917
"&*"
918918
} else {
919919
""

src/tools/clippy/clippy_lints/src/functions/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, tys: &mut DefIdSet)
207207
ty::Tuple(args) => args.iter().any(|ty| is_mutable_ty(cx, ty, tys)),
208208
ty::Array(ty, _) | ty::Slice(ty) => is_mutable_ty(cx, ty, tys),
209209
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) | ty::Ref(_, ty, mutbl) => {
210-
mutbl == hir::Mutability::Mut || is_mutable_ty(cx, ty, tys)
210+
mutbl == ty::Mutability::Mut || is_mutable_ty(cx, ty, tys)
211211
},
212212
// calling something constitutes a side effect, so return true on all callables
213213
// also never calls need not be used, so return true for them, too

src/tools/clippy/clippy_lints/src/iter_without_into_iter.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::get_parent_as_impl;
33
use clippy_utils::source::snippet;
44
use clippy_utils::ty::{implements_trait, make_normalized_projection};
5-
use rustc_ast::Mutability;
65
use rustc_errors::Applicability;
76
use rustc_hir::{FnRetTy, ImplItemKind, ImplicitSelfKind, ItemKind, TyKind};
87
use rustc_lint::{LateContext, LateLintPass};
@@ -124,8 +123,8 @@ impl LateLintPass<'_> for IterWithoutIntoIter {
124123
&& trait_ref.trait_def_id().is_some_and(|did| cx.tcx.is_diagnostic_item(sym::IntoIterator, did))
125124
&& let &ty::Ref(_, ty, mtbl) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
126125
&& let expected_method_name = match mtbl {
127-
Mutability::Mut => sym::iter_mut,
128-
Mutability::Not => sym::iter,
126+
ty::Mutability::Mut => sym::iter_mut,
127+
ty::Mutability::Not => sym::iter,
129128
}
130129
&& !type_has_inherent_method(cx, ty, expected_method_name)
131130
&& let Some(iter_assoc_span) = imp.items.iter().find_map(|item| {

src/tools/clippy/clippy_lints/src/len_zero.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hir::def::Res;
99
use rustc_hir::def_id::{DefId, DefIdSet};
1010
use rustc_hir::{
1111
AssocItemKind, BinOpKind, Expr, ExprKind, FnRetTy, GenericArg, GenericBound, ImplItem, ImplItemKind,
12-
ImplicitSelfKind, Item, ItemKind, LangItem, Mutability, Node, PatKind, PathSegment, PrimTy, QPath, TraitItemRef,
12+
ImplicitSelfKind, Item, ItemKind, LangItem, Node, PatKind, PathSegment, PrimTy, QPath, TraitItemRef,
1313
TyKind, TypeBindingKind,
1414
};
1515
use rustc_lint::{LateContext, LateLintPass};
@@ -406,8 +406,8 @@ fn check_is_empty_sig<'tcx>(
406406
[arg, res] if len_output.matches_is_empty_output(cx, *res) => {
407407
matches!(
408408
(arg.kind(), self_kind),
409-
(ty::Ref(_, _, Mutability::Not), ImplicitSelfKind::ImmRef)
410-
| (ty::Ref(_, _, Mutability::Mut), ImplicitSelfKind::MutRef)
409+
(ty::Ref(_, _, ty::Mutability::Not), ImplicitSelfKind::ImmRef)
410+
| (ty::Ref(_, _, ty::Mutability::Mut), ImplicitSelfKind::MutRef)
411411
) || (!arg.is_ref() && matches!(self_kind, ImplicitSelfKind::Imm | ImplicitSelfKind::Mut))
412412
},
413413
_ => false,

src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use clippy_utils::ty::{
77
make_normalized_projection_with_regions, normalize_with_regions,
88
};
99
use rustc_errors::Applicability;
10-
use rustc_hir::{Expr, Mutability};
10+
use rustc_hir::Expr;
1111
use rustc_lint::LateContext;
1212
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
1313
use rustc_middle::ty::{self, EarlyBinder, Ty, TypeAndMut};
@@ -61,10 +61,10 @@ enum AdjustKind {
6161
ReborrowMut,
6262
}
6363
impl AdjustKind {
64-
fn borrow(mutbl: Mutability) -> Self {
64+
fn borrow(mutbl: ty::Mutability) -> Self {
6565
match mutbl {
66-
Mutability::Not => Self::Borrow,
67-
Mutability::Mut => Self::BorrowMut,
66+
ty::Mutability::Not => Self::Borrow,
67+
ty::Mutability::Mut => Self::BorrowMut,
6868
}
6969
}
7070

@@ -75,10 +75,10 @@ impl AdjustKind {
7575
}
7676
}
7777

78-
fn reborrow(mutbl: Mutability) -> Self {
78+
fn reborrow(mutbl: ty::Mutability) -> Self {
7979
match mutbl {
80-
Mutability::Not => Self::Reborrow,
81-
Mutability::Mut => Self::ReborrowMut,
80+
ty::Mutability::Not => Self::Reborrow,
81+
ty::Mutability::Mut => Self::ReborrowMut,
8282
}
8383
}
8484

@@ -150,7 +150,7 @@ fn is_ref_iterable<'tcx>(
150150
return Some((AdjustKind::None, self_ty));
151151
}
152152
} else if enforce_iter_loop_reborrow
153-
&& let ty::Ref(region, ty, Mutability::Mut) = *self_ty.kind()
153+
&& let ty::Ref(region, ty, ty::Mutability::Mut) = *self_ty.kind()
154154
&& let Some(mutbl) = mutbl
155155
{
156156
// Attempt to reborrow the mutable reference

src/tools/clippy/clippy_lints/src/loops/for_kv_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
44
use clippy_utils::sugg;
55
use clippy_utils::ty::is_type_diagnostic_item;
66
use clippy_utils::visitors::is_local_used;
7-
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind};
7+
use rustc_hir::{BorrowKind, Expr, ExprKind, Pat, PatKind};
88
use rustc_lint::LateContext;
99
use rustc_middle::ty;
1010
use rustc_span::sym;
@@ -19,14 +19,14 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx
1919
let (new_pat_span, kind, ty, mutbl) = match *cx.typeck_results().expr_ty(arg).kind() {
2020
ty::Ref(_, ty, mutbl) => match (&pat[0].kind, &pat[1].kind) {
2121
(key, _) if pat_is_wild(cx, key, body) => (pat[1].span, "value", ty, mutbl),
22-
(_, value) if pat_is_wild(cx, value, body) => (pat[0].span, "key", ty, Mutability::Not),
22+
(_, value) if pat_is_wild(cx, value, body) => (pat[0].span, "key", ty, ty::Mutability::Not),
2323
_ => return,
2424
},
2525
_ => return,
2626
};
2727
let mutbl = match mutbl {
28-
Mutability::Not => "",
29-
Mutability::Mut => "_mut",
28+
ty::Mutability::Not => "",
29+
ty::Mutability::Mut => "_mut",
3030
};
3131
let arg = match arg.kind {
3232
ExprKind::AddrOf(BorrowKind::Ref, _, expr) => expr,

src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
360360
let ty = self.cx.typeck_results().expr_ty_adjusted(expr);
361361
self.prefer_mutable = false;
362362
if let ty::Ref(_, _, mutbl) = *ty.kind() {
363-
if mutbl == Mutability::Mut {
363+
if mutbl == ty::Mutability::Mut {
364364
self.prefer_mutable = true;
365365
}
366366
}
@@ -375,7 +375,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
375375
) {
376376
self.prefer_mutable = false;
377377
if let ty::Ref(_, _, mutbl) = *ty.kind() {
378-
if mutbl == Mutability::Mut {
378+
if mutbl == ty::Mutability::Mut {
379379
self.prefer_mutable = true;
380380
}
381381
}

src/tools/clippy/clippy_lints/src/loops/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ pub(super) fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic
331331
match &arg_ty.kind() {
332332
ty::Ref(_, inner_ty, mutbl) if has_iter_method(cx, *inner_ty).is_some() => {
333333
let method_name = match mutbl {
334-
Mutability::Mut => "iter_mut",
335-
Mutability::Not => "iter",
334+
ty::Mutability::Mut => "iter_mut",
335+
ty::Mutability::Not => "iter",
336336
};
337337
let caller = match &arg.kind {
338338
ExprKind::AddrOf(BorrowKind::Ref, _, arg_inner) => arg_inner,

src/tools/clippy/clippy_lints/src/loops/while_let_on_iterator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ use if_chain::if_chain;
77
use rustc_errors::Applicability;
88
use rustc_hir::def::Res;
99
use rustc_hir::intravisit::{walk_expr, Visitor};
10-
use rustc_hir::{Closure, Expr, ExprKind, HirId, LangItem, Local, Mutability, PatKind, UnOp};
10+
use rustc_hir::{Closure, Expr, ExprKind, HirId, LangItem, Local, PatKind, UnOp};
1111
use rustc_lint::LateContext;
1212
use rustc_middle::hir::nested_filter::OnlyBodies;
1313
use rustc_middle::ty::adjustment::Adjust;
14+
use rustc_middle::ty;
1415
use rustc_span::symbol::sym;
1516
use rustc_span::Symbol;
1617

@@ -48,7 +49,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
4849
// If the iterator is a field or the iterator is accessed after the loop is complete it needs to be
4950
// borrowed mutably. TODO: If the struct can be partially moved from and the struct isn't used
5051
// afterwards a mutable borrow of a field isn't necessary.
51-
let by_ref = if cx.typeck_results().expr_ty(iter_expr).ref_mutability() == Some(Mutability::Mut)
52+
let by_ref = if cx.typeck_results().expr_ty(iter_expr).ref_mutability() == Some(ty::Mutability::Mut)
5253
|| !iter_expr_struct.can_move
5354
|| !iter_expr_struct.fields.is_empty()
5455
|| needs_mutable_borrow(cx, &iter_expr_struct, loop_expr)

src/tools/clippy/clippy_lints/src/manual_main_separator_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::msrvs::{self, Msrv};
33
use clippy_utils::{is_trait_method, match_def_path, paths, peel_hir_expr_refs};
44
use rustc_errors::Applicability;
55
use rustc_hir::def::{DefKind, Res};
6-
use rustc_hir::{Expr, ExprKind, Mutability, QPath};
6+
use rustc_hir::{Expr, ExprKind, QPath};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_middle::ty;
99
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -55,7 +55,7 @@ impl LateLintPass<'_> for ManualMainSeparatorStr {
5555
let ExprKind::Path(QPath::Resolved(None, path)) = receiver.kind &&
5656
let Res::Def(DefKind::Const, receiver_def_id) = path.res &&
5757
match_def_path(cx, receiver_def_id, &paths::PATH_MAIN_SEPARATOR) &&
58-
let ty::Ref(_, ty, Mutability::Not) = cx.typeck_results().expr_ty_adjusted(expr).kind() &&
58+
let ty::Ref(_, ty, ty::Mutability::Not) = cx.typeck_results().expr_ty_adjusted(expr).kind() &&
5959
ty.is_str()
6060
{
6161
span_lint_and_sugg(

src/tools/clippy/clippy_lints/src/matches/manual_utils.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_hir::LangItem::{OptionNone, OptionSome};
1414
use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Path, QPath};
1515
use rustc_lint::LateContext;
1616
use rustc_span::{sym, SyntaxContext};
17+
use rustc_middle::ty;
1718

1819
#[expect(clippy::too_many_arguments)]
1920
#[expect(clippy::too_many_lines)]
@@ -101,11 +102,11 @@ where
101102
});
102103
if let ExprKind::Path(QPath::Resolved(None, Path { res: Res::Local(l), .. })) = e.kind {
103104
match captures.get(l) {
104-
Some(CaptureKind::Value | CaptureKind::Ref(Mutability::Mut)) => return None,
105-
Some(CaptureKind::Ref(Mutability::Not)) if binding_ref_mutability == Mutability::Mut => {
105+
Some(CaptureKind::Value | CaptureKind::Ref(ty::Mutability::Mut)) => return None,
106+
Some(CaptureKind::Ref(ty::Mutability::Not)) if binding_ref_mutability == Mutability::Mut => {
106107
return None;
107108
},
108-
Some(CaptureKind::Ref(Mutability::Not)) | None => (),
109+
Some(CaptureKind::Ref(ty::Mutability::Not)) | None => (),
109110
}
110111
}
111112
}

src/tools/clippy/clippy_lints/src/methods/into_iter_on_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ fn ty_has_iter_method(cx: &LateContext<'_>, self_ref_ty: Ty<'_>) -> Option<(Symb
4646
unreachable!()
4747
};
4848
let method_name = match mutbl {
49-
hir::Mutability::Not => "iter",
50-
hir::Mutability::Mut => "iter_mut",
49+
ty::Mutability::Not => "iter",
50+
ty::Mutability::Mut => "iter_mut",
5151
};
5252
(ty_name, method_name)
5353
})

src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use clippy_utils::source::snippet_opt;
33
use clippy_utils::ty::{implements_trait, is_copy};
44
use rustc_ast::BindingAnnotation;
55
use rustc_errors::Applicability;
6-
use rustc_hir::{Body, Expr, ExprKind, HirId, HirIdSet, PatKind};
6+
use rustc_hir::{Body, Expr, ExprKind, HirId, HirIdSet, PatKind, Mutability};
77
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
88
use rustc_lint::LateContext;
9-
use rustc_middle::mir::{FakeReadCause, Mutability};
9+
use rustc_middle::mir::FakeReadCause;
1010
use rustc_middle::ty::{self, BorrowKind};
1111
use rustc_span::sym;
1212

src/tools/clippy/clippy_lints/src/methods/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,14 +4528,14 @@ impl SelfKind {
45284528
}
45294529
}
45304530

4531-
fn matches_ref<'a>(cx: &LateContext<'a>, mutability: hir::Mutability, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
4531+
fn matches_ref<'a>(cx: &LateContext<'a>, mutability: ty::Mutability, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
45324532
if let ty::Ref(_, t, m) = *ty.kind() {
45334533
return m == mutability && t == parent_ty;
45344534
}
45354535

45364536
let trait_sym = match mutability {
4537-
hir::Mutability::Not => sym::AsRef,
4538-
hir::Mutability::Mut => sym::AsMut,
4537+
ty::Mutability::Not => sym::AsRef,
4538+
ty::Mutability::Mut => sym::AsMut,
45394539
};
45404540

45414541
let Some(trait_def_id) = cx.tcx.get_diagnostic_item(trait_sym) else {
@@ -4546,14 +4546,14 @@ impl SelfKind {
45464546

45474547
fn matches_none<'a>(cx: &LateContext<'a>, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
45484548
!matches_value(cx, parent_ty, ty)
4549-
&& !matches_ref(cx, hir::Mutability::Not, parent_ty, ty)
4550-
&& !matches_ref(cx, hir::Mutability::Mut, parent_ty, ty)
4549+
&& !matches_ref(cx, ty::Mutability::Not, parent_ty, ty)
4550+
&& !matches_ref(cx, ty::Mutability::Mut, parent_ty, ty)
45514551
}
45524552

45534553
match self {
45544554
Self::Value => matches_value(cx, parent_ty, ty),
4555-
Self::Ref => matches_ref(cx, hir::Mutability::Not, parent_ty, ty) || ty == parent_ty && is_copy(cx, ty),
4556-
Self::RefMut => matches_ref(cx, hir::Mutability::Mut, parent_ty, ty),
4555+
Self::Ref => matches_ref(cx, ty::Mutability::Not, parent_ty, ty) || ty == parent_ty && is_copy(cx, ty),
4556+
Self::RefMut => matches_ref(cx, ty::Mutability::Mut, parent_ty, ty),
45574557
Self::No => matches_none(cx, parent_ty, ty),
45584558
}
45594559
}

0 commit comments

Comments
 (0)