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

Commit 986750d

Browse files
authored
Rollup merge of rust-lang#140232 - nnethercote:rm-unnecessary-clones, r=SparrowLii
Remove unnecessary clones r? `@SparrowLii`
2 parents 1254559 + af80477 commit 986750d

File tree

27 files changed

+50
-50
lines changed

27 files changed

+50
-50
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
799799
has_bang,
800800
Some(*ident),
801801
macro_def.body.delim,
802-
&macro_def.body.tokens.clone(),
802+
&macro_def.body.tokens,
803803
true,
804804
sp,
805805
);
@@ -1468,7 +1468,7 @@ impl<'a> State<'a> {
14681468
true,
14691469
None,
14701470
m.args.delim,
1471-
&m.args.tokens.clone(),
1471+
&m.args.tokens,
14721472
true,
14731473
m.span(),
14741474
);

compiler/rustc_smir/src/rustc_internal/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ where
262262
/// // Your code goes in here.
263263
/// # ControlFlow::Continue(())
264264
/// }
265-
/// # let args = vec!["--verbose".to_string()];
265+
/// # let args = &["--verbose".to_string()];
266266
/// let result = run!(args, analyze_code);
267267
/// # assert_eq!(result, Err(CompilerError::Skipped))
268268
/// # }
@@ -284,7 +284,7 @@ where
284284
/// // Your code goes in here.
285285
/// # ControlFlow::Continue(())
286286
/// }
287-
/// # let args = vec!["--verbose".to_string()];
287+
/// # let args = &["--verbose".to_string()];
288288
/// # let extra_args = vec![];
289289
/// let result = run!(args, || analyze_code(extra_args));
290290
/// # assert_eq!(result, Err(CompilerError::Skipped))
@@ -346,7 +346,6 @@ macro_rules! run_driver {
346346
C: Send,
347347
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
348348
{
349-
args: Vec<String>,
350349
callback: Option<F>,
351350
result: Option<ControlFlow<B, C>>,
352351
}
@@ -358,14 +357,14 @@ macro_rules! run_driver {
358357
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
359358
{
360359
/// Creates a new `StableMir` instance, with given test_function and arguments.
361-
pub fn new(args: Vec<String>, callback: F) -> Self {
362-
StableMir { args, callback: Some(callback), result: None }
360+
pub fn new(callback: F) -> Self {
361+
StableMir { callback: Some(callback), result: None }
363362
}
364363

365364
/// Runs the compiler against given target and tests it with `test_function`
366-
pub fn run(&mut self) -> Result<C, CompilerError<B>> {
365+
pub fn run(&mut self, args: &[String]) -> Result<C, CompilerError<B>> {
367366
let compiler_result = rustc_driver::catch_fatal_errors(|| -> interface::Result::<()> {
368-
run_compiler(&self.args.clone(), self);
367+
run_compiler(&args, self);
369368
Ok(())
370369
});
371370
match (compiler_result, self.result.take()) {
@@ -415,7 +414,7 @@ macro_rules! run_driver {
415414
}
416415
}
417416

418-
StableMir::new($args, $callback).run()
417+
StableMir::new($callback).run($args)
419418
}};
420419
}
421420

compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ fn relate_mir_and_user_args<'tcx>(
117117
CRATE_DEF_ID,
118118
ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span),
119119
);
120-
let instantiated_predicate =
121-
ocx.normalize(&cause.clone(), param_env, instantiated_predicate);
120+
let instantiated_predicate = ocx.normalize(&cause, param_env, instantiated_predicate);
122121

123122
ocx.register_obligation(Obligation::new(tcx, cause, param_env, instantiated_predicate));
124123
}

library/alloc/src/collections/btree/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub struct Iter<'a, T: 'a> {
139139
#[stable(feature = "collection_debug", since = "1.17.0")]
140140
impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
141141
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142-
f.debug_tuple("Iter").field(&self.iter.clone()).finish()
142+
f.debug_tuple("Iter").field(&self.iter).finish()
143143
}
144144
}
145145

src/bootstrap/src/core/build_steps/setup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl Step for Editor {
683683
match EditorKind::prompt_user() {
684684
Ok(editor_kind) => {
685685
if let Some(editor_kind) = editor_kind {
686-
while !t!(create_editor_settings_maybe(config, editor_kind.clone())) {}
686+
while !t!(create_editor_settings_maybe(config, &editor_kind)) {}
687687
} else {
688688
println!("Ok, skipping editor setup!");
689689
}
@@ -695,7 +695,7 @@ impl Step for Editor {
695695

696696
/// Create the recommended editor LSP config file for rustc development, or just print it
697697
/// If this method should be re-called, it returns `false`.
698-
fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Result<bool> {
698+
fn create_editor_settings_maybe(config: &Config, editor: &EditorKind) -> io::Result<bool> {
699699
let hashes = editor.hashes();
700700
let (current_hash, historical_hashes) = hashes.split_last().unwrap();
701701
let settings_path = editor.settings_path(config);
@@ -752,7 +752,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
752752
// exists but user modified, back it up
753753
Some(false) => {
754754
// exists and is not current version or outdated, so back it up
755-
let backup = settings_path.clone().with_extension(editor.backup_extension());
755+
let backup = settings_path.with_extension(editor.backup_extension());
756756
eprintln!(
757757
"WARNING: copying `{}` to `{}`",
758758
settings_path.file_name().unwrap().to_str().unwrap(),

tests/ui-fulldeps/stable-mir/check_abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn get_item<'a>(
145145
fn main() {
146146
let path = "alloc_input.rs";
147147
generate_input(&path).unwrap();
148-
let args = vec![
148+
let args = &[
149149
"rustc".to_string(),
150150
"--crate-type=lib".to_string(),
151151
"--crate-name".to_string(),

tests/ui-fulldeps/stable-mir/check_allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn get_item<'a>(
219219
fn main() {
220220
let path = "alloc_input.rs";
221221
generate_input(&path).unwrap();
222-
let args = vec![
222+
let args = &[
223223
"rustc".to_string(),
224224
"--edition=2021".to_string(),
225225
"--crate-name".to_string(),

tests/ui-fulldeps/stable-mir/check_assoc_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn check_items<T: CrateDef>(items: &[T], expected: &[&str]) {
8585
fn main() {
8686
let path = "assoc_items.rs";
8787
generate_input(&path).unwrap();
88-
let args = vec![
88+
let args = &[
8989
"rustc".to_string(),
9090
"--crate-type=lib".to_string(),
9191
"--crate-name".to_string(),

tests/ui-fulldeps/stable-mir/check_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn get_item<'a>(
5757
fn main() {
5858
let path = "attribute_input.rs";
5959
generate_input(&path).unwrap();
60-
let args = vec![
60+
let args = &[
6161
"rustc".to_string(),
6262
"--crate-type=lib".to_string(),
6363
"--crate-name".to_string(),

tests/ui-fulldeps/stable-mir/check_binop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'a> MirVisitor for Visitor<'a> {
8181
fn main() {
8282
let path = "binop_input.rs";
8383
generate_input(&path).unwrap();
84-
let args = vec!["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
84+
let args = &["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
8585
run!(args, test_binops).unwrap();
8686
}
8787

0 commit comments

Comments
 (0)