Skip to content

Commit 5176a5c

Browse files
committed
Auto merge of #3726 - phansch:some_renaming, r=oli-obk
Some renamings: s/ast_ty/hir_ty and s/StructField/hir::StructField I think in both cases the new names make the code more understandable. For `StructField` specifically because there's one in [`syntax::ast`][ast] and one in [`rustc::hir`][hir]. [ast]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.StructField.html [hir]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.StructField.html
2 parents 84dca9a + ee7bad4 commit 5176a5c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

clippy_lints/src/types.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass {
186186
check_fn_decl(cx, decl);
187187
}
188188

189-
fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &StructField) {
189+
fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField) {
190190
check_ty(cx, &field.ty, false);
191191
}
192192

@@ -240,21 +240,21 @@ fn match_type_parameter(cx: &LateContext<'_, '_>, qpath: &QPath, path: &[&str])
240240
///
241241
/// The parameter `is_local` distinguishes the context of the type; types from
242242
/// local bindings should only be checked for the `BORROWED_BOX` lint.
243-
fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
244-
if in_macro(ast_ty.span) {
243+
fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool) {
244+
if in_macro(hir_ty.span) {
245245
return;
246246
}
247-
match ast_ty.node {
247+
match hir_ty.node {
248248
TyKind::Path(ref qpath) if !is_local => {
249-
let hir_id = cx.tcx.hir().node_to_hir_id(ast_ty.id);
249+
let hir_id = cx.tcx.hir().node_to_hir_id(hir_ty.id);
250250
let def = cx.tables.qpath_def(qpath, hir_id);
251251
if let Some(def_id) = opt_def_id(def) {
252252
if Some(def_id) == cx.tcx.lang_items().owned_box() {
253253
if match_type_parameter(cx, qpath, &paths::VEC) {
254254
span_help_and_lint(
255255
cx,
256256
BOX_VEC,
257-
ast_ty.span,
257+
hir_ty.span,
258258
"you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`",
259259
"`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.",
260260
);
@@ -288,7 +288,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
288288
span_lint_and_sugg(
289289
cx,
290290
VEC_BOX,
291-
ast_ty.span,
291+
hir_ty.span,
292292
"`Vec<T>` is already on the heap, the boxing is unnecessary.",
293293
"try",
294294
format!("Vec<{}>", boxed_type),
@@ -302,7 +302,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
302302
span_lint(
303303
cx,
304304
OPTION_OPTION,
305-
ast_ty.span,
305+
hir_ty.span,
306306
"consider using `Option<T>` instead of `Option<Option<T>>` or a custom \
307307
enum if you need to distinguish all 3 cases",
308308
);
@@ -312,7 +312,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
312312
span_help_and_lint(
313313
cx,
314314
LINKEDLIST,
315-
ast_ty.span,
315+
hir_ty.span,
316316
"I see you're using a LinkedList! Perhaps you meant some other data structure?",
317317
"a VecDeque might work",
318318
);
@@ -360,7 +360,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
360360
},
361361
}
362362
},
363-
TyKind::Rptr(ref lt, ref mut_ty) => check_ty_rptr(cx, ast_ty, is_local, lt, mut_ty),
363+
TyKind::Rptr(ref lt, ref mut_ty) => check_ty_rptr(cx, hir_ty, is_local, lt, mut_ty),
364364
// recurse
365365
TyKind::Slice(ref ty) | TyKind::Array(ref ty, _) | TyKind::Ptr(MutTy { ref ty, .. }) => {
366366
check_ty(cx, ty, is_local)
@@ -374,7 +374,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
374374
}
375375
}
376376

377-
fn check_ty_rptr(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool, lt: &Lifetime, mut_ty: &MutTy) {
377+
fn check_ty_rptr(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool, lt: &Lifetime, mut_ty: &MutTy) {
378378
match mut_ty.ty.node {
379379
TyKind::Path(ref qpath) => {
380380
let hir_id = cx.tcx.hir().node_to_hir_id(mut_ty.ty.id);
@@ -410,7 +410,7 @@ fn check_ty_rptr(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool, lt:
410410
span_lint_and_sugg(
411411
cx,
412412
BORROWED_BOX,
413-
ast_ty.span,
413+
hir_ty.span,
414414
"you seem to be trying to use `&Box<T>`. Consider using just `&T`",
415415
"try",
416416
format!(
@@ -1324,7 +1324,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexityPass {
13241324
self.check_fndecl(cx, decl);
13251325
}
13261326

1327-
fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx StructField) {
1327+
fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx hir::StructField) {
13281328
// enum variants are also struct fields now
13291329
self.check_type(cx, &field.ty);
13301330
}

0 commit comments

Comments
 (0)