Skip to content

Commit 74379d4

Browse files
committed
Actually infer args in visitors
1 parent 8286824 commit 74379d4

File tree

3 files changed

+6
-52
lines changed

3 files changed

+6
-52
lines changed

clippy_lints/src/use_self.rs

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hir::{
99
def::{CtorOf, DefKind, Res},
1010
def_id::LocalDefId,
1111
intravisit::{walk_ty, walk_inf, NestedVisitorMap, Visitor},
12-
Expr, ExprKind, FnRetTy, FnSig, GenericArg, HirId, Impl, ImplItemKind, Item, ItemKind, Node, Path, PathSegment,
12+
Expr, ExprKind, FnRetTy, FnSig, GenericArg, HirId, Impl, ImplItemKind, Item, ItemKind, Path,
1313
QPath, TyKind,
1414
};
1515
use rustc_lint::{LateContext, LateLintPass, LintContext};
@@ -280,52 +280,6 @@ impl<'tcx> Visitor<'tcx> for SkipTyCollector {
280280
}
281281
}
282282

283-
<<<<<<< HEAD
284-
=======
285-
struct LintTyCollector<'a, 'tcx> {
286-
cx: &'a LateContext<'tcx>,
287-
self_ty: Ty<'tcx>,
288-
types_to_lint: Vec<HirId>,
289-
types_to_skip: Vec<HirId>,
290-
}
291-
292-
impl<'a, 'tcx> Visitor<'tcx> for LintTyCollector<'a, 'tcx> {
293-
type Map = Map<'tcx>;
294-
295-
fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'_>) {
296-
if_chain! {
297-
if let Some(ty) = self.cx.typeck_results().node_type_opt(hir_ty.hir_id);
298-
if should_lint_ty(hir_ty, ty, self.self_ty);
299-
then {
300-
self.types_to_lint.push(hir_ty.hir_id);
301-
} else {
302-
self.types_to_skip.push(hir_ty.hir_id);
303-
}
304-
}
305-
306-
walk_ty(self, hir_ty);
307-
}
308-
309-
fn visit_infer(&mut self, inf: &'tcx hir::InferArg) {
310-
if_chain! {
311-
if let Some(ty) = self.cx.typeck_results().node_type_opt(inf.hir_id);
312-
if should_lint_ty(&inf.to_ty(), ty, self.self_ty);
313-
then {
314-
self.types_to_lint.push(inf.hir_id);
315-
} else {
316-
self.types_to_skip.push(inf.hir_id);
317-
}
318-
}
319-
320-
walk_inf(self, inf)
321-
}
322-
323-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
324-
NestedVisitorMap::None
325-
}
326-
}
327-
328-
>>>>>>> Add inferred args to typeck
329283
fn span_lint(cx: &LateContext<'_>, span: Span) {
330284
span_lint_and_sugg(
331285
cx,

clippy_utils/src/hir_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
904904
mut_ty.mutbl.hash(&mut self.s);
905905
},
906906
TyKind::Rptr(lifetime, ref mut_ty) => {
907-
self.hash_lifetime(lifetime);
907+
self.hash_lifetime(*lifetime);
908908
self.hash_ty(mut_ty.ty);
909909
mut_ty.mutbl.hash(&mut self.s);
910910
},
@@ -924,7 +924,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
924924
bfn.decl.c_variadic.hash(&mut self.s);
925925
},
926926
TyKind::Tup(ty_list) => {
927-
for ty in ty_list {
927+
for ty in *ty_list {
928928
self.hash_ty(ty);
929929
}
930930
},
@@ -933,7 +933,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
933933
self.hash_generic_args(arg_list);
934934
},
935935
TyKind::TraitObject(_, lifetime, _) => {
936-
self.hash_lifetime(lifetime);
936+
self.hash_lifetime(*lifetime);
937937
},
938938
TyKind::Typeof(anon_const) => {
939939
self.hash_body(anon_const.body);

tests/ui/transmute_ptr_to_ref.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ error: transmute from a pointer type (`*const i32`) to a reference type (`&issue
4646
--> $DIR/transmute_ptr_to_ref.rs:32:32
4747
|
4848
LL | let _: &Foo<u8> = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) };
49-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const issue1231::Foo<u8>)`
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<_>)`
5050

5151
error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<&u8>`)
5252
--> $DIR/transmute_ptr_to_ref.rs:34:33
5353
|
5454
LL | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) };
55-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const issue1231::Foo<&u8>)`
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<&_>)`
5656

5757
error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`)
5858
--> $DIR/transmute_ptr_to_ref.rs:38:14

0 commit comments

Comments
 (0)