Skip to content

Commit e29cefd

Browse files
committed
Fix tests
1 parent 58e3a4a commit e29cefd

File tree

17 files changed

+33
-18
lines changed

17 files changed

+33
-18
lines changed

compiler/rustc_codegen_ssa/src/back/rpath.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
2424

2525
debug!("preparing the RPATH!");
2626

27-
let libs = config.used_crates.clone();
27+
let libs = config.used_crates;
2828
let libs = libs.iter().filter_map(|&(_, ref l)| l.option()).collect::<Vec<_>>();
2929
let rpaths = get_rpaths(config, &libs);
3030
let mut flags = rpaths_to_flags(&rpaths);

compiler/rustc_lint/src/noop_method_call.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
4646
{
4747
// Check that we're dealing with a trait method
4848
if let Some(trait_id) = cx.tcx.trait_of_item(did) {
49+
// Check we're dealing with one of the traits we care about
50+
if ![sym::Clone, sym::Deref, sym::Borrow]
51+
.iter()
52+
.any(|s| cx.tcx.is_diagnostic_item(*s, trait_id))
53+
{
54+
return;
55+
}
56+
4957
let substs = cx.typeck_results().node_substs(expr.hir_id);
5058
// We can't resolve on types that recursively require monomorphization,
5159
// so check that we don't need to perfom substitution
@@ -54,7 +62,6 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
5462
// Resolve the trait method instance
5563
if let Ok(Some(i)) = ty::Instance::resolve(cx.tcx, param_env, did, substs) {
5664
// Check that it implements the noop diagnostic
57-
tracing::debug!("Resolves to: {:?}", i.def_id());
5865
if [
5966
sym::noop_method_borrow,
6067
sym::noop_method_clone,

compiler/rustc_middle/src/ty/error.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_target::spec::abi;
1212

1313
use std::borrow::Cow;
1414
use std::fmt;
15-
use std::ops::Deref;
1615

1716
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable)]
1817
pub struct ExpectedFound<T> {
@@ -535,7 +534,6 @@ impl<T> Trait<T> for X {
535534
TargetFeatureCast(def_id) => {
536535
let attrs = self.get_attrs(*def_id);
537536
let target_spans = attrs
538-
.deref()
539537
.iter()
540538
.filter(|attr| attr.has_name(sym::target_feature))
541539
.map(|attr| attr.span);

compiler/rustc_mir/src/borrow_check/invalidation.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
165165
self.consume_operand(location, value);
166166

167167
// Invalidate all borrows of local places
168-
let borrow_set = self.borrow_set.clone();
168+
let borrow_set = self.borrow_set;
169169
let resume = self.location_table.start_index(resume.start_location());
170170
for (i, data) in borrow_set.iter_enumerated() {
171171
if borrow_of_local_data(data.borrowed_place) {
@@ -177,7 +177,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
177177
}
178178
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
179179
// Invalidate all borrows of local places
180-
let borrow_set = self.borrow_set.clone();
180+
let borrow_set = self.borrow_set;
181181
let start = self.location_table.start_index(location);
182182
for (i, data) in borrow_set.iter_enumerated() {
183183
if borrow_of_local_data(data.borrowed_place) {
@@ -369,15 +369,15 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
369369
);
370370
let tcx = self.tcx;
371371
let body = self.body;
372-
let borrow_set = self.borrow_set.clone();
372+
let borrow_set = self.borrow_set;
373373
let indices = self.borrow_set.indices();
374374
each_borrow_involving_path(
375375
self,
376376
tcx,
377377
body,
378378
location,
379379
(sd, place),
380-
&borrow_set.clone(),
380+
borrow_set,
381381
indices,
382382
|this, borrow_index, borrow| {
383383
match (rw, borrow.kind) {

compiler/rustc_mir_build/src/build/matches/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5151

5252
PatKind::Constant { value } => Test {
5353
span: match_pair.pattern.span,
54-
kind: TestKind::Eq { value, ty: match_pair.pattern.ty.clone() },
54+
kind: TestKind::Eq { value, ty: match_pair.pattern.ty },
5555
},
5656

5757
PatKind::Range(range) => {

compiler/rustc_span/src/symbol.rs

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ symbols! {
126126
Argument,
127127
ArgumentV1,
128128
Arguments,
129+
Borrow,
129130
C,
130131
CString,
131132
Center,
@@ -136,6 +137,7 @@ symbols! {
136137
Decodable,
137138
Decoder,
138139
Default,
140+
Deref,
139141
Encodable,
140142
Encoder,
141143
Eq,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
828828
sig.decl
829829
.inputs
830830
.iter()
831-
.map(|arg| match arg.clone().kind {
831+
.map(|arg| match arg.kind {
832832
hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
833833
Some(arg.span),
834834
vec![("_".to_owned(), "_".to_owned()); tys.len()],

compiler/rustc_traits/src/chalk/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ crate fn evaluate_goal<'tcx>(
112112
});
113113
let sol = Canonical {
114114
max_universe: ty::UniverseIndex::from_usize(0),
115-
variables: obligation.variables.clone(),
115+
variables: obligation.variables,
116116
value: QueryResponse {
117117
var_values: CanonicalVarValues { var_values },
118118
region_constraints: QueryRegionConstraints::default(),
@@ -137,7 +137,7 @@ crate fn evaluate_goal<'tcx>(
137137
// let's just ignore that
138138
let sol = Canonical {
139139
max_universe: ty::UniverseIndex::from_usize(0),
140-
variables: obligation.variables.clone(),
140+
variables: obligation.variables,
141141
value: QueryResponse {
142142
var_values: CanonicalVarValues { var_values: IndexVec::new() }
143143
.make_identity(tcx),

compiler/rustc_typeck/src/check/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
446446
let expected_arg_tys = self.expected_inputs_for_expected_output(
447447
call_expr.span,
448448
expected,
449-
fn_sig.output().clone(),
449+
fn_sig.output(),
450450
fn_sig.inputs(),
451451
);
452452

compiler/rustc_typeck/src/check/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
710710
});
711711

712712
let ret_ty = ret_coercion.borrow().expected_ty();
713-
let return_expr_ty = self.check_expr_with_hint(return_expr, ret_ty.clone());
713+
let return_expr_ty = self.check_expr_with_hint(return_expr, ret_ty);
714714
ret_coercion.borrow_mut().coerce(
715715
self,
716716
&self.cause(return_expr.span, ObligationCauseCode::ReturnValue(return_expr.hir_id)),

library/core/src/borrow.rs

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
/// [`HashMap<K, V>`]: ../../std/collections/struct.HashMap.html
154154
/// [`String`]: ../../std/string/struct.String.html
155155
#[stable(feature = "rust1", since = "1.0.0")]
156+
#[rustc_diagnostic_item = "Borrow"]
156157
pub trait Borrow<Borrowed: ?Sized> {
157158
/// Immutably borrows from an owned value.
158159
///

library/core/src/clone.rs

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
/// [impls]: #implementors
105105
#[stable(feature = "rust1", since = "1.0.0")]
106106
#[lang = "clone"]
107+
#[rustc_diagnostic_item = "Clone"]
107108
pub trait Clone: Sized {
108109
/// Returns a copy of the value.
109110
///

library/core/src/ops/deref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#[doc(alias = "*")]
6161
#[doc(alias = "&*")]
6262
#[stable(feature = "rust1", since = "1.0.0")]
63+
#[rustc_diagnostic_item = "Deref"]
6364
pub trait Deref {
6465
/// The resulting type after dereferencing.
6566
#[stable(feature = "rust1", since = "1.0.0")]

src/test/ui/issues/issue-11820.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// run-pass
22
// pretty-expanded FIXME #23616
33

4+
#![allow(noop_method_call)]
5+
46
struct NoClone;
57

68
fn main() {
7-
let rnc = &NoClone;
8-
let rsnc = &Some(NoClone);
9+
let rnc = &NoClone;
10+
let rsnc = &Some(NoClone);
911

10-
let _: &NoClone = rnc.clone();
11-
let _: &Option<NoClone> = rsnc.clone();
12+
let _: &NoClone = rnc.clone();
13+
let _: &Option<NoClone> = rsnc.clone();
1214
}

src/test/ui/underscore-imports/cycle.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ mod y {
1414

1515
pub fn main() {
1616
use x::*;
17+
#[allow(noop_method_call)]
1718
(&0).deref();
1819
}

src/test/ui/underscore-imports/hygiene-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ m!(y);
2929

3030
fn main() {
3131
use crate::y::*;
32+
#[allow(noop_method_call)]
3233
(&()).deref();
3334
}

src/test/ui/underscore-imports/macro-expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// check-pass
44

55
#![feature(decl_macro, rustc_attrs)]
6+
#![allow(noop_method_call)]
67

78
mod x {
89
pub use std::ops::Not as _;

0 commit comments

Comments
 (0)