Skip to content

Commit 30448e8

Browse files
committed
Auto merge of rust-lang#10871 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 50ab3ce + 84f8ce8 commit 30448e8

37 files changed

+137
-355
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.71"
3+
version = "0.1.72"
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.71"
3+
version = "0.1.72"
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/casts/cast_ref_to_mut.rs

-26
This file was deleted.

clippy_lints/src/casts/mod.rs

-38
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ mod cast_possible_truncation;
99
mod cast_possible_wrap;
1010
mod cast_precision_loss;
1111
mod cast_ptr_alignment;
12-
mod cast_ref_to_mut;
1312
mod cast_sign_loss;
1413
mod cast_slice_different_sizes;
1514
mod cast_slice_from_raw_parts;
@@ -331,41 +330,6 @@ declare_clippy_lint! {
331330
"casting a function pointer to any integer type"
332331
}
333332

334-
declare_clippy_lint! {
335-
/// ### What it does
336-
/// Checks for casts of `&T` to `&mut T` anywhere in the code.
337-
///
338-
/// ### Why is this bad?
339-
/// It’s basically guaranteed to be undefined behavior.
340-
/// `UnsafeCell` is the only way to obtain aliasable data that is considered
341-
/// mutable.
342-
///
343-
/// ### Example
344-
/// ```rust,ignore
345-
/// fn x(r: &i32) {
346-
/// unsafe {
347-
/// *(r as *const _ as *mut _) += 1;
348-
/// }
349-
/// }
350-
/// ```
351-
///
352-
/// Instead consider using interior mutability types.
353-
///
354-
/// ```rust
355-
/// use std::cell::UnsafeCell;
356-
///
357-
/// fn x(r: &UnsafeCell<i32>) {
358-
/// unsafe {
359-
/// *r.get() += 1;
360-
/// }
361-
/// }
362-
/// ```
363-
#[clippy::version = "1.33.0"]
364-
pub CAST_REF_TO_MUT,
365-
correctness,
366-
"a cast of reference to a mutable pointer"
367-
}
368-
369333
declare_clippy_lint! {
370334
/// ### What it does
371335
/// Checks for expressions where a character literal is cast
@@ -709,7 +673,6 @@ impl_lint_pass!(Casts => [
709673
CAST_POSSIBLE_TRUNCATION,
710674
CAST_POSSIBLE_WRAP,
711675
CAST_LOSSLESS,
712-
CAST_REF_TO_MUT,
713676
CAST_PTR_ALIGNMENT,
714677
CAST_SLICE_DIFFERENT_SIZES,
715678
UNNECESSARY_CAST,
@@ -778,7 +741,6 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
778741
}
779742
}
780743

781-
cast_ref_to_mut::check(cx, expr);
782744
cast_ptr_alignment::check(cx, expr);
783745
char_lit_as_u8::check(cx, expr);
784746
ptr_as_ptr::check(cx, expr, &self.msrv);

clippy_lints/src/declared_lints.rs

-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
8181
crate::casts::CAST_POSSIBLE_WRAP_INFO,
8282
crate::casts::CAST_PRECISION_LOSS_INFO,
8383
crate::casts::CAST_PTR_ALIGNMENT_INFO,
84-
crate::casts::CAST_REF_TO_MUT_INFO,
8584
crate::casts::CAST_SIGN_LOSS_INFO,
8685
crate::casts::CAST_SLICE_DIFFERENT_SIZES_INFO,
8786
crate::casts::CAST_SLICE_FROM_RAW_PARTS_INFO,
@@ -213,7 +212,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
213212
crate::instant_subtraction::UNCHECKED_DURATION_SUBTRACTION_INFO,
214213
crate::int_plus_one::INT_PLUS_ONE_INFO,
215214
crate::invalid_upcast_comparisons::INVALID_UPCAST_COMPARISONS_INFO,
216-
crate::invalid_utf8_in_unchecked::INVALID_UTF8_IN_UNCHECKED_INFO,
217215
crate::items_after_statements::ITEMS_AFTER_STATEMENTS_INFO,
218216
crate::items_after_test_module::ITEMS_AFTER_TEST_MODULE_INFO,
219217
crate::iter_not_returning_iterator::ITER_NOT_RETURNING_ITERATOR_INFO,

clippy_lints/src/dereference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
12191219
return false;
12201220
}
12211221

1222-
let predicate = EarlyBinder(predicate).subst(cx.tcx, &substs_with_referent_ty);
1222+
let predicate = EarlyBinder::bind(predicate).subst(cx.tcx, &substs_with_referent_ty);
12231223
let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate);
12241224
let infcx = cx.tcx.infer_ctxt().build();
12251225
infcx.predicate_must_hold_modulo_regions(&obligation)

