Skip to content

Commit d396555

Browse files
Add sym::size_hint
1 parent 2b8d2b7 commit d396555

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

clippy_lints/src/iter_missing_exact_size.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::paths::{PathNS, lookup_path_str};
3+
use clippy_utils::sym as clippy_sym;
34
use clippy_utils::ty::{get_field_by_name, implements_trait, ty_from_hir_ty};
45
use rustc_errors::MultiSpan;
56
use rustc_hir::{Body, ExprKind, Impl, ImplItemKind, Item, ItemKind, OwnerId, OwnerNode};
@@ -107,7 +108,7 @@ fn size_hint_body<'tcx>(cx: &LateContext<'tcx>, owner_id: OwnerId) -> Option<&'t
107108
.find(|assoc_item| {
108109
assoc_item.expect_trait_impl().is_ok()
109110
&& assoc_item.is_method()
110-
&& assoc_item.name().as_str() == "size_hint"
111+
&& assoc_item.name() == clippy_sym::size_hint
111112
})?;
112113

113114
let node = cx.tcx.expect_hir_owner_node(size_hint_fn.def_id.expect_local());
@@ -151,7 +152,7 @@ impl<'tcx> LateLintPass<'tcx> for IterMissingExactSize {
151152
&& block.stmts.is_empty()
152153
&& let Some(trailing_expr) = block.expr
153154
&& let ExprKind::MethodCall(method_name, receiver, args, _) = trailing_expr.kind
154-
&& method_name.ident.as_str() == "size_hint"
155+
&& method_name.ident.name == clippy_sym::size_hint
155156
&& let ExprKind::Field(_object, field_name) = receiver.kind
156157
&& args.is_empty()
157158
{

clippy_utils/src/sym.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ generate! {
545545
set_readonly,
546546
signum,
547547
single_component_path_imports,
548+
size_hint,
548549
skip,
549550
skip_while,
550551
slice_from_ref,

0 commit comments

Comments
 (0)