Skip to content

Commit 8d482b4

Browse files
authored
Unrolled build for rust-lang#140232
Rollup merge of rust-lang#140232 - nnethercote:rm-unnecessary-clones, r=SparrowLii Remove unnecessary clones r? `@SparrowLii`
2 parents 7f69523 + af80477 commit 8d482b4

27 files changed

+50
-50
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

+2-2
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

+7-8
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ where
256256
/// // Your code goes in here.
257257
/// # ControlFlow::Continue(())
258258
/// }
259-
/// # let args = vec!["--verbose".to_string()];
259+
/// # let args = &["--verbose".to_string()];
260260
/// let result = run!(args, analyze_code);
261261
/// # assert_eq!(result, Err(CompilerError::Skipped))
262262
/// # }
@@ -278,7 +278,7 @@ where
278278
/// // Your code goes in here.
279279
/// # ControlFlow::Continue(())
280280
/// }
281-
/// # let args = vec!["--verbose".to_string()];
281+
/// # let args = &["--verbose".to_string()];
282282
/// # let extra_args = vec![];
283283
/// let result = run!(args, || analyze_code(extra_args));
284284
/// # assert_eq!(result, Err(CompilerError::Skipped))
@@ -340,7 +340,6 @@ macro_rules! run_driver {
340340
C: Send,
341341
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
342342
{
343-
args: Vec<String>,
344343
callback: Option<F>,
345344
result: Option<ControlFlow<B, C>>,
346345
}
@@ -352,14 +351,14 @@ macro_rules! run_driver {
352351
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
353352
{
354353
/// Creates a new `StableMir` instance, with given test_function and arguments.
355-
pub fn new(args: Vec<String>, callback: F) -> Self {
356-
StableMir { args, callback: Some(callback), result: None }
354+
pub fn new(callback: F) -> Self {
355+
StableMir { callback: Some(callback), result: None }
357356
}
358357

359358
/// Runs the compiler against given target and tests it with `test_function`
360-
pub fn run(&mut self) -> Result<C, CompilerError<B>> {
359+
pub fn run(&mut self, args: &[String]) -> Result<C, CompilerError<B>> {
361360
let compiler_result = rustc_driver::catch_fatal_errors(|| -> interface::Result::<()> {
362-
run_compiler(&self.args.clone(), self);
361+
run_compiler(&args, self);
363362
Ok(())
364363
});
365364
match (compiler_result, self.result.take()) {
@@ -409,7 +408,7 @@ macro_rules! run_driver {
409408
}
410409
}
411410

412-
StableMir::new($args, $callback).run()
411+
StableMir::new($callback).run($args)
413412
}};
414413
}
415414

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

+1-2
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

+1-1
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

+3-3
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn contains<T: CrateDef + std::fmt::Debug>(items: &[T], expected: &[&str]) {
8484
fn main() {
8585
let path = "crate_definitions.rs";
8686
generate_input(&path).unwrap();
87-
let args = vec![
87+
let args = &[
8888
"rustc".to_string(),
8989
"--crate-type=lib".to_string(),
9090
"--crate-name".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn check_fn_def(ty: Ty) {
7676
fn main() {
7777
let path = "defs_ty_input.rs";
7878
generate_input(&path).unwrap();
79-
let args = vec![
79+
let args = &[
8080
"rustc".to_string(),
8181
"-Cpanic=abort".to_string(),
8282
"--crate-name".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn get_instances(body: mir::Body) -> Vec<Instance> {
112112
fn main() {
113113
let path = "defs_input.rs";
114114
generate_input(&path).unwrap();
115-
let args = vec![
115+
let args = &[
116116
"rustc".to_string(),
117117
"-Cpanic=abort".to_string(),
118118
"--crate-name".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn test_foreign() -> ControlFlow<()> {
5858
fn main() {
5959
let path = "foreign_input.rs";
6060
generate_input(&path).unwrap();
61-
let args = vec![
61+
let args = &[
6262
"rustc".to_string(),
6363
"-Cpanic=abort".to_string(),
6464
"--crate-type=lib".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn test_body(body: mir::Body) {
8787
fn main() {
8888
let path = "instance_input.rs";
8989
generate_input(&path).unwrap();
90-
let args = vec![
90+
let args = &[
9191
"rustc".to_string(),
9292
"-Cpanic=abort".to_string(),
9393
"--crate-type=lib".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'a> MirVisitor for CallsVisitor<'a> {
115115
fn main() {
116116
let path = "binop_input.rs";
117117
generate_input(&path).unwrap();
118-
let args = vec!["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
118+
let args = &["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()];
119119
run!(args, test_intrinsics).unwrap();
120120
}
121121

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn test_item_kind() -> ControlFlow<()> {
4747
fn main() {
4848
let path = "item_kind_input.rs";
4949
generate_input(&path).unwrap();
50-
let args = vec![
50+
let args = &[
5151
"rustc".to_string(),
5252
"-Cpanic=abort".to_string(),
5353
"--crate-type=lib".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn check_ty(ty: Ty) {
6161
fn main() {
6262
let path = "normalization_input.rs";
6363
generate_input(&path).unwrap();
64-
let args = vec![
64+
let args = &[
6565
"rustc".to_string(),
6666
"-Cpanic=abort".to_string(),
6767
"--crate-type=lib".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn assert_impl(impl_names: &HashSet<String>, target: &str) {
7272
fn main() {
7373
let path = "trait_queries.rs";
7474
generate_input(&path).unwrap();
75-
let args = vec![
75+
let args = &[
7676
"rustc".to_string(),
7777
"--crate-type=lib".to_string(),
7878
"--crate-name".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn get_item<'a>(
120120
fn main() {
121121
let path = "transform_input.rs";
122122
generate_input(&path).unwrap();
123-
let args = vec![
123+
let args = &[
124124
"rustc".to_string(),
125125
"--crate-type=lib".to_string(),
126126
"--crate-name".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a> MirVisitor for PlaceVisitor<'a> {
7878
fn main() {
7979
let path = "ty_fold_input.rs";
8080
generate_input(&path).unwrap();
81-
let args = vec![
81+
let args = &[
8282
"rustc".to_string(),
8383
"-Cpanic=abort".to_string(),
8484
"--crate-name".to_string(),

tests/ui-fulldeps/stable-mir/compilation-result.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,42 @@ use std::io::Write;
2525
fn main() {
2626
let path = "input_compilation_result_test.rs";
2727
generate_input(&path).unwrap();
28-
let args = vec!["rustc".to_string(), path.to_string()];
29-
test_continue(args.clone());
30-
test_break(args.clone());
31-
test_failed(args.clone());
32-
test_skipped(args.clone());
28+
let args = &["rustc".to_string(), path.to_string()];
29+
test_continue(args);
30+
test_break(args);
31+
test_failed(args);
32+
test_skipped(args);
3333
test_captured(args)
3434
}
3535

36-
fn test_continue(args: Vec<String>) {
36+
fn test_continue(args: &[String]) {
3737
let result = run!(args, || ControlFlow::Continue::<(), bool>(true));
3838
assert_eq!(result, Ok(true));
3939
}
4040

41-
fn test_break(args: Vec<String>) {
41+
fn test_break(args: &[String]) {
4242
let result = run!(args, || ControlFlow::Break::<bool, i32>(false));
4343
assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false)));
4444
}
4545

4646
#[allow(unreachable_code)]
47-
fn test_skipped(mut args: Vec<String>) {
47+
fn test_skipped(args: &[String]) {
48+
let mut args = args.to_vec();
4849
args.push("--version".to_string());
49-
let result = run!(args, || unreachable!() as ControlFlow<()>);
50+
let result = run!(&args, || unreachable!() as ControlFlow<()>);
5051
assert_eq!(result, Err(stable_mir::CompilerError::Skipped));
5152
}
5253

5354
#[allow(unreachable_code)]
54-
fn test_failed(mut args: Vec<String>) {
55+
fn test_failed(args: &[String]) {
56+
let mut args = args.to_vec();
5557
args.push("--cfg=broken".to_string());
56-
let result = run!(args, || unreachable!() as ControlFlow<()>);
58+
let result = run!(&args, || unreachable!() as ControlFlow<()>);
5759
assert_eq!(result, Err(stable_mir::CompilerError::Failed));
5860
}
5961

6062
/// Test that we are able to pass a closure and set the return according to the captured value.
61-
fn test_captured(args: Vec<String>) {
63+
fn test_captured(args: &[String]) {
6264
let captured = "10".to_string();
6365
let result = run!(args, || ControlFlow::Continue::<(), usize>(captured.len()));
6466
assert_eq!(result, Ok(captured.len()));

tests/ui-fulldeps/stable-mir/crate-info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn get_item<'a>(
186186
fn main() {
187187
let path = "input.rs";
188188
generate_input(&path).unwrap();
189-
let args = vec![
189+
let args = &[
190190
"rustc".to_string(),
191191
"--crate-type=lib".to_string(),
192192
"--crate-name".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn get_item<'a>(
146146
fn main() {
147147
let path = "input.rs";
148148
generate_input(&path).unwrap();
149-
let args = vec![
149+
let args = &[
150150
"rustc".to_string(),
151151
"--crate-type=lib".to_string(),
152152
"--crate-name".to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn test_translation(tcx: TyCtxt<'_>) -> ControlFlow<()> {
4040
fn main() {
4141
let path = "internal_input.rs";
4242
generate_input(&path).unwrap();
43-
let args = vec![
43+
let args = &[
4444
"rustc".to_string(),
4545
"--crate-name".to_string(),
4646
CRATE_NAME.to_string(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
4646
fn main() {
4747
let path = "internal_input.rs";
4848
generate_input(&path).unwrap();
49-
let args = vec![
49+
let args = &[
5050
"rustc".to_string(),
5151
"--crate-name".to_string(),
5252
CRATE_NAME.to_string(),

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ impl mir::MutMirVisitor for TestMutVisitor {
183183
fn main() {
184184
let path = "sim_visitor_input.rs";
185185
generate_input(&path).unwrap();
186-
let args = vec![
186+
let args = &[
187187
"rustc".to_string(),
188188
"-Cpanic=abort".to_string(),
189189
"--crate-name".to_string(),
190190
CRATE_NAME.to_string(),
191191
path.to_string(),
192192
];
193-
run!(args.clone(), test_visitor).unwrap();
193+
run!(args, test_visitor).unwrap();
194194
run!(args, test_mut_visitor).unwrap();
195195
}
196196

0 commit comments

Comments
 (0)