Skip to content

Commit abc59bb

Browse files
committed
Auto merge of #8656 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 574bf88 + a2fdbb5 commit abc59bb

34 files changed

+196
-157
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ document.
88

99
[57b3c4b...master](https://github.com/rust-lang/rust-clippy/compare/57b3c4b...master)
1010

11-
## Rust 1.60 (beta)
11+
## Rust 1.60
1212

13-
Current beta, release 2022-04-07
13+
Current stable, released 2022-04-07
1414

1515
[0eff589...57b3c4b](https://github.com/rust-lang/rust-clippy/compare/0eff589...57b3c4b)
1616

@@ -142,7 +142,7 @@ Current beta, release 2022-04-07
142142

143143
## Rust 1.59
144144

145-
Current stable, release 2022-02-24
145+
Released 2022-02-24
146146

147147
[e181011...0eff589](https://github.com/rust-lang/rust-clippy/compare/e181011...0eff589)
148148

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.61"
3+
version = "0.1.62"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.61"
3+
version = "0.1.62"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/arithmetic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
139139
}
140140

141141
fn check_body(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
142-
let body_owner = cx.tcx.hir().body_owner(body.id());
142+
let body_owner = cx.tcx.hir().body_owner_def_id(body.id());
143143

144144
match cx.tcx.hir().body_owner_kind(body_owner) {
145145
hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const => {
146-
let body_span = cx.tcx.hir().span(body_owner);
146+
let body_span = cx.tcx.def_span(body_owner);
147147

148148
if let Some(span) = self.const_span {
149149
if span.contains(body_span) {

clippy_lints/src/collapsible_match.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ use clippy_utils::higher::IfLetOrMatch;
33
use clippy_utils::visitors::is_local_used;
44
use clippy_utils::{is_lang_ctor, is_unit_expr, path_to_local, peel_blocks_with_stmt, peel_ref_operators, SpanlessEq};
55
use if_chain::if_chain;
6+
use rustc_errors::MultiSpan;
67
use rustc_hir::LangItem::OptionNone;
78
use rustc_hir::{Arm, Expr, Guard, HirId, Pat, PatKind};
89
use rustc_lint::{LateContext, LateLintPass};
910
use rustc_session::{declare_lint_pass, declare_tool_lint};
10-
use rustc_span::{MultiSpan, Span};
11+
use rustc_span::Span;
1112

1213
declare_clippy_lint! {
1314
/// ### What it does
@@ -129,8 +130,8 @@ fn check_arm<'tcx>(
129130
&msg,
130131
|diag| {
131132
let mut help_span = MultiSpan::from_spans(vec![binding_span, inner_then_pat.span]);
132-
help_span.push_span_label(binding_span, "replace this binding".into());
133-
help_span.push_span_label(inner_then_pat.span, "with this pattern".into());
133+
help_span.push_span_label(binding_span, "replace this binding");
134+
help_span.push_span_label(inner_then_pat.span, "with this pattern");
134135
diag.span_help(help_span, "the outer pattern can be modified to include the inner pattern");
135136
},
136137
);

clippy_lints/src/doc.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_ast::token::CommentKind;
1111
use rustc_data_structures::fx::FxHashSet;
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_errors::emitter::EmitterWriter;
14-
use rustc_errors::{Applicability, Handler, SuggestionStyle};
14+
use rustc_errors::{Applicability, Handler, MultiSpan, SuggestionStyle};
1515
use rustc_hir as hir;
1616
use rustc_hir::intravisit::{self, Visitor};
1717
use rustc_hir::{AnonConst, Expr};
@@ -25,7 +25,7 @@ use rustc_session::parse::ParseSess;
2525
use rustc_session::{declare_tool_lint, impl_lint_pass};
2626
use rustc_span::def_id::LocalDefId;
2727
use rustc_span::edition::Edition;
28-
use rustc_span::source_map::{BytePos, FilePathMapping, MultiSpan, SourceMap, Span};
28+
use rustc_span::source_map::{BytePos, FilePathMapping, SourceMap, Span};
2929
use rustc_span::{sym, FileName, Pos};
3030
use std::io;
3131
use std::ops::Range;
@@ -621,7 +621,19 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
621621
let filename = FileName::anon_source_code(&code);
622622

623623
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
624-
let emitter = EmitterWriter::new(Box::new(io::sink()), None, false, false, false, None, false);
624+
let fallback_bundle =
625+
rustc_errors::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle");
626+
let emitter = EmitterWriter::new(
627+
Box::new(io::sink()),
628+
None,
629+
None,
630+
fallback_bundle,
631+
false,
632+
false,
633+
false,
634+
None,
635+
false,
636+
);
625637
let handler = Handler::with_emitter(false, None, Box::new(emitter));
626638
let sess = ParseSess::with_span_handler(handler, sm);
627639

clippy_lints/src/implicit_saturating_sub.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::{higher, peel_blocks_with_stmt, SpanlessEq};
33
use if_chain::if_chain;
44
use rustc_ast::ast::LitKind;
55
use rustc_errors::Applicability;
6-
use rustc_hir::{lang_items::LangItem, BinOpKind, Expr, ExprKind, QPath};
6+
use rustc_hir::{BinOpKind, Expr, ExprKind, QPath};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99

@@ -82,14 +82,6 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
8282

8383
// Get the variable name
8484
let var_name = ares_path.segments[0].ident.name.as_str();
85-
const INT_TYPES: [LangItem; 5] = [
86-
LangItem::I8,
87-
LangItem::I16,
88-
LangItem::I32,
89-
LangItem::I64,
90-
LangItem::Isize
91-
];
92-
9385
match cond_num_val.kind {
9486
ExprKind::Lit(ref cond_lit) => {
9587
// Check if the constant is zero
@@ -105,8 +97,8 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
10597
if name.ident.as_str() == "MIN";
10698
if let Some(const_id) = cx.typeck_results().type_dependent_def_id(cond_num_val.hir_id);
10799
if let Some(impl_id) = cx.tcx.impl_of_method(const_id);
108-
let mut int_ids = INT_TYPES.iter().filter_map(|&ty| cx.tcx.lang_items().require(ty).ok());
109-
if int_ids.any(|int_id| int_id == impl_id);
100+
if let None = cx.tcx.impl_trait_ref(impl_id); // An inherent impl
101+
if cx.tcx.type_of(impl_id).is_integral();
110102
then {
111103
print_lint_and_sugg(cx, var_name, expr)
112104
}
@@ -118,8 +110,8 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
118110
if name.ident.as_str() == "min_value";
119111
if let Some(func_id) = cx.typeck_results().type_dependent_def_id(func.hir_id);
120112
if let Some(impl_id) = cx.tcx.impl_of_method(func_id);
121-
let mut int_ids = INT_TYPES.iter().filter_map(|&ty| cx.tcx.lang_items().require(ty).ok());
122-
if int_ids.any(|int_id| int_id == impl_id);
113+
if let None = cx.tcx.impl_trait_ref(impl_id); // An inherent impl
114+
if cx.tcx.type_of(impl_id).is_integral();
123115
then {
124116
print_lint_and_sugg(cx, var_name, expr)
125117
}

clippy_lints/src/loops/needless_collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ use clippy_utils::ty::is_type_diagnostic_item;
66
use clippy_utils::{can_move_expr_to_closure, is_trait_method, path_to_local, path_to_local_id, CaptureKind};
77
use if_chain::if_chain;
88
use rustc_data_structures::fx::FxHashMap;
9-
use rustc_errors::Applicability;
9+
use rustc_errors::{Applicability, MultiSpan};
1010
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
1111
use rustc_hir::{Block, Expr, ExprKind, HirId, HirIdSet, Local, Mutability, Node, PatKind, Stmt, StmtKind};
1212
use rustc_lint::LateContext;
1313
use rustc_middle::hir::nested_filter;
1414
use rustc_middle::ty::subst::GenericArgKind;
1515
use rustc_middle::ty::{self, Ty};
1616
use rustc_span::sym;
17-
use rustc_span::{MultiSpan, Span};
17+
use rustc_span::Span;
1818

1919
const NEEDLESS_COLLECT_MSG: &str = "avoid using `collect()` when not needed";
2020

@@ -102,7 +102,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
102102

103103
// Suggest replacing iter_call with iter_replacement, and removing stmt
104104
let mut span = MultiSpan::from_span(method_name.ident.span);
105-
span.push_span_label(iter_call.span, "the iterator could be used here instead".into());
105+
span.push_span_label(iter_call.span, "the iterator could be used here instead");
106106
span_lint_hir_and_then(
107107
cx,
108108
super::NEEDLESS_COLLECT,

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
273273
}
274274
return false; // no need to walk further *on the variable*
275275
}
276-
Res::Def(DefKind::Static | DefKind::Const, ..) => {
276+
Res::Def(DefKind::Static (_)| DefKind::Const, ..) => {
277277
if index_used_directly {
278278
self.indexed_directly.insert(
279279
seqvar.segments[0].ident.name,

clippy_lints/src/loops/while_immutable_condition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> {
104104
Res::Local(hir_id) => {
105105
self.ids.insert(hir_id);
106106
},
107-
Res::Def(DefKind::Static, def_id) => {
107+
Res::Def(DefKind::Static(_), def_id) => {
108108
let mutable = self.cx.tcx.is_mutable_static(def_id);
109109
self.def_ids.insert(def_id, mutable);
110110
},

0 commit comments

Comments
 (0)