Skip to content

Commit 82fbdaa

Browse files
committed
rename to suspicious_double_ref_op and fix CI
1 parent 0dbc32d commit 82fbdaa

File tree

20 files changed

+32
-33
lines changed

20 files changed

+32
-33
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ fn link_dwarf_object<'a>(
573573

574574
impl<Relocations> ThorinSession<Relocations> {
575575
fn alloc_mmap(&self, data: Mmap) -> &Mmap {
576-
(*self.arena_mmap.alloc(data)).borrow()
576+
&*self.arena_mmap.alloc(data)
577577
}
578578
}
579579

@@ -583,7 +583,7 @@ fn link_dwarf_object<'a>(
583583
}
584584

585585
fn alloc_relocation(&self, data: Relocations) -> &Relocations {
586-
(*self.arena_relocations.alloc(data)).borrow()
586+
&*self.arena_relocations.alloc(data)
587587
}
588588

589589
fn read_input(&self, path: &Path) -> std::io::Result<&[u8]> {

compiler/rustc_lint/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ lint_array_into_iter =
55
.use_explicit_into_iter_suggestion =
66
or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
77
8-
lint_clone_double_ref =
8+
lint_suspicious_double_ref_op =
99
using `.{$call}()` on a double reference, which copies `{$ty}` instead of {$op} the inner type
1010
1111
lint_enum_intrinsics_mem_discriminant =

compiler/rustc_lint/src/lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ pub struct BuiltinUnexpectedCliConfigValue {
565565
}
566566

567567
#[derive(LintDiagnostic)]
568-
#[diag(lint_clone_double_ref)]
568+
#[diag(lint_suspicious_double_ref_op)]
569569
pub struct CloneDoubleRef<'a> {
570570
pub call: Symbol,
571571
pub ty: Ty<'a>,

compiler/rustc_lint/src/noop_method_call.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ declare_lint! {
3737
}
3838

3939
declare_lint! {
40-
/// The `clone_double_ref` lint checks for usage of `.clone()` on an `&&T`,
40+
/// The `suspicious_double_ref_op` lint checks for usage of `.clone()` on an `&&T`,
4141
/// which copies the inner `&T`, instead of cloning the underlying `T` and
4242
/// can be confusing.
43-
pub CLONE_DOUBLE_REF,
43+
pub SUSPICIOUS_DOUBLE_REF_OP,
4444
Warn,
4545
"using `clone` on `&&T`"
4646
}
4747

48-
declare_lint_pass!(NoopMethodCall => [NOOP_METHOD_CALL, CLONE_DOUBLE_REF]);
48+
declare_lint_pass!(NoopMethodCall => [NOOP_METHOD_CALL, SUSPICIOUS_DOUBLE_REF_OP]);
4949

5050
impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
5151
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
@@ -115,7 +115,7 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
115115
);
116116
} else {
117117
cx.emit_spanned_lint(
118-
CLONE_DOUBLE_REF,
118+
SUSPICIOUS_DOUBLE_REF_OP,
119119
span,
120120
CloneDoubleRef { call: call.ident.name, ty: expr_ty, op },
121121
)

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use rustc_span::def_id::LocalDefId;
3939
use rustc_span::symbol::{sym, Ident, Symbol};
4040
use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span, DUMMY_SP};
4141
use rustc_target::spec::abi;
42-
use std::ops::Deref;
4342

4443
use super::method_chain::CollectAllMismatches;
4544
use super::InferCtxtPrivExt;
@@ -3571,7 +3570,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
35713570
// trait_pred `S: Sum<<Self as Iterator>::Item>` and predicate `i32: Sum<&()>`
35723571
let mut type_diffs = vec![];
35733572

3574-
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref()
3573+
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code
35753574
&& let Some(node_substs) = typeck_results.node_substs_opt(call_hir_id)
35763575
&& let where_clauses = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_substs)
35773576
&& let Some(where_pred) = where_clauses.predicates.get(*idx)

