Skip to content

Commit 57b3c4b

Browse files
committed
Auto merge of #8409 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 6966a42 + 49b9f92 commit 57b3c4b

27 files changed

+90
-91
lines changed

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir::{
1212
};
1313
use rustc_lint::{LateContext, LateLintPass};
1414
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
15-
use rustc_middle::ty::{self, Ty, TyCtxt, TyS, TypeckResults};
15+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeckResults};
1616
use rustc_session::{declare_tool_lint, impl_lint_pass};
1717
use rustc_span::{symbol::sym, Span};
1818

@@ -448,7 +448,7 @@ fn try_parse_ref_op<'tcx>(
448448
// the reference.
449449
fn deref_method_same_type(result_ty: Ty<'_>, arg_ty: Ty<'_>) -> bool {
450450
match (result_ty.kind(), arg_ty.kind()) {
451-
(ty::Ref(_, result_ty, _), ty::Ref(_, arg_ty, _)) => TyS::same_type(result_ty, arg_ty),
451+
(ty::Ref(_, result_ty, _), ty::Ref(_, arg_ty, _)) => result_ty == arg_ty,
452452

453453
// The result type for a deref method is always a reference
454454
// Not matching the previous pattern means the argument type is not a reference

clippy_lints/src/implicit_hasher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind}
88
use rustc_lint::{LateContext, LateLintPass, LintContext};
99
use rustc_middle::hir::nested_filter;
1010
use rustc_middle::lint::in_external_macro;
11-
use rustc_middle::ty::{Ty, TyS, TypeckResults};
11+
use rustc_middle::ty::{Ty, TypeckResults};
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
1313
use rustc_span::source_map::Span;
1414
use rustc_span::symbol::sym;
@@ -345,7 +345,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 't
345345
if let TyKind::Path(QPath::Resolved(None, ty_path)) = ty.kind;
346346
if let Some(ty_did) = ty_path.res.opt_def_id();
347347
then {
348-
if !TyS::same_type(self.target.ty(), self.maybe_typeck_results.unwrap().expr_ty(e)) {
348+
if self.target.ty() != self.maybe_typeck_results.unwrap().expr_ty(e) {
349349
return;
350350
}
351351

clippy_lints/src/index_refutable_slice.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::higher::IfLet;
44
use clippy_utils::ty::is_copy;
55
use clippy_utils::{is_expn_of, is_lint_allowed, meets_msrv, msrvs, path_to_local};
66
use if_chain::if_chain;
7-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
7+
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
88
use rustc_errors::Applicability;
99
use rustc_hir as hir;
1010
use rustc_hir::intravisit::{self, Visitor};
@@ -92,9 +92,9 @@ impl<'tcx> LateLintPass<'tcx> for IndexRefutableSlice {
9292
extract_msrv_attr!(LateContext);
9393
}
9494

95-
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxHashMap<hir::HirId, SliceLintInformation> {
95+
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<hir::HirId, SliceLintInformation> {
9696
let mut removed_pat: FxHashSet<hir::HirId> = FxHashSet::default();
97-
let mut slices: FxHashMap<hir::HirId, SliceLintInformation> = FxHashMap::default();
97+
let mut slices: FxIndexMap<hir::HirId, SliceLintInformation> = FxIndexMap::default();
9898
pat.walk_always(|pat| {
9999
if let hir::PatKind::Binding(binding, value_hir_id, ident, sub_pat) = pat.kind {
100100
// We'll just ignore mut and ref mut for simplicity sake right now
@@ -208,10 +208,10 @@ impl SliceLintInformation {
208208

209209
fn filter_lintable_slices<'a, 'tcx>(
210210
cx: &'a LateContext<'tcx>,
211-
slice_lint_info: FxHashMap<hir::HirId, SliceLintInformation>,
211+
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
212212
max_suggested_slice: u64,
213213
scope: &'tcx hir::Expr<'tcx>,
214-
) -> FxHashMap<hir::HirId, SliceLintInformation> {
214+
) -> FxIndexMap<hir::HirId, SliceLintInformation> {
215215
let mut visitor = SliceIndexLintingVisitor {
216216
cx,
217217
slice_lint_info,
@@ -225,7 +225,7 @@ fn filter_lintable_slices<'a, 'tcx>(
225225

226226
struct SliceIndexLintingVisitor<'a, 'tcx> {
227227
cx: &'a LateContext<'tcx>,
228-
slice_lint_info: FxHashMap<hir::HirId, SliceLintInformation>,
228+
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
229229
max_suggested_slice: u64,
230230
}
231231

clippy_lints/src/len_zero.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir::{
1010
ItemKind, Mutability, Node, TraitItemRef, TyKind,
1111
};
1212
use rustc_lint::{LateContext, LateLintPass};
13-
use rustc_middle::ty::{self, AssocKind, FnSig, Ty, TyS};
13+
use rustc_middle::ty::{self, AssocKind, FnSig, Ty};
1414
use rustc_session::{declare_lint_pass, declare_tool_lint};
1515
use rustc_span::{
1616
source_map::{Span, Spanned, Symbol},
@@ -265,7 +265,7 @@ impl LenOutput<'_> {
265265
(_, &ty::Bool) => true,
266266
(Self::Option(id), &ty::Adt(adt, subs)) if id == adt.did => subs.type_at(0).is_bool(),
267267
(Self::Result(id, err_ty), &ty::Adt(adt, subs)) if id == adt.did => {
268-
subs.type_at(0).is_bool() && TyS::same_type(subs.type_at(1), err_ty)
268+
subs.type_at(0).is_bool() && subs.type_at(1) == err_ty
269269
},
270270
_ => false,
271271
}

clippy_lints/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#![warn(rust_2018_idioms, unused_lifetimes)]
1919
// warn on rustc internal lints
2020
#![warn(rustc::internal)]
21+
// Disable this rustc lint for now, as it was also done in rustc
22+
#![allow(rustc::potential_query_instability)]
2123

2224
// FIXME: switch to something more ergonomic here, once available.
2325
// (Currently there is no way to opt into sysroot crates without `extern crate`.)

clippy_lints/src/loops/explicit_into_iter_loop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ use clippy_utils::source::snippet_with_applicability;
55
use rustc_errors::Applicability;
66
use rustc_hir::Expr;
77
use rustc_lint::LateContext;
8-
use rustc_middle::ty::TyS;
98
use rustc_span::symbol::sym;
109

1110
pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr<'_>) {
1211
let self_ty = cx.typeck_results().expr_ty(self_arg);
1312
let self_ty_adjusted = cx.typeck_results().expr_ty_adjusted(self_arg);
14-
if !(TyS::same_type(self_ty, self_ty_adjusted) && is_trait_method(cx, call_expr, sym::IntoIterator)) {
13+
if !(self_ty == self_ty_adjusted && is_trait_method(cx, call_expr, sym::IntoIterator)) {
1514
return;
1615
}
1716

clippy_lints/src/loops/explicit_iter_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::ty::is_type_diagnostic_item;
66
use rustc_errors::Applicability;
77
use rustc_hir::{Expr, Mutability};
88
use rustc_lint::LateContext;
9-
use rustc_middle::ty::{self, Ty, TyS};
9+
use rustc_middle::ty::{self, Ty};
1010
use rustc_span::sym;
1111

1212
pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, arg: &Expr<'_>, method_name: &str) {
@@ -22,7 +22,7 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, arg: &Expr<'_>, m
2222
mutbl: Mutability::Not,
2323
},
2424
);
25-
TyS::same_type(receiver_ty_adjusted, ref_receiver_ty)
25+
receiver_ty_adjusted == ref_receiver_ty
2626
},
2727
_ => false,
2828
};

clippy_lints/src/matches/match_same_arms.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use clippy_utils::source::snippet;
33
use clippy_utils::{path_to_local, search_same, SpanlessEq, SpanlessHash};
44
use rustc_hir::{Arm, Expr, ExprKind, HirId, HirIdMap, HirIdSet, MatchSource, Pat, PatKind};
55
use rustc_lint::LateContext;
6-
use rustc_middle::ty::TyS;
76
use std::collections::hash_map::Entry;
87

98
use super::MATCH_SAME_ARMS;
@@ -32,7 +31,7 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) {
3231
};
3332
// the names technically don't have to match; this makes the lint more conservative
3433
if cx.tcx.hir().name(a_id) == cx.tcx.hir().name(b_id);
35-
if TyS::same_type(cx.typeck_results().expr_ty(a), cx.typeck_results().expr_ty(b));
34+
if cx.typeck_results().expr_ty(a) == cx.typeck_results().expr_ty(b);
3635
if pat_contains_local(lhs.pat, a_id);
3736
if pat_contains_local(rhs.pat, b_id);
3837
then {

clippy_lints/src/methods/filter_map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_hir as hir;
88
use rustc_hir::def::Res;
99
use rustc_hir::{Expr, ExprKind, PatKind, QPath, UnOp};
1010
use rustc_lint::LateContext;
11-
use rustc_middle::ty::TyS;
1211
use rustc_span::source_map::Span;
1312
use rustc_span::symbol::{sym, Symbol};
1413
use std::borrow::Cow;
@@ -149,7 +148,7 @@ pub(super) fn check<'tcx>(
149148
if_chain! {
150149
if path_to_local_id(a_path, filter_param_id);
151150
if path_to_local_id(b, map_param_id);
152-
if TyS::same_type(cx.typeck_results().expr_ty_adjusted(a), cx.typeck_results().expr_ty_adjusted(b));
151+
if cx.typeck_results().expr_ty_adjusted(a) == cx.typeck_results().expr_ty_adjusted(b);
153152
then {
154153
return true;
155154
}

clippy_lints/src/methods/implicit_clone.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir as hir;
88
use rustc_lint::LateContext;
9-
use rustc_middle::ty::TyS;
109
use rustc_span::sym;
1110

1211
use super::IMPLICIT_CLONE;
@@ -19,7 +18,7 @@ pub fn check(cx: &LateContext<'_>, method_name: &str, expr: &hir::Expr<'_>, recv
1918
let input_type = cx.typeck_results().expr_ty(recv);
2019
let (input_type, ref_count) = peel_mid_ty_refs(input_type);
2120
if let Some(ty_name) = input_type.ty_adt_def().map(|adt_def| cx.tcx.item_name(adt_def.did));
22-
if TyS::same_type(return_type, input_type);
21+
if return_type == input_type;
2322
then {
2423
let mut app = Applicability::MachineApplicable;
2524
let recv_snip = snippet_with_context(cx, recv.span, expr.span.ctxt(), "..", &mut app).0;

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ use rustc_hir::def::Res;
7878
use rustc_hir::{Expr, ExprKind, PrimTy, QPath, TraitItem, TraitItemKind};
7979
use rustc_lint::{LateContext, LateLintPass, LintContext};
8080
use rustc_middle::lint::in_external_macro;
81-
use rustc_middle::ty::{self, TraitRef, Ty, TyS};
81+
use rustc_middle::ty::{self, TraitRef, Ty};
8282
use rustc_semver::RustcVersion;
8383
use rustc_session::{declare_tool_lint, impl_lint_pass};
8484
use rustc_span::{sym, Span};
@@ -2198,7 +2198,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
21982198
}
21992199
}
22002200

2201-
if name == "new" && !TyS::same_type(ret_ty, self_ty) {
2201+
if name == "new" && ret_ty != self_ty {
22022202
span_lint(
22032203
cx,
22042204
NEW_RET_NO_SELF,

clippy_lints/src/methods/unnecessary_filter_map.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir as hir;
55
use rustc_hir::intravisit::{walk_expr, Visitor};
66
use rustc_hir::LangItem::{OptionNone, OptionSome};
77
use rustc_lint::LateContext;
8-
use rustc_middle::ty::{self, TyS};
8+
use rustc_middle::ty;
99
use rustc_span::sym;
1010

1111
use super::UNNECESSARY_FILTER_MAP;
@@ -33,9 +33,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Expr<
3333
} else if !found_mapping && !mutates_arg {
3434
let in_ty = cx.typeck_results().node_type(body.params[0].hir_id);
3535
match cx.typeck_results().expr_ty(&body.value).kind() {
36-
ty::Adt(adt, subst)
37-
if cx.tcx.is_diagnostic_item(sym::Option, adt.did) && TyS::same_type(in_ty, subst.type_at(0)) =>
38-
{
36+
ty::Adt(adt, subst) if cx.tcx.is_diagnostic_item(sym::Option, adt.did) && in_ty == subst.type_at(0) => {
3937
"filter"
4038
},
4139
_ => return,

clippy_lints/src/needless_option_as_deref.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use clippy_utils::ty::is_type_diagnostic_item;
44
use rustc_errors::Applicability;
55
use rustc_hir::{Expr, ExprKind};
66
use rustc_lint::{LateContext, LateLintPass};
7-
use rustc_middle::ty::TyS;
87
use rustc_session::{declare_lint_pass, declare_tool_lint};
98
use rustc_span::symbol::sym;
109

@@ -49,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for OptionNeedlessDeref {
4948
if let ExprKind::MethodCall(path, [sub_expr], _) = expr.kind;
5049
let symbol = path.ident.as_str();
5150
if symbol == "as_deref" || symbol == "as_deref_mut";
52-
if TyS::same_type( outer_ty, typeck.expr_ty(sub_expr) );
51+
if outer_ty == typeck.expr_ty(sub_expr);
5352
then{
5453
span_lint_and_sugg(
5554
cx,

clippy_lints/src/needless_question_mark.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_errors::Applicability;
66
use rustc_hir::LangItem::{OptionSome, ResultOk};
77
use rustc_hir::{AsyncGeneratorKind, Block, Body, Expr, ExprKind, GeneratorKind, LangItem, MatchSource, QPath};
88
use rustc_lint::{LateContext, LateLintPass};
9-
use rustc_middle::ty::TyS;
109
use rustc_session::{declare_lint_pass, declare_tool_lint};
1110

1211
declare_clippy_lint! {
@@ -128,7 +127,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
128127
if expr.span.ctxt() == inner_expr.span.ctxt();
129128
let expr_ty = cx.typeck_results().expr_ty(expr);
130129
let inner_ty = cx.typeck_results().expr_ty(inner_expr);
131-
if TyS::same_type(expr_ty, inner_ty);
130+
if expr_ty == inner_ty;
132131
then {
133132
span_lint_and_sugg(
134133
cx,

clippy_lints/src/new_without_default.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_hir as hir;
88
use rustc_hir::HirIdSet;
99
use rustc_lint::{LateContext, LateLintPass, LintContext};
1010
use rustc_middle::lint::in_external_macro;
11-
use rustc_middle::ty::TyS;
1211
use rustc_session::{declare_tool_lint, impl_lint_pass};
1312
use rustc_span::sym;
1413

@@ -103,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
103102
if cx.access_levels.is_reachable(impl_item.def_id);
104103
let self_def_id = cx.tcx.hir().get_parent_item(id);
105104
let self_ty = cx.tcx.type_of(self_def_id);
106-
if TyS::same_type(self_ty, return_ty(cx, id));
105+
if self_ty == return_ty(cx, id);
107106
if let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default);
108107
then {
109108
if self.impling_types.is_none() {

clippy_lints/src/redundant_slicing.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability};
88
use rustc_lint::{LateContext, LateLintPass};
9-
use rustc_middle::ty::TyS;
109
use rustc_session::{declare_lint_pass, declare_tool_lint};
1110

1211
declare_clippy_lint! {
@@ -54,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
5453
if addressee.span.ctxt() == ctxt;
5554
if let ExprKind::Index(indexed, range) = addressee.kind;
5655
if is_type_lang_item(cx, cx.typeck_results().expr_ty_adjusted(range), LangItem::RangeFull);
57-
if TyS::same_type(cx.typeck_results().expr_ty(expr), cx.typeck_results().expr_ty(indexed));
56+
if cx.typeck_results().expr_ty(expr) == cx.typeck_results().expr_ty(indexed);
5857
then {
5958
let mut app = Applicability::MachineApplicable;
6059
let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0;

clippy_lints/src/size_of_in_element_count.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use if_chain::if_chain;
77
use rustc_hir::BinOpKind;
88
use rustc_hir::{Expr, ExprKind};
99
use rustc_lint::{LateContext, LateLintPass};
10-
use rustc_middle::ty::{self, Ty, TyS, TypeAndMut};
10+
use rustc_middle::ty::{self, Ty, TypeAndMut};
1111
use rustc_session::{declare_lint_pass, declare_tool_lint};
1212

1313
declare_clippy_lint! {
@@ -138,7 +138,7 @@ impl<'tcx> LateLintPass<'tcx> for SizeOfInElementCount {
138138
// Find a size_of call in the count parameter expression and
139139
// check that it's the same type
140140
if let Some(ty_used_for_size_of) = get_size_of_ty(cx, count_expr, false);
141-
if TyS::same_type(pointee_ty, ty_used_for_size_of);
141+
if pointee_ty == ty_used_for_size_of;
142142
then {
143143
span_lint_and_help(
144144
cx,

0 commit comments

Comments
 (0)