Rollup merge of #61866 - sinkuu:redundant_clone, r=petrochenkov

Remove redundant `clone()`s
This commit is contained in:
Mazdak Farrokhzad 2019-06-16 06:05:18 +02:00 committed by GitHub
commit 2ba1d94f7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 17 additions and 16 deletions

View file

@ -307,7 +307,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let required_region_bounds = tcx.required_region_bounds(
opaque_type,
bounds.predicates.clone(),
bounds.predicates,
);
debug_assert!(!required_region_bounds.is_empty());

View file

@ -1617,7 +1617,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
self.ir.tcx.lint_hir_note(
lint::builtin::UNUSED_VARIABLES,
hir_id,
spans.clone(),
spans,
&format!("variable `{}` is assigned to, but never used", name),
&format!("consider using `_{}` instead", name),
);

View file

@ -36,7 +36,7 @@ fn owned_ptr_base_path<'a, 'tcx>(loan_path: &'a LoanPath<'tcx>) -> &'a LoanPath<
return match helper(loan_path) {
Some(new_loan_path) => new_loan_path,
None => loan_path.clone()
None => loan_path,
};
fn helper<'a, 'tcx>(loan_path: &'a LoanPath<'tcx>) -> Option<&'a LoanPath<'tcx>> {

View file

@ -279,7 +279,7 @@ fn fat_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
}
}));
serialized_modules.extend(cached_modules.into_iter().map(|(buffer, wp)| {
(buffer, CString::new(wp.cgu_name.clone()).unwrap())
(buffer, CString::new(wp.cgu_name).unwrap())
}));
// For all serialized bitcode files we parse them and link them in as we did

View file

@ -459,7 +459,7 @@ impl CodegenCx<'b, 'tcx> {
};
let f = self.declare_cfn(name, fn_ty);
llvm::SetUnnamedAddr(f, false);
self.intrinsics.borrow_mut().insert(name, f.clone());
self.intrinsics.borrow_mut().insert(name, f);
f
}

View file

@ -1609,7 +1609,7 @@ impl<'tcx> VariantInfo<'tcx> {
// with every variant, make each variant name be just the value
// of the discriminant. The struct name for the variant includes
// the actual variant description.
format!("{}", variant_index.as_usize()).to_string()
format!("{}", variant_index.as_usize())
}
}
}

View file

@ -194,7 +194,7 @@ impl AnnotateSnippetEmitterWriter {
let converter = DiagnosticConverter {
source_map: self.source_map.clone(),
level: level.clone(),
message: message.clone(),
message,
code: code.clone(),
msp: msp.clone(),
children,

View file

@ -236,7 +236,7 @@ impl<'a> CrateLoader<'a> {
let host_lib = host_lib.unwrap();
self.load_derive_macros(
&host_lib.metadata.get_root(),
host_lib.dylib.clone().map(|p| p.0),
host_lib.dylib.map(|p| p.0),
span
)
} else {

View file

@ -1737,7 +1737,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pat_span,
}))),
};
let for_arm_body = self.local_decls.push(local.clone());
let for_arm_body = self.local_decls.push(local);
let locals = if has_guard.0 {
let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> {
// This variable isn't mutated but has a name, so has to be

View file

@ -922,7 +922,7 @@ fn receiver_is_valid<'fcx, 'tcx>(
};
let obligation = traits::Obligation::new(
cause.clone(),
cause,
fcx.param_env,
trait_ref.to_predicate()
);

View file

@ -317,7 +317,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
// Ensure that rustdoc works even if rustc is feature-staged
unstable_features: UnstableFeatures::Allow,
actually_rustdoc: true,
debugging_opts: debugging_options.clone(),
debugging_opts: debugging_options,
error_format,
edition,
describe_lints,

View file

@ -740,7 +740,7 @@ impl Tester for Collector {
debug!("Creating test {}: {}", name, test);
self.tests.push(testing::TestDescAndFn {
desc: testing::TestDesc {
name: testing::DynTestName(name.clone()),
name: testing::DynTestName(name),
ignore: config.ignore,
// compiler failures are test failures
should_panic: testing::ShouldPanic::No,

View file

@ -23,6 +23,7 @@ use log::debug;
use rustc_data_structures::fx::{FxHashMap};
use std::borrow::Cow;
use std::collections::hash_map::Entry;
use std::slice;
use rustc_data_structures::sync::Lrc;
use errors::Applicability;
@ -359,10 +360,10 @@ pub fn compile(
// don't abort iteration early, so that errors for multiple lhses can be reported
for lhs in &lhses {
valid &= check_lhs_no_empty_seq(sess, &[lhs.clone()]);
valid &= check_lhs_no_empty_seq(sess, slice::from_ref(lhs));
valid &= check_lhs_duplicate_matcher_bindings(
sess,
&[lhs.clone()],
slice::from_ref(lhs),
&mut FxHashMap::default(),
def.id
);

View file

@ -887,7 +887,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>,
};
let fmt_str = &*fmt.node.0.as_str(); // for the suggestions below
let mut parser = parse::Parser::new(fmt_str, str_style, skips.clone(), append_newline);
let mut parser = parse::Parser::new(fmt_str, str_style, skips, append_newline);
let mut unverified_pieces = Vec::new();
while let Some(piece) = parser.next() {

View file

@ -409,7 +409,7 @@ impl server::TokenStream for Rustc<'_> {
}
fn from_str(&mut self, src: &str) -> Self::TokenStream {
parse::parse_stream_from_source_str(
FileName::proc_macro_source_code(src.clone()),
FileName::proc_macro_source_code(src),
src.to_string(),
self.sess,
Some(self.call_site),