Skip to content

Commit 72b2659

Browse files
committed
Fix clippy and rustfmt compilation
1 parent a86973a commit 72b2659

File tree

4 files changed

+36
-35
lines changed

4 files changed

+36
-35
lines changed

compiler/rustc_parse/src/parser/ty.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use rustc_ast::ptr::P;
22
use rustc_ast::token::{self, BinOpToken, Delimiter, IdentIsRaw, Token, TokenKind};
33
use rustc_ast::util::case::Case;
44
use rustc_ast::{
5-
self as ast, BareFnTy, BoundAsyncness, BoundConstness, BoundPolarity, FnRetTy, GenericBound, GenericBounds, GenericParam, Generics, Lifetime, MacCall, MutTy, Mutability, Pinnedness, PolyTraitRef, PreciseCapturingArg, TraitBoundModifiers, TraitObjectSyntax, Ty, TyKind, DUMMY_NODE_ID
5+
self as ast, BareFnTy, BoundAsyncness, BoundConstness, BoundPolarity, DUMMY_NODE_ID, FnRetTy,
6+
GenericBound, GenericBounds, GenericParam, Generics, Lifetime, MacCall, MutTy, Mutability,
7+
Pinnedness, PolyTraitRef, PreciseCapturingArg, TraitBoundModifiers, TraitObjectSyntax, Ty,
8+
TyKind,
69
};
710
use rustc_errors::{Applicability, PResult};
811
use rustc_span::symbol::{Ident, kw, sym};

compiler/rustc_passes/src/hir_stats.rs

+24-27
Original file line numberDiff line numberDiff line change
@@ -575,33 +575,30 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
575575
}
576576

577577
fn visit_ty(&mut self, t: &'v ast::Ty) {
578-
record_variants!(
579-
(self, t, t.kind, Id::None, ast, Ty, TyKind),
580-
[
581-
Slice,
582-
Array,
583-
Ptr,
584-
Ref,
585-
PinnedRef,
586-
BareFn,
587-
Never,
588-
Tup,
589-
AnonStruct,
590-
AnonUnion,
591-
Path,
592-
Pat,
593-
TraitObject,
594-
ImplTrait,
595-
Paren,
596-
Typeof,
597-
Infer,
598-
ImplicitSelf,
599-
MacCall,
600-
CVarArgs,
601-
Dummy,
602-
Err
603-
]
604-
);
578+
record_variants!((self, t, t.kind, Id::None, ast, Ty, TyKind), [
579+
Slice,
580+
Array,
581+
Ptr,
582+
Ref,
583+
PinnedRef,
584+
BareFn,
585+
Never,
586+
Tup,
587+
AnonStruct,
588+
AnonUnion,
589+
Path,
590+
Pat,
591+
TraitObject,
592+
ImplTrait,
593+
Paren,
594+
Typeof,
595+
Infer,
596+
ImplicitSelf,
597+
MacCall,
598+
CVarArgs,
599+
Dummy,
600+
Err
601+
]);
605602

606603
ast_visit::walk_ty(self, t)
607604
}

src/tools/clippy/clippy_utils/src/ast_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,8 @@ pub fn eq_ty(l: &Ty, r: &Ty) -> bool {
722722
(Slice(l), Slice(r)) => eq_ty(l, r),
723723
(Array(le, ls), Array(re, rs)) => eq_ty(le, re) && eq_expr(&ls.value, &rs.value),
724724
(Ptr(l), Ptr(r)) => l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty),
725-
(Ref(ll, lp, l), Ref(rl, rp, r)) => {
726-
both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty) && lp == rp
725+
(Ref(ll, l), Ref(rl, r)) | (PinnedRef(ll, l), PinnedRef(rl, r)) => {
726+
both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty)
727727
},
728728
(BareFn(l), BareFn(r)) => {
729729
l.safety == r.safety

src/tools/rustfmt/src/types.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,9 @@ impl Rewrite for ast::Ty {
827827

828828
rewrite_unary_prefix(context, prefix, &*mt.ty, shape)
829829
}
830-
ast::TyKind::Ref(ref lifetime, _pinned, ref mt) => {
831-
// FIXME: format pinnedness
830+
ast::TyKind::Ref(ref lifetime, ref mt)
831+
| ast::TyKind::PinnedRef(ref lifetime, ref mt) => {
832+
// FIXME(pin_ergonomics): correctly format pinned reference syntax
832833
let mut_str = format_mutability(mt.mutbl);
833834
let mut_len = mut_str.len();
834835
let mut result = String::with_capacity(128);
@@ -1263,9 +1264,9 @@ pub(crate) fn can_be_overflowed_type(
12631264
) -> bool {
12641265
match ty.kind {
12651266
ast::TyKind::Tup(..) => context.use_block_indent() && len == 1,
1266-
ast::TyKind::Ref(_, _, ref mutty) | ast::TyKind::Ptr(ref mutty) => {
1267-
can_be_overflowed_type(context, &*mutty.ty, len)
1268-
}
1267+
ast::TyKind::Ref(_, ref mutty)
1268+
| ast::TyKind::PinnedRef(_, ref mutty)
1269+
| ast::TyKind::Ptr(ref mutty) => can_be_overflowed_type(context, &*mutty.ty, len),
12691270
_ => false,
12701271
}
12711272
}

0 commit comments

Comments
 (0)