Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 371120b

Browse files
committed
Auto merge of rust-lang#10749 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents d7173e2 + 79656cc commit 371120b

28 files changed

+109
-227
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Current stable, released 2023-04-20
6262

6363
* [`explicit_auto_deref`]: Now considers projections when determining if auto deref is applicable
6464
[#10386](https://github.com/rust-lang/rust-clippy/pull/10386)
65-
* [`manual_let_else`]: Now considers side effects of branches before linting
65+
* [`manual_let_else`]: Now considers side effects of branches before linting
6666
[#10336](https://github.com/rust-lang/rust-clippy/pull/10336)
6767
* [`uninlined_format_args`]: No longer lints for arguments with generic parameters
6868
[#10343](https://github.com/rust-lang/rust-clippy/pull/10343)

clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
315315
crate::methods::CHARS_NEXT_CMP_INFO,
316316
crate::methods::CLEAR_WITH_DRAIN_INFO,
317317
crate::methods::CLONED_INSTEAD_OF_COPIED_INFO,
318-
crate::methods::CLONE_DOUBLE_REF_INFO,
319318
crate::methods::CLONE_ON_COPY_INFO,
320319
crate::methods::CLONE_ON_REF_PTR_INFO,
321320
crate::methods::COLLAPSIBLE_STR_REPLACE_INFO,

clippy_lints/src/default_union_representation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation {
6161
None,
6262
&format!(
6363
"consider annotating `{}` with `#[repr(C)]` to explicitly specify memory layout",
64-
cx.tcx.def_path_str(item.owner_id.to_def_id())
64+
cx.tcx.def_path_str(item.owner_id)
6565
),
6666
);
6767
}

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
517517
tcx.mk_predicates_from_iter(ty_predicates.iter().map(|&(p, _)| p).chain(
518518
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
519519
tcx.mk_predicate(Binder::dummy(PredicateKind::Clause(Clause::Trait(TraitPredicate {
520-
trait_ref: tcx.mk_trait_ref(eq_trait_id, [tcx.mk_param_from_def(param)]),
520+
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
521521
constness: BoundConstness::NotConst,
522522
polarity: ImplPolarity::Positive,
523523
}))))

clippy_lints/src/escape.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
9292
if trait_item.id.owner_id.def_id == fn_def_id {
9393
// be sure we have `self` parameter in this function
9494
if trait_item.kind == (AssocItemKind::Fn { has_self: true }) {
95-
trait_self_ty = Some(
96-
TraitRef::identity(cx.tcx, trait_item.id.owner_id.to_def_id())
97-
.self_ty()
98-
.skip_binder(),
99-
);
95+
trait_self_ty =
96+
Some(TraitRef::identity(cx.tcx, trait_item.id.owner_id.to_def_id()).self_ty());
10097
}
10198
}
10299
}

clippy_lints/src/formatting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_span::source_map::Span;
1010

1111
declare_clippy_lint! {
1212
/// ### What it does
13-
/// Checks for usage of the nonexistent `=*`, `=!` and `=-`
13+
/// Checks for usage of the non-existent `=*`, `=!` and `=-`
1414
/// operators.
1515
///
1616
/// ### Why is this bad?

clippy_lints/src/future_not_send.rs

Lines changed: 3 additions & 4 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, EarlyBinder, PredicateKind};
7+
use rustc_middle::ty::{self, AliasTy, Clause, PredicateKind};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::def_id::LocalDefId;
1010
use rustc_span::{sym, Span};
@@ -66,8 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6666
if let ty::Alias(ty::Opaque, AliasTy { def_id, substs, .. }) = *ret_ty.kind() {
6767
let preds = cx.tcx.explicit_item_bounds(def_id);
6868
let mut is_future = false;
69-
for &(p, _span) in preds {
70-
let p = EarlyBinder(p).subst(cx.tcx, substs);
69+
for (p, _span) in preds.subst_iter_copied(cx.tcx, substs) {
7170
if let Some(trait_pred) = p.to_opt_poly_trait_pred() {
7271
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
7372
is_future = true;
@@ -97,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
9796
if let PredicateKind::Clause(Clause::Trait(trait_pred)) =
9897
obligation.predicate.kind().skip_binder()
9998
{
100-
db.note(&format!(
99+
db.note(format!(
101100
"`{}` doesn't implement `{}`",
102101
trait_pred.self_ty(),
103102
trait_pred.trait_ref.print_only_trait_path(),

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Se
354354
pub fn read_conf(sess: &Session, path: &io::Result<(Option<PathBuf>, Vec<String>)>) -> Conf {
355355
if let Ok((_, warnings)) = path {
356356
for warning in warnings {
357-
sess.warn(warning);
357+
sess.warn(warning.clone());
358358
}
359359
}
360360
let file_name = match path {

clippy_lints/src/methods/clone_on_copy.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
1+
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::get_parent_node;
33
use clippy_utils::source::snippet_with_context;
4-
use clippy_utils::sugg;
54
use clippy_utils::ty::is_copy;
65
use rustc_errors::Applicability;
76
use rustc_hir::{BindingAnnotation, ByRef, Expr, ExprKind, MatchSource, Node, PatKind, QPath};
87
use rustc_lint::LateContext;
98
use rustc_middle::ty::{self, adjustment::Adjust, print::with_forced_trimmed_paths};
109
use rustc_span::symbol::{sym, Symbol};
1110

12-
use super::CLONE_DOUBLE_REF;
1311
use super::CLONE_ON_COPY;
1412

1513
/// Checks for the `CLONE_ON_COPY` lint.
@@ -42,41 +40,7 @@ pub(super) fn check(
4240

4341
let ty = cx.typeck_results().expr_ty(expr);
4442
if let ty::Ref(_, inner, _) = arg_ty.kind() {
45-
if let ty::Ref(_, innermost, _) = inner.kind() {
46-
span_lint_and_then(
47-
cx,
48-
CLONE_DOUBLE_REF,
49-
expr.span,
50-
&with_forced_trimmed_paths!(format!(
51-
"using `clone` on a double-reference; \
52-
this will copy the reference of type `{ty}` instead of cloning the inner type"
53-
)),
54-
|diag| {
55-
if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) {
56-
let mut ty = innermost;
57-
let mut n = 0;
58-
while let ty::Ref(_, inner, _) = ty.kind() {
59-
ty = inner;
60-
n += 1;
61-
}
62-
let refs = "&".repeat(n + 1);
63-
let derefs = "*".repeat(n);
64-
let explicit = with_forced_trimmed_paths!(format!("<{refs}{ty}>::clone({snip})"));
65-
diag.span_suggestion(
66-
expr.span,
67-
"try dereferencing it",
68-
with_forced_trimmed_paths!(format!("{refs}({derefs}{}).clone()", snip.deref())),
69-
Applicability::MaybeIncorrect,
70-
);
71-
diag.span_suggestion(
72-
expr.span,
73-
"or try being explicit if you are sure, that you want to clone a reference",
74-
explicit,
75-
Applicability::MaybeIncorrect,
76-
);
77-
}
78-
},
79-
);
43+
if let ty::Ref(..) = inner.kind() {
8044
return; // don't report clone_on_copy
8145
}
8246
}

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -984,29 +984,6 @@ declare_clippy_lint! {
984984
"using 'clone' on a ref-counted pointer"
985985
}
986986

987-
declare_clippy_lint! {
988-
/// ### What it does
989-
/// Checks for usage of `.clone()` on an `&&T`.
990-
///
991-
/// ### Why is this bad?
992-
/// Cloning an `&&T` copies the inner `&T`, instead of
993-
/// cloning the underlying `T`.
994-
///
995-
/// ### Example
996-
/// ```rust
997-
/// fn main() {
998-
/// let x = vec![1];
999-
/// let y = &&x;
1000-
/// let z = y.clone();
1001-
/// println!("{:p} {:p}", *y, z); // prints out the same pointer
1002-
/// }
1003-
/// ```
1004-
#[clippy::version = "pre 1.29.0"]
1005-
pub CLONE_DOUBLE_REF,
1006-
correctness,
1007-
"using `clone` on `&&T`"
1008-
}
1009-
1010987
declare_clippy_lint! {
1011988
/// ### What it does
1012989
/// Checks for usage of `.to_string()` on an `&&T` where
@@ -3258,7 +3235,6 @@ impl_lint_pass!(Methods => [
32583235
CHARS_LAST_CMP,
32593236
CLONE_ON_COPY,
32603237
CLONE_ON_REF_PTR,
3261-
CLONE_DOUBLE_REF,
32623238
COLLAPSIBLE_STR_REPLACE,
32633239
ITER_OVEREAGER_CLONED,
32643240
CLONED_INSTEAD_OF_COPIED,
@@ -3500,8 +3476,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
35003476
let first_arg_span = first_arg_ty.span;
35013477
let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);
35023478
let self_ty = TraitRef::identity(cx.tcx, item.owner_id.to_def_id())
3503-
.self_ty()
3504-
.skip_binder();
3479+
.self_ty();
35053480
wrong_self_convention::check(
35063481
cx,
35073482
item.ident.name.as_str(),
@@ -3519,8 +3494,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
35193494
if let TraitItemKind::Fn(_, _) = item.kind;
35203495
let ret_ty = return_ty(cx, item.owner_id);
35213496
let self_ty = TraitRef::identity(cx.tcx, item.owner_id.to_def_id())
3522-
.self_ty()
3523-
.skip_binder();
3497+
.self_ty();
35243498
if !ret_ty.contains(self_ty);
35253499

35263500
then {

0 commit comments

Comments
 (0)