Skip to content

Commit e6f29f1

Browse files
committed
dogfood
1 parent 31fd282 commit e6f29f1

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

clippy_lints/src/loops/same_item_push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn get_vec_push<'tcx>(
185185
if let StmtKind::Semi(semi_stmt) = &stmt.kind;
186186
if let ExprKind::MethodCall(path, self_expr, args, _) = &semi_stmt.kind;
187187
// Figure out the parameters for the method call
188-
if let Some(pushed_item) = args.get(0);
188+
if let Some(pushed_item) = args.first();
189189
// Check that the method being called is push() on a Vec
190190
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(self_expr), sym::Vec);
191191
if path.ident.name.as_str() == "push";

clippy_lints/src/manual_bits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ fn get_size_of_ty<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<
103103
if let ExprKind::Path(ref count_func_qpath) = count_func.kind;
104104

105105
if let QPath::Resolved(_, count_func_path) = count_func_qpath;
106-
if let Some(segment_zero) = count_func_path.segments.get(0);
106+
if let Some(segment_zero) = count_func_path.segments.first();
107107
if let Some(args) = segment_zero.args;
108-
if let Some(GenericArg::Type(real_ty)) = args.args.get(0);
108+
if let Some(GenericArg::Type(real_ty)) = args.args.first();
109109

110110
if let Some(def_id) = cx.qpath_res(count_func_qpath, count_func.hir_id).opt_def_id();
111111
if cx.tcx.is_diagnostic_item(sym::mem_size_of, def_id);

clippy_lints/src/methods/search_is_some.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(super) fn check<'tcx>(
3939
if search_method == "find";
4040
if let hir::ExprKind::Closure(&hir::Closure { body, .. }) = search_arg.kind;
4141
let closure_body = cx.tcx.hir().body(body);
42-
if let Some(closure_arg) = closure_body.params.get(0);
42+
if let Some(closure_arg) = closure_body.params.first();
4343
then {
4444
if let hir::PatKind::Ref(..) = closure_arg.pat.kind {
4545
Some(search_snippet.replacen('&', "", 1))

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl MissingDoc {
6767
if_chain! {
6868
if let Some(meta) = meta;
6969
if let MetaItemKind::List(list) = meta.kind;
70-
if let Some(meta) = list.get(0);
70+
if let Some(meta) = list.first();
7171
if let Some(name) = meta.ident();
7272
then {
7373
name.name == sym::include

clippy_lints/src/needless_continue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fn needless_continue_in_else(else_expr: &ast::Expr, label: Option<&ast::Label>)
189189
}
190190

191191
fn is_first_block_stmt_continue(block: &ast::Block, label: Option<&ast::Label>) -> bool {
192-
block.stmts.get(0).map_or(false, |stmt| match stmt.kind {
192+
block.stmts.first().map_or(false, |stmt| match stmt.kind {
193193
ast::StmtKind::Semi(ref e) | ast::StmtKind::Expr(ref e) => {
194194
if let ast::ExprKind::Continue(ref l) = e.kind {
195195
compare_labels(label, l.as_ref())
@@ -434,7 +434,7 @@ fn erode_from_back(s: &str) -> String {
434434
}
435435

436436
fn span_of_first_expr_in_block(block: &ast::Block) -> Option<Span> {
437-
block.stmts.get(0).map(|stmt| stmt.span)
437+
block.stmts.first().map(|stmt| stmt.span)
438438
}
439439

440440
#[cfg(test)]

clippy_lints/src/slow_vector_initialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VectorInitializationVisitor<'a, 'tcx> {
335335

336336
fn visit_block(&mut self, block: &'tcx Block<'_>) {
337337
if self.initialization_found {
338-
if let Some(s) = block.stmts.get(0) {
338+
if let Some(s) = block.stmts.first() {
339339
self.visit_stmt(s);
340340
}
341341

clippy_lints/src/uninit_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn extract_set_len_self<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Opt
201201
let expr = peel_hir_expr_while(expr, |e| {
202202
if let ExprKind::Block(block, _) = e.kind {
203203
// Extract the first statement/expression
204-
match (block.stmts.get(0).map(|stmt| &stmt.kind), block.expr) {
204+
match (block.stmts.first().map(|stmt| &stmt.kind), block.expr) {
205205
(None, Some(expr)) => Some(expr),
206206
(Some(StmtKind::Expr(expr) | StmtKind::Semi(expr)), _) => Some(expr),
207207
_ => None,

clippy_lints/src/unnecessary_map_on_constructor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
4040
let (constructor_path, constructor_item) =
4141
if let hir::ExprKind::Call(constructor, constructor_args) = recv.kind
4242
&& let hir::ExprKind::Path(constructor_path) = constructor.kind
43-
&& let Some(arg) = constructor_args.get(0)
43+
&& let Some(arg) = constructor_args.first()
4444
{
4545
if constructor.span.from_expansion() || arg.span.from_expansion() {
4646
return;
@@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
6666
_ => return,
6767
}
6868

69-
if let Some(map_arg) = args.get(0)
69+
if let Some(map_arg) = args.first()
7070
&& let hir::ExprKind::Path(fun) = map_arg.kind
7171
{
7272
if map_arg.span.from_expansion() {

clippy_utils/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
504504
},
505505
(Some(Constant::Vec(vec)), _) => {
506506
if !vec.is_empty() && vec.iter().all(|x| *x == vec[0]) {
507-
match vec.get(0) {
507+
match vec.first() {
508508
Some(Constant::F32(x)) => Some(Constant::F32(*x)),
509509
Some(Constant::F64(x)) => Some(Constant::F64(*x)),
510510
_ => None,

clippy_utils/src/higher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ pub fn get_vec_init_kind<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -
449449
} else if name.ident.name == symbol::kw::Default {
450450
return Some(VecInitKind::Default);
451451
} else if name.ident.name.as_str() == "with_capacity" {
452-
let arg = args.get(0)?;
452+
let arg = args.first()?;
453453
return match constant_simple(cx, cx.typeck_results(), arg) {
454454
Some(Constant::Int(num)) => Some(VecInitKind::WithConstCapacity(num)),
455455
_ => Some(VecInitKind::WithExprCapacity(arg.hir_id)),

0 commit comments

Comments
 (0)