Skip to content

Commit 6220dff

Browse files
committed
Auto merge of #5922 - flip1995:rustup, r=flip1995
Rustup r? @ghost changelog: none
2 parents 9360ca6 + c680602 commit 6220dff

29 files changed

+138
-156
lines changed

clippy_lints/src/attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::utils::{
55
span_lint_and_sugg, span_lint_and_then, without_block_comments,
66
};
77
use if_chain::if_chain;
8-
use rustc_ast::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
98
use rustc_ast::util::lev_distance::find_best_match_for_name;
9+
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
1010
use rustc_errors::Applicability;
1111
use rustc_hir::{
1212
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
@@ -570,7 +570,7 @@ declare_lint_pass!(EarlyAttributes => [
570570
]);
571571

572572
impl EarlyLintPass for EarlyAttributes {
573-
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &rustc_ast::ast::Item) {
573+
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &rustc_ast::Item) {
574574
check_empty_line_after_outer_attr(cx, item);
575575
}
576576

@@ -580,7 +580,7 @@ impl EarlyLintPass for EarlyAttributes {
580580
}
581581
}
582582

583-
fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::ast::Item) {
583+
fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::Item) {
584584
for attr in &item.attrs {
585585
let attr_item = if let AttrKind::Normal(ref attr) = attr.kind {
586586
attr

clippy_lints/src/default_trait_access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultTraitAccess {
6868
);
6969
}
7070
},
71-
QPath::TypeRelative(..) => {},
71+
QPath::TypeRelative(..) | QPath::LangItem(..) => {},
7272
}
7373
}
7474
}

clippy_lints/src/indexing_slicing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
8989
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
9090
if let ExprKind::Index(ref array, ref index) = &expr.kind {
9191
let ty = cx.typeck_results().expr_ty(array);
92-
if let Some(range) = higher::range(cx, index) {
92+
if let Some(range) = higher::range(index) {
9393
// Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..]
9494
if let ty::Array(_, s) = ty.kind {
9595
let size: u128 = if let Some(size) = s.try_eval_usize(cx.tcx, cx.param_env) {

clippy_lints/src/infinite_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
171171
Finite
172172
}
173173
},
174-
ExprKind::Struct(..) => higher::range(cx, expr).map_or(false, |r| r.end.is_none()).into(),
174+
ExprKind::Struct(..) => higher::range(expr).map_or(false, |r| r.end.is_none()).into(),
175175
_ => Finite,
176176
}
177177
}

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn check_len(
262262
fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
263263
/// Special case ranges until `range_is_empty` is stabilized. See issue 3807.
264264
fn should_skip_range(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
265-
higher::range(cx, expr).map_or(false, |_| {
265+
higher::range(expr).map_or(false, |_| {
266266
!cx.tcx
267267
.features()
268268
.declared_lib_features

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore) {
341341
}
342342

343343
#[doc(hidden)]
344-
pub fn read_conf(args: &[rustc_ast::ast::NestedMetaItem], sess: &Session) -> Conf {
344+
pub fn read_conf(args: &[rustc_ast::NestedMetaItem], sess: &Session) -> Conf {
345345
use std::path::Path;
346346
match utils::conf::file_from_args(args) {
347347
Ok(file_name) => {

clippy_lints/src/loops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ fn detect_manual_memcpy<'tcx>(
10031003
start: Some(start),
10041004
end: Some(end),
10051005
limits,
1006-
}) = higher::range(cx, arg)
1006+
}) = higher::range(arg)
10071007
{
10081008
// the var must be a single name
10091009
if let PatKind::Binding(_, canonical_id, _, _) = pat.kind {
@@ -1197,7 +1197,7 @@ fn check_for_loop_range<'tcx>(
11971197
start: Some(start),
11981198
ref end,
11991199
limits,
1200-
}) = higher::range(cx, arg)
1200+
}) = higher::range(arg)
12011201
{
12021202
// the var must be a single name
12031203
if let PatKind::Binding(_, canonical_id, ident, _) = pat.kind {
@@ -1699,7 +1699,7 @@ fn check_for_mut_range_bound(cx: &LateContext<'_>, arg: &Expr<'_>, body: &Expr<'
16991699
start: Some(start),
17001700
end: Some(end),
17011701
..
1702-
}) = higher::range(cx, arg)
1702+
}) = higher::range(arg)
17031703
{
17041704
let mut_ids = vec![check_for_mutability(cx, start), check_for_mutability(cx, end)];
17051705
if mut_ids[0].is_some() || mut_ids[1].is_some() {

clippy_lints/src/match_on_vec_items.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use crate::utils::{self, is_type_diagnostic_item, match_type, snippet, span_lint_and_sugg, walk_ptrs_ty};
1+
use crate::utils::walk_ptrs_ty;
2+
use crate::utils::{is_type_diagnostic_item, is_type_lang_item, snippet, span_lint_and_sugg};
23
use if_chain::if_chain;
34
use rustc_errors::Applicability;
4-
use rustc_hir::{Expr, ExprKind, MatchSource};
5+
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource};
56
use rustc_lint::{LateContext, LateLintPass, LintContext};
67
use rustc_middle::lint::in_external_macro;
78
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -96,5 +97,5 @@ fn is_vector(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
9697
fn is_full_range(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
9798
let ty = cx.typeck_results().expr_ty(expr);
9899
let ty = walk_ptrs_ty(ty);
99-
match_type(cx, ty, &utils::paths::RANGE_FULL)
100+
is_type_lang_item(cx, ty, LangItem::RangeFull)
100101
}

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2364,7 +2364,7 @@ fn lint_iter_next<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, iter_
23642364
if_chain! {
23652365
if let hir::ExprKind::Index(ref caller_var, ref index_expr) = &caller_expr.kind;
23662366
if let Some(higher::Range { start: Some(start_expr), end: None, limits: ast::RangeLimits::HalfOpen })
2367-
= higher::range(cx, index_expr);
2367+
= higher::range(index_expr);
23682368
if let hir::ExprKind::Lit(ref start_lit) = &start_expr.kind;
23692369
if let ast::LitKind::Int(start_idx, _) = start_lit.node;
23702370
then {

clippy_lints/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints {
433433
return;
434434
}
435435
let binding = match expr.kind {
436-
ExprKind::Path(ref qpath) => {
436+
ExprKind::Path(ref qpath) if !matches!(qpath, hir::QPath::LangItem(..)) => {
437437
let binding = last_path_segment(qpath).ident.as_str();
438438
if binding.starts_with('_') &&
439439
!binding.starts_with("__") &&

0 commit comments

Comments
 (0)