library/core/benches/iter.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::borrow::Borrow;
21
use core::iter::*;
32
use core::mem;
43
use core::num::Wrapping;
@@ -428,7 +427,7 @@ fn bench_trusted_random_access_chunks(b: &mut Bencher) {
428427
black_box(&v)
429428
.iter()
430429
// this shows that we're not relying on the slice::Iter specialization in Copied
431-
.map(|b| *b.borrow())
430+
.map(|b| *b)
432431
.array_chunks::<{ mem::size_of::<u64>() }>()
433432
.map(|ary| {
434433
let d = u64::from_ne_bytes(ary);

library/core/tests/clone.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#[test]
2+
#[cfg_attr(not(bootstrap), allow(suspicious_double_ref_op))]
23
fn test_borrowed_clone() {
34
let x = 5;
45
let y: &i32 = &x;

src/tools/clippy/clippy_lints/src/renamed_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3030
("clippy::stutter", "clippy::module_name_repetitions"),
3131
("clippy::to_string_in_display", "clippy::recursive_format_impl"),
3232
("clippy::zero_width_space", "clippy::invisible_characters"),
33-
("clippy::clone_double_ref", "clone_double_ref"),
33+
("clippy::clone_double_ref", "suspicious_double_ref_op"),
3434
("clippy::drop_bounds", "drop_bounds"),
3535
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
3636
("clippy::for_loop_over_result", "for_loops_over_fallibles"),

src/tools/clippy/tests/ui/explicit_deref_methods.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#![warn(clippy::explicit_deref_methods)]
33
#![allow(unused_variables)]
44
#![allow(
5+
noop_method_call,
56
clippy::borrow_deref_ref,
6-
clone_double_ref,
77
clippy::explicit_auto_deref,
88
clippy::needless_borrow,
99
clippy::uninlined_format_args

src/tools/clippy/tests/ui/explicit_deref_methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#![warn(clippy::explicit_deref_methods)]
33
#![allow(unused_variables)]
44
#![allow(
5+
noop_method_call,
56
clippy::borrow_deref_ref,
6-
clone_double_ref,
77
clippy::explicit_auto_deref,
88
clippy::needless_borrow,
99
clippy::uninlined_format_args

src/tools/clippy/tests/ui/rename.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#![allow(clippy::module_name_repetitions)]
2828
#![allow(clippy::recursive_format_impl)]
2929
#![allow(clippy::invisible_characters)]
30-
#![allow(clone_double_ref)]
3130
#![allow(drop_bounds)]
3231
#![allow(for_loops_over_fallibles)]
3332
#![allow(array_into_iter)]
@@ -37,6 +36,7 @@
3736
#![allow(enum_intrinsics_non_enums)]
3837
#![allow(non_fmt_panics)]
3938
#![allow(named_arguments_used_positionally)]
39+
#![allow(suspicious_double_ref_op)]
4040
#![allow(temporary_cstring_as_ptr)]
4141
#![allow(unknown_lints)]
4242
#![allow(unused_labels)]
@@ -68,7 +68,7 @@
6868
#![warn(clippy::module_name_repetitions)]
6969
#![warn(clippy::recursive_format_impl)]
7070
#![warn(clippy::invisible_characters)]
71-
#![warn(clone_double_ref)]
71+
#![warn(suspicious_double_ref_op)]
7272
#![warn(drop_bounds)]
7373
#![warn(for_loops_over_fallibles)]
7474
#![warn(for_loops_over_fallibles)]

src/tools/clippy/tests/ui/rename.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#![allow(clippy::module_name_repetitions)]
2828
#![allow(clippy::recursive_format_impl)]
2929
#![allow(clippy::invisible_characters)]
30-
#![allow(clone_double_ref)]
3130
#![allow(drop_bounds)]
3231
#![allow(for_loops_over_fallibles)]
3332
#![allow(array_into_iter)]
@@ -37,6 +36,7 @@
3736
#![allow(enum_intrinsics_non_enums)]
3837
#![allow(non_fmt_panics)]
3938
#![allow(named_arguments_used_positionally)]
39+
#![allow(suspicious_double_ref_op)]
4040
#![allow(temporary_cstring_as_ptr)]
4141
#![allow(unknown_lints)]
4242
#![allow(unused_labels)]

src/tools/clippy/tests/ui/rename.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_ch
168168
LL | #![warn(clippy::zero_width_space)]
169169
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters`
170170

171-
error: lint `clippy::clone_double_ref` has been renamed to `clone_double_ref`
171+
error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op`
172172
--> $DIR/rename.rs:71:9
173173
|
174174
LL | #![warn(clippy::clone_double_ref)]
175-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clone_double_ref`
175+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `suspicious_double_ref_op`
176176

177177
error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
178178
--> $DIR/rename.rs:72:9

src/tools/compiletest/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
11141114
for path in found_paths {
11151115
for ancestor in path.ancestors().skip(1) {
11161116
if found_paths.contains(ancestor) {
1117-
collisions.push((path, ancestor.clone()));
1117+
collisions.push((path, ancestor));
11181118
}
11191119
}
11201120
}

tests/ui/lint/clone-double-ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(lazy_cell)]
2-
#![deny(clone_double_ref, noop_method_call)]
2+
#![deny(suspicious_double_ref_op, noop_method_call)]
33

44
pub fn clone_on_double_ref() {
55
let x = vec![1];

tests/ui/lint/clone-double-ref.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | let z: &Vec<_> = y.clone();
77
note: the lint level is defined here
88
--> $DIR/clone-double-ref.rs:2:9
99
|
10-
LL | #![deny(clone_double_ref, noop_method_call)]
11-
| ^^^^^^^^^^^^^^^^
10+
LL | #![deny(suspicious_double_ref_op, noop_method_call)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: call to `.clone()` on a reference in this situation does nothing
1414
--> $DIR/clone-double-ref.rs:24:25
@@ -18,10 +18,10 @@ LL | let _ = &mut encoded.clone();
1818
|
1919
= note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed
2020
note: the lint level is defined here
21-
--> $DIR/clone-double-ref.rs:2:27
21+
--> $DIR/clone-double-ref.rs:2:35
2222
|
23-
LL | #![deny(clone_double_ref, noop_method_call)]
24-
| ^^^^^^^^^^^^^^^^
23+
LL | #![deny(suspicious_double_ref_op, noop_method_call)]
24+
| ^^^^^^^^^^^^^^^^
2525

2626
error: call to `.clone()` on a reference in this situation does nothing
2727
--> $DIR/clone-double-ref.rs:26:21

tests/ui/lint/noop-method-call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// check-pass
22

33
#![allow(unused)]
4-
#![warn(noop_method_call, clone_double_ref)]
4+
#![warn(noop_method_call, suspicious_double_ref_op)]
55

66
use std::borrow::Borrow;
77
use std::ops::Deref;

tests/ui/lint/noop-method-call.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clon
88
note: the lint level is defined here
99
--> $DIR/noop-method-call.rs:4:9
1010
|
11-
LL | #![warn(noop_method_call, clone_double_ref)]
11+
LL | #![warn(noop_method_call, suspicious_double_ref_op)]
1212
| ^^^^^^^^^^^^^^^^
1313

1414
warning: using `.clone()` on a double reference, which copies `&CloneType<u32>` instead of cloning the inner type
@@ -20,8 +20,8 @@ LL | let clone_type_ref_clone: &CloneType<u32> = clone_type_ref.clone();
2020
note: the lint level is defined here
2121
--> $DIR/noop-method-call.rs:4:27
2222
|
23-
LL | #![warn(noop_method_call, clone_double_ref)]
24-
| ^^^^^^^^^^^^^^^^
23+
LL | #![warn(noop_method_call, suspicious_double_ref_op)]
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^
2525

2626
warning: call to `.deref()` on a reference in this situation does nothing
2727
--> $DIR/noop-method-call.rs:27:63

tests/ui/trait-bounds/issue-94680.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// check-pass
22

3-
#![allow(clone_double_ref)]
3+
#![allow(suspicious_double_ref_op)]
44

55
fn main() {
66
println!("{:?}", {

tests/ui/trivial-bounds/issue-73021-impossible-inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// revisions: no-opt inline
33
// [inline]compile-flags: -Zmir-opt-level=3 --emit=mir
44
#![feature(trivial_bounds)]
5-
#![allow(unused, clone_double_ref)]
5+
#![allow(unused, suspicious_double_ref_op)]
66

77
trait Foo {
88
fn test(&self);

0 commit comments

Comments
 (0)