clippy_lints/src/drop_forget_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
9898
let is_copy = is_copy(cx, arg_ty);
9999
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
100100
let (lint, msg) = match fn_name {
101-
// early return for uplifted lints: drop_ref, drop_copy, forget_ref, forget_copy
101+
// early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, forgetting_copy_types
102102
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
103103
sym::mem_forget if arg_ty.is_ref() => return,
104104
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return,

clippy_lints/src/eta_reduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ fn get_ufcs_type_name<'tcx>(cx: &LateContext<'tcx>, method_def_id: DefId, substs
243243
| ty::Ref(..)
244244
| ty::Slice(_)
245245
| ty::Tuple(_) => {
246-
format!("<{}>", EarlyBinder(ty).subst(cx.tcx, substs))
246+
format!("<{}>", EarlyBinder::bind(ty).subst(cx.tcx, substs))
247247
},
248248
_ => ty.to_string(),
249249
}

clippy_lints/src/invalid_utf8_in_unchecked.rs

-74
This file was deleted.

clippy_lints/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ mod inline_fn_without_body;
157157
mod instant_subtraction;
158158
mod int_plus_one;
159159
mod invalid_upcast_comparisons;
160-
mod invalid_utf8_in_unchecked;
161160
mod items_after_statements;
162161
mod items_after_test_module;
163162
mod iter_not_returning_iterator;
@@ -952,7 +951,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
952951
store.register_late_pass(move |_| Box::new(manual_retain::ManualRetain::new(msrv())));
953952
let verbose_bit_mask_threshold = conf.verbose_bit_mask_threshold;
954953
store.register_late_pass(move |_| Box::new(operators::Operators::new(verbose_bit_mask_threshold)));
955-
store.register_late_pass(|_| Box::new(invalid_utf8_in_unchecked::InvalidUtf8InUnchecked));
956954
store.register_late_pass(|_| Box::<std_instead_of_core::StdReexports>::default());
957955
store.register_late_pass(move |_| Box::new(instant_subtraction::InstantSubtraction::new(msrv())));
958956
store.register_late_pass(|_| Box::new(partialeq_to_none::PartialeqToNone));

clippy_lints/src/methods/needless_collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) -
241241
&& let proj_ty = cx.tcx.mk_projection(iter_item.def_id, substs)
242242
&& let Ok(item_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, proj_ty)
243243
{
244-
item_ty == EarlyBinder(search_ty).subst(cx.tcx, cx.typeck_results().node_substs(call_id))
244+
item_ty == EarlyBinder::bind(search_ty).subst(cx.tcx, cx.typeck_results().node_substs(call_id))
245245
} else {
246246
false
247247
}

clippy_lints/src/methods/unnecessary_to_owned.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
428428
}));
429429

