Skip to content

Commit fae2d65

Browse files
committed
Auto merge of #11048 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 9020937 + 3d25840 commit fae2d65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+241
-550
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5267,6 +5267,7 @@ Released 2018-09-13
52675267
[`unchecked_duration_subtraction`]: https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction
52685268
[`undocumented_unsafe_blocks`]: https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks
52695269
[`undropped_manually_drops`]: https://rust-lang.github.io/rust-clippy/master/index.html#undropped_manually_drops
5270+
[`undropped_manually_drops`]: https://rust-lang.github.io/rust-clippy/master/index.html#undropped_manually_drops
52705271
[`unicode_not_nfc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unicode_not_nfc
52715272
[`unimplemented`]: https://rust-lang.github.io/rust-clippy/master/index.html#unimplemented
52725273
[`uninit_assumed_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#uninit_assumed_init

clippy_lints/src/casts/cast_possible_wrap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
2424
// 1. unsigned to signed
2525
// and
2626
// 2. either:
27+
//
2728
// 2a. between two types of constant size that are always the same size
2829
// 2b. between one target-dependent size and one constant size integer,
2930
// and the constant integer is in the allowed set of target dependent sizes

clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
492492
crate::operators::ARITHMETIC_SIDE_EFFECTS_INFO,
493493
crate::operators::ASSIGN_OP_PATTERN_INFO,
494494
crate::operators::BAD_BIT_MASK_INFO,
495-
crate::operators::CMP_NAN_INFO,
496495
crate::operators::CMP_OWNED_INFO,
497496
crate::operators::DOUBLE_COMPARISONS_INFO,
498497
crate::operators::DURATION_SUBSEC_INFO,

clippy_lints/src/dereference.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use rustc_lint::{LateContext, LateLintPass};
2626
use rustc_middle::mir::{Rvalue, StatementKind};
2727
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
2828
use rustc_middle::ty::{
29-
self, Binder, BoundVariableKind, Clause, EarlyBinder, FnSig, GenericArgKind, List, ParamEnv, ParamTy,
30-
PredicateKind, ProjectionPredicate, Ty, TyCtxt, TypeVisitableExt, TypeckResults,
29+
self, Binder, BoundVariableKind, ClauseKind, EarlyBinder, FnSig, GenericArgKind, List, ParamEnv, ParamTy,
30+
ProjectionPredicate, Ty, TyCtxt, TypeVisitableExt, TypeckResults,
3131
};
3232
use rustc_session::{declare_tool_lint, impl_lint_pass};
3333
use rustc_span::{symbol::sym, Span, Symbol};
@@ -357,15 +357,17 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
357357
// start auto-deref.
358358
// 4. If the chain of non-user-defined derefs ends with a mutable re-borrow, and re-borrow
359359
// adjustments will not be inserted automatically, then leave one further reference to avoid
360-
// moving a mutable borrow.
361-
// e.g.
362-
// fn foo<T>(x: &mut Option<&mut T>, y: &mut T) {
363-
// let x = match x {
364-
// // Removing the borrow will cause `x` to be moved
365-
// Some(x) => &mut *x,
366-
// None => y
367-
// };
368-
// }
360+
// moving a mutable borrow. e.g.
361+
//
362+
// ```rust
363+
// fn foo<T>(x: &mut Option<&mut T>, y: &mut T) {
364+
// let x = match x {
365+
// // Removing the borrow will cause `x` to be moved
366+
// Some(x) => &mut *x,
367+
// None => y
368+
// };
369+
// }
370+
// ```
369371
let deref_msg =
370372
"this expression creates a reference which is immediately dereferenced by the compiler";
371373
let borrow_msg = "this expression borrows a value the compiler would automatically borrow";
@@ -1135,7 +1137,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
11351137
let projection_predicates = predicates
11361138
.iter()
11371139
.filter_map(|predicate| {
1138-
if let PredicateKind::Clause(Clause::Projection(projection_predicate)) = predicate.kind().skip_binder() {
1140+
if let ClauseKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
11391141
Some(projection_predicate)
11401142
} else {
11411143
None
@@ -1149,7 +1151,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
11491151
if predicates
11501152
.iter()
11511153
.filter_map(|predicate| {
1152-
if let PredicateKind::Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder()
1154+
if let ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder()
11531155
&& trait_predicate.trait_ref.self_ty() == param_ty.to_ty(cx.tcx)
11541156
{
11551157
Some(trait_predicate.trait_ref.def_id)
@@ -1211,7 +1213,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
12111213
}
12121214

12131215
predicates.iter().all(|predicate| {
1214-
if let PredicateKind::Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder()
1216+
if let ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder()
12151217
&& cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
12161218
&& let ty::Param(param_ty) = trait_predicate.self_ty().kind()
12171219
&& let GenericArgKind::Type(ty) = substs_with_referent_ty[param_ty.index as usize].unpack()
@@ -1426,6 +1428,7 @@ fn ty_auto_deref_stability<'tcx>(
14261428
continue;
14271429
},
14281430
ty::Param(_) => TyPosition::new_deref_stable_for_result(precedence, ty),
1431+
ty::Alias(ty::Weak, _) => unreachable!("should have been normalized away above"),
14291432
ty::Alias(ty::Inherent, _) => unreachable!("inherent projection should have been normalized away above"),
14301433
ty::Alias(ty::Projection, _) if ty.has_non_region_param() => {
14311434
TyPosition::new_deref_stable_for_result(precedence, ty)

clippy_lints/src/derive.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_lint::{LateContext, LateLintPass};
1414
use rustc_middle::hir::nested_filter;
1515
use rustc_middle::traits::Reveal;
1616
use rustc_middle::ty::{
17-
self, Binder, BoundConstness, Clause, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, PredicateKind,
17+
self, BoundConstness, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, ToPredicate,
1818
TraitPredicate, Ty, TyCtxt,
1919
};
2020
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -503,7 +503,7 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
503503

504504
let ty_predicates = tcx.predicates_of(did).predicates;
505505
for (p, _) in ty_predicates {
506-
if let PredicateKind::Clause(Clause::Trait(p)) = p.kind().skip_binder()
506+
if let ClauseKind::Trait(p) = p.kind().skip_binder()
507507
&& p.trait_ref.def_id == eq_trait_id
508508
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
509509
&& p.constness == BoundConstness::NotConst
@@ -514,13 +514,14 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
514514
}
515515

516516
ParamEnv::new(
517-
tcx.mk_predicates_from_iter(ty_predicates.iter().map(|&(p, _)| p).chain(
517+
tcx.mk_clauses_from_iter(ty_predicates.iter().map(|&(p, _)| p).chain(
518518
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
519-
tcx.mk_predicate(Binder::dummy(PredicateKind::Clause(Clause::Trait(TraitPredicate {
519+
ClauseKind::Trait(TraitPredicate {
520520
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
521521
constness: BoundConstness::NotConst,
522522
polarity: ImplPolarity::Positive,
523-
}))))
523+
})
524+
.to_predicate(tcx)
524525
}),
525526
)),
526527
Reveal::UserFacing,

clippy_lints/src/future_not_send.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_hir::intravisit::FnKind;
44
use rustc_hir::{Body, FnDecl};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::{LateContext, LateLintPass};
7-
use rustc_middle::ty::{self, AliasTy, Clause, PredicateKind};
7+
use rustc_middle::ty::{self, AliasTy, ClauseKind, PredicateKind};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::def_id::LocalDefId;
1010
use rustc_span::{sym, Span};
@@ -67,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6767
let preds = cx.tcx.explicit_item_bounds(def_id);
6868
let mut is_future = false;
6969
for (p, _span) in preds.subst_iter_copied(cx.tcx, substs) {
70-
if let Some(trait_pred) = p.to_opt_poly_trait_pred() {
70+
if let Some(trait_pred) = p.as_trait_clause() {
7171
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
7272
is_future = true;
7373
break;
@@ -93,7 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
9393
infcx
9494
.err_ctxt()
9595
.maybe_note_obligation_cause_for_async_await(db, &obligation);
96-
if let PredicateKind::Clause(Clause::Trait(trait_pred)) =
96+
if let PredicateKind::Clause(ClauseKind::Trait(trait_pred)) =
9797
obligation.predicate.kind().skip_binder()
9898
{
9999
db.note(format!(

clippy_lints/src/loops/never_loop.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ fn never_loop_expr<'tcx>(
223223
NeverLoopResult::AlwaysBreak,
224224
)
225225
}),
226+
ExprKind::Become(e) => combine_seq(
227+
never_loop_expr(cx, e, ignore_ids, main_loop_id),
228+
NeverLoopResult::AlwaysBreak,
229+
),
226230
ExprKind::InlineAsm(asm) => asm
227231
.operands
228232
.iter()

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
329329
ExprKind::Field(..) |
330330
ExprKind::Index(..) |
331331
ExprKind::Ret(..) |
332+
ExprKind::Become(..) |
332333
ExprKind::Repeat(..) |
333334
ExprKind::Yield(..) => walk_expr(self, ex),
334335
ExprKind::AddrOf(_, _, _) |

clippy_lints/src/methods/needless_collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_hir::{
1616
};
1717
use rustc_lint::LateContext;
1818
use rustc_middle::hir::nested_filter;
19-
use rustc_middle::ty::{self, AssocKind, Clause, EarlyBinder, GenericArg, GenericArgKind, PredicateKind, Ty};
19+
use rustc_middle::ty::{self, AssocKind, ClauseKind, EarlyBinder, GenericArg, GenericArgKind, Ty};
2020
use rustc_span::symbol::Ident;
2121
use rustc_span::{sym, Span, Symbol};
2222

@@ -175,7 +175,7 @@ fn check_collect_into_intoiterator<'tcx>(
175175
.caller_bounds()
176176
.into_iter()
177177
.filter_map(|p| {
178-
if let PredicateKind::Clause(Clause::Trait(t)) = p.kind().skip_binder()
178+
if let ClauseKind::Trait(t) = p.kind().skip_binder()
179179
&& cx.tcx.is_diagnostic_item(sym::IntoIterator,t.trait_ref.def_id) {
180180
Some(t.self_ty())
181181
} else {

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_lint::LateContext;
1414
use rustc_middle::mir::Mutability;
1515
use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref};
1616
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
17-
use rustc_middle::ty::{self, Clause, EarlyBinder, ParamTy, PredicateKind, ProjectionPredicate, TraitPredicate, Ty};
17+
use rustc_middle::ty::{self, ClauseKind, EarlyBinder, ParamTy, ProjectionPredicate, TraitPredicate, Ty};
1818
use rustc_span::{sym, Symbol};
1919
use rustc_trait_selection::traits::{query::evaluate_obligation::InferCtxtExt as _, Obligation, ObligationCause};
2020

@@ -350,12 +350,12 @@ fn get_input_traits_and_projections<'tcx>(
350350
let mut projection_predicates = Vec::new();
351351
for predicate in cx.tcx.param_env(callee_def_id).caller_bounds() {
352352
match predicate.kind().skip_binder() {
353-
PredicateKind::Clause(Clause::Trait(trait_predicate)) => {
353+
ClauseKind::Trait(trait_predicate) => {
354354
if trait_predicate.trait_ref.self_ty() == input {
355355
trait_predicates.push(trait_predicate);
356356
}
357357
},
358-
PredicateKind::Clause(Clause::Projection(projection_predicate)) => {
358+
ClauseKind::Projection(projection_predicate) => {
359359
if projection_predicate.projection_ty.self_ty() == input {
360360
projection_predicates.push(projection_predicate);
361361
}
@@ -412,7 +412,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
412412

413413
let mut trait_predicates = cx.tcx.param_env(callee_def_id)
414414
.caller_bounds().iter().filter(|predicate| {
415-
if let PredicateKind::Clause(Clause::Trait(trait_predicate))
415+
if let ClauseKind::Trait(trait_predicate)
416416
= predicate.kind().skip_binder()
417417
&& trait_predicate.trait_ref.self_ty() == *param_ty
418418
{

clippy_lints/src/missing_inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
105105
match tit_.kind {
106106
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
107107
hir::TraitItemKind::Fn(..) => {
108-
if cx.tcx.impl_defaultness(tit.id.owner_id).has_value() {
108+
if cx.tcx.defaultness(tit.id.owner_id).has_value() {
109109
// trait method with default body needs inline in case
110110
// an impl is not provided
111111
let desc = "a default trait method";

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
125125
.filter_map(|pred| {
126126
// Note that we do not want to deal with qualified predicates here.
127127
match pred.kind().no_bound_vars() {
128-
Some(ty::PredicateKind::Clause(ty::Clause::Trait(pred))) if pred.def_id() != sized_trait => {
129-
Some(pred)
130-
},
128+
Some(ty::ClauseKind::Trait(pred)) if pred.def_id() != sized_trait => Some(pred),
131129
_ => None,
132130
}
133131
})

clippy_lints/src/non_copy_const.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ fn is_value_unfrozen_raw<'tcx>(
166166
// have a value that is a frozen variant with a generic param (an example is
167167
// `declare_interior_mutable_const::enums::BothOfCellAndGeneric::GENERIC_VARIANT`).
168168
// However, it prevents a number of false negatives that is, I think, important:
169-
// 1. assoc consts in trait defs referring to consts of themselves
170-
// (an example is `declare_interior_mutable_const::traits::ConcreteTypes::ANOTHER_ATOMIC`).
171-
// 2. a path expr referring to assoc consts whose type is doesn't have
172-
// any frozen variants in trait defs (i.e. without substitute for `Self`).
173-
// (e.g. borrowing `borrow_interior_mutable_const::trait::ConcreteTypes::ATOMIC`)
174-
// 3. similar to the false positive above;
175-
// but the value is an unfrozen variant, or the type has no enums. (An example is
176-
// `declare_interior_mutable_const::enums::BothOfCellAndGeneric::UNFROZEN_VARIANT`
177-
// and `declare_interior_mutable_const::enums::BothOfCellAndGeneric::NO_ENUM`).
169+
// 1. assoc consts in trait defs referring to consts of themselves (an example is
170+
// `declare_interior_mutable_const::traits::ConcreteTypes::ANOTHER_ATOMIC`).
171+
// 2. a path expr referring to assoc consts whose type is doesn't have any frozen variants in trait
172+
// defs (i.e. without substitute for `Self`). (e.g. borrowing
173+
// `borrow_interior_mutable_const::trait::ConcreteTypes::ATOMIC`)
174+
// 3. similar to the false positive above; but the value is an unfrozen variant, or the type has no
175+
// enums. (An example is
176+
// `declare_interior_mutable_const::enums::BothOfCellAndGeneric::UNFROZEN_VARIANT` and
177+
// `declare_interior_mutable_const::enums::BothOfCellAndGeneric::NO_ENUM`).
178178
// One might be able to prevent these FNs correctly, and replace this with `false`;
179179
// e.g. implementing `has_frozen_variant` described above, and not running this function
180180
// when the type doesn't have any frozen variants would be the 'correct' way for the 2nd

clippy_lints/src/operators/cmp_nan.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

clippy_lints/src/operators/mod.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
mod absurd_extreme_comparisons;
22
mod assign_op_pattern;
33
mod bit_mask;
4-
mod cmp_nan;
54
mod cmp_owned;
65
mod double_comparison;
76
mod duration_subsec;
@@ -485,31 +484,6 @@ declare_clippy_lint! {
485484
"integer division may cause loss of precision"
486485
}
487486

488-
declare_clippy_lint! {
489-
/// ### What it does
490-
/// Checks for comparisons to NaN.
491-
///
492-
/// ### Why is this bad?
493-
/// NaN does not compare meaningfully to anything – not
494-
/// even itself – so those comparisons are simply wrong.
495-
///
496-
/// ### Example
497-
/// ```rust
498-
/// # let x = 1.0;
499-
/// if x == f32::NAN { }
500-
/// ```
501-
///
502-
/// Use instead:
503-
/// ```rust
504-
/// # let x = 1.0f32;
505-
/// if x.is_nan() { }
506-
/// ```
507-
#[clippy::version = "pre 1.29.0"]
508-
pub CMP_NAN,
509-
correctness,
510-
"comparisons to `NAN`, which will always return false, probably not intended"
511-
}
512-
513487
declare_clippy_lint! {
514488
/// ### What it does
515489
/// Checks for conversions to owned values just for the sake
@@ -775,7 +749,6 @@ impl_lint_pass!(Operators => [
775749
FLOAT_EQUALITY_WITHOUT_ABS,
776750
IDENTITY_OP,
777751
INTEGER_DIVISION,
778-
CMP_NAN,
779752
CMP_OWNED,
780753
FLOAT_CMP,
781754
FLOAT_CMP_CONST,
@@ -816,7 +789,6 @@ impl<'tcx> LateLintPass<'tcx> for Operators {
816789
duration_subsec::check(cx, e, op.node, lhs, rhs);
817790
float_equality_without_abs::check(cx, e, op.node, lhs, rhs);
818791
integer_division::check(cx, e, op.node, lhs, rhs);
819-
cmp_nan::check(cx, e, op.node, lhs, rhs);
820792
cmp_owned::check(cx, op.node, lhs, rhs);
821793
float_cmp::check(cx, e, op.node, lhs, rhs);
822794
modulo_one::check(cx, e, op.node, rhs);

clippy_lints/src/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_infer::infer::TyCtxtInferExt;
2121
use rustc_infer::traits::{Obligation, ObligationCause};
2222
use rustc_lint::{LateContext, LateLintPass};
2323
use rustc_middle::hir::nested_filter;
24-
use rustc_middle::ty::{self, Binder, Clause, ExistentialPredicate, List, PredicateKind, Ty};
24+
use rustc_middle::ty::{self, Binder, ClauseKind, ExistentialPredicate, List, PredicateKind, Ty};
2525
use rustc_session::{declare_lint_pass, declare_tool_lint};
2626
use rustc_span::source_map::Span;
2727
use rustc_span::sym;
@@ -732,7 +732,7 @@ fn matches_preds<'tcx>(
732732
ObligationCause::dummy(),
733733
cx.param_env,
734734
cx.tcx
735-
.mk_predicate(Binder::dummy(PredicateKind::Clause(Clause::Projection(
735+
.mk_predicate(Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(
736736
p.with_self_ty(cx.tcx, ty),
737737
)))),
738738
)),

0 commit comments

Comments
 (0)