430430
if trait_predicates.any(|predicate| {
431-
let predicate = EarlyBinder(predicate).subst(cx.tcx, new_subst);
431+
let predicate = EarlyBinder::bind(predicate).subst(cx.tcx, new_subst);
432432
let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate);
433433
!cx.tcx.infer_ctxt().build().predicate_must_hold_modulo_regions(&obligation)
434434
}) {
@@ -438,7 +438,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
438438
let output_ty = fn_sig.output();
439439
if output_ty.contains(*param_ty) {
440440
if let Ok(new_ty) = cx.tcx.try_subst_and_normalize_erasing_regions(
441-
new_subst, cx.param_env, EarlyBinder(output_ty)) {
441+
new_subst, cx.param_env, EarlyBinder::bind(output_ty)) {
442442
expr = parent_expr;
443443
ty = new_ty;
444444
continue;

clippy_lints/src/missing_const_for_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
154154

155155
if let Err((span, err)) = is_min_const_fn(cx.tcx, mir, &self.msrv) {
156156
if cx.tcx.is_const_fn_raw(def_id.to_def_id()) {
157-
cx.tcx.sess.span_err(span, err.as_ref());
157+
cx.tcx.sess.span_err(span, err);
158158
}
159159
} else {
160160
span_lint(cx, MISSING_CONST_FOR_FN, span, "this could be a `const fn`");

clippy_lints/src/missing_fields_in_debug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug {
217217
&& let body = cx.tcx.hir().body(*body_id)
218218
&& let ExprKind::Block(block, _) = body.value.kind
219219
// inspect `self`
220-
&& let self_ty = cx.tcx.type_of(self_path.res.def_id()).0.peel_refs()
220+
&& let self_ty = cx.tcx.type_of(self_path.res.def_id()).skip_binder().peel_refs()
221221
&& let Some(self_adt) = self_ty.ty_adt_def()
222222
&& let Some(self_def_id) = self_adt.did().as_local()
223223
&& let Some(Node::Item(self_item)) = cx.tcx.hir().find_by_def_id(self_def_id)

clippy_lints/src/multiple_unsafe_ops_per_block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn collect_unsafe_exprs<'tcx>(
138138
.type_dependent_def_id(expr.hir_id)
139139
.map(|def_id| cx.tcx.fn_sig(def_id))
140140
{
141-
if sig.0.unsafety() == Unsafety::Unsafe {
141+
if sig.skip_binder().unsafety() == Unsafety::Unsafe {
142142
unsafe_ops.push(("unsafe method call occurs here", expr.span));
143143
}
144144
}

clippy_lints/src/needless_pass_by_value.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use rustc_span::{sym, Span};
2626
use rustc_target::spec::abi::Abi;
2727
use rustc_trait_selection::traits;
2828
use rustc_trait_selection::traits::misc::type_allowed_to_implement_copy;
29-
use std::borrow::Cow;
3029

3130
declare_clippy_lint! {
3231
/// ### What it does
@@ -240,9 +239,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
240239
snippet_opt(cx, span)
241240
.map_or(
242241
"change the call to".into(),
243-
|x| Cow::from(format!("change `{x}` to")),
244-
)
245-
.as_ref(),
242+
|x| format!("change `{x}` to"),
243+
),
246244
suggestion,
247245
Applicability::Unspecified,
248246
);
@@ -270,9 +268,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
270268
snippet_opt(cx, span)
271269
.map_or(
272270
"change the call to".into(),
273-
|x| Cow::from(format!("change `{x}` to"))
274-
)
275-
.as_ref(),
271+
|x| format!("change `{x}` to")
272+
),
276273
suggestion,
277274
Applicability::Unspecified,
278275
);

clippy_lints/src/renamed_lints.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3131
("clippy::stutter", "clippy::module_name_repetitions"),
3232
("clippy::to_string_in_display", "clippy::recursive_format_impl"),
3333
("clippy::zero_width_space", "clippy::invisible_characters"),
34+
("clippy::cast_ref_to_mut", "cast_ref_to_mut"),
3435
("clippy::clone_double_ref", "suspicious_double_ref_op"),
3536
("clippy::drop_bounds", "drop_bounds"),
36-
("clippy::drop_copy", "drop_copy"),
37-
("clippy::drop_ref", "drop_ref"),
37+
("clippy::drop_copy", "dropping_copy_types"),
38+
("clippy::drop_ref", "dropping_references"),
3839
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
3940
("clippy::for_loop_over_result", "for_loops_over_fallibles"),
4041
("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),
41-
("clippy::forget_copy", "forget_copy"),
42-
("clippy::forget_ref", "forget_ref"),
42+
("clippy::forget_copy", "forgetting_copy_types"),
43+
("clippy::forget_ref", "forgetting_references"),
4344
("clippy::into_iter_on_array", "array_into_iter"),
4445
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
4546
("clippy::invalid_ref", "invalid_value"),
47+
("clippy::invalid_utf8_in_unchecked", "invalid_from_utf8_unchecked"),
4648
("clippy::let_underscore_drop", "let_underscore_drop"),
4749
("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums"),
4850
("clippy::panic_params", "non_fmt_panics"),

clippy_lints/src/strings.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sug
22
use clippy_utils::source::{snippet, snippet_with_applicability};
33
use clippy_utils::ty::is_type_lang_item;
44
use clippy_utils::{get_expr_use_or_unification_node, peel_blocks, SpanlessEq};
5-
use clippy_utils::{get_parent_expr, is_lint_allowed, match_function_call, method_calls, paths};
5+
use clippy_utils::{get_parent_expr, is_lint_allowed, is_path_diagnostic_item, method_calls};
66
use if_chain::if_chain;
77
use rustc_errors::Applicability;
88
use rustc_hir::def_id::DefId;
@@ -255,7 +255,8 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes {
255255

256256
if_chain! {
257257
// Find std::str::converts::from_utf8
258-
if let Some(args) = match_function_call(cx, e, &paths::STR_FROM_UTF8);
258+
if let ExprKind::Call(fun, args) = e.kind;
259+
if is_path_diagnostic_item(cx, fun, sym::str_from_utf8);
259260

260261
// Find string::as_bytes
261262
if let ExprKind::AddrOf(BorrowKind::Ref, _, args) = args[0].kind;

clippy_lints/src/unnecessary_wraps.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
163163
span_lint_and_then(cx, UNNECESSARY_WRAPS, span, lint_msg.as_str(), |diag| {
164164
diag.span_suggestion(
165165
fn_decl.output.span(),
166-
return_type_sugg_msg.as_str(),
166+
return_type_sugg_msg,
167167
return_type_sugg,
168168
Applicability::MaybeIncorrect,
169169
);

clippy_utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_utils"
3-
version = "0.1.71"
3+
version = "0.1.72"
44
edition = "2021"
55
publish = false
66

clippy_utils/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
462462
let substs = if self.substs.is_empty() {
463463
substs
464464
} else {
465-
EarlyBinder(substs).subst(self.lcx.tcx, self.substs)
465+
EarlyBinder::bind(substs).subst(self.lcx.tcx, self.substs)
466466
};
467467

468468
let result = self

0 commit comments

Comments
 (0)