Skip to content

Commit fc18f42

Browse files
committed
[tiny] remove unecessary .into() calls
While working on #129249, encountered these cases in the codebase of calling `.into()` unecessarily. Splitting them out so that they can land independently of the lint.
1 parent 6bdf430 commit fc18f42

18 files changed

Lines changed: 31 additions & 42 deletions

File tree

compiler/rustc_builtin_macros/src/format_foreign/shell/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn test_escape() {
2222
fn test_parse() {
2323
macro_rules! assert_pns_eq_sub {
2424
($in_:expr, $kind:ident($arg:expr, $pos:expr)) => {
25-
assert_eq!(pns(concat!($in_, "!")), Some((S::$kind($arg.into(), $pos), "!")))
25+
assert_eq!(pns(concat!($in_, "!")), Some((S::$kind($arg, $pos), "!")))
2626
};
2727
}
2828

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'tcx> InferCtxt<'tcx> {
286286
(GenericArgKind::Lifetime(v_o), GenericArgKind::Lifetime(v_r)) => {
287287
if v_o != v_r {
288288
output_query_region_constraints.constraints.push((
289-
ty::RegionEqPredicate(v_o.into(), v_r).into(),
289+
ty::RegionEqPredicate(v_o, v_r).into(),
290290
constraint_category,
291291
ty::VisibleForLeakCheck::Yes,
292292
));

compiler/rustc_middle/src/mir/interpret/queries.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,12 @@ impl<'tcx> TyCtxt<'tcx> {
107107
Ok(Some(instance)) => GlobalId { instance, promoted: None },
108108
// For errors during resolution, we deliberately do not point at the usage site of the constant,
109109
// since for these errors the place the constant is used shouldn't matter.
110-
Ok(None) => return Err(ErrorHandled::TooGeneric(DUMMY_SP).into()),
110+
Ok(None) => return Err(ErrorHandled::TooGeneric(DUMMY_SP)),
111111
Err(err) => {
112112
return Err(ErrorHandled::Reported(
113113
ReportedErrorInfo::non_const_eval_error(err),
114114
DUMMY_SP,
115-
)
116-
.into());
115+
));
117116
}
118117
};
119118

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ impl<'tcx> TypingEnv<'tcx> {
10981098
def_id: impl IntoQueryKey<DefId>,
10991099
) -> TypingEnv<'tcx> {
11001100
let def_id = def_id.into_query_key();
1101-
Self::new(tcx.param_env(def_id), TypingMode::non_body_analysis().into())
1101+
Self::new(tcx.param_env(def_id), TypingMode::non_body_analysis())
11021102
}
11031103

11041104
pub fn post_analysis(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryKey<DefId>) -> TypingEnv<'tcx> {

compiler/rustc_mir_build/src/builder/expr/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
914914
block,
915915
source_info,
916916
destination,
917-
Rvalue::Reborrow(target, mutability, place.into()),
917+
Rvalue::Reborrow(target, mutability, place),
918918
);
919919
block.unit()
920920
}

compiler/rustc_mir_transform/src/check_null.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn insert_null_check<'tcx>(
7979
source_info,
8080
StatementKind::Assign(Box::new((pointee_should_be_checked, rvalue))),
8181
));
82-
Operand::Copy(pointee_should_be_checked.into())
82+
Operand::Copy(pointee_should_be_checked)
8383
}
8484
};
8585

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ where
389389
impl_def_id,
390390
impl_args,
391391
impl_trait_ref,
392-
target_container_def_id.into(),
392+
target_container_def_id,
393393
)?;
394394

395395
if !cx.check_args_compatible(target_item_def_id.into(), target_args) {

compiler/rustc_target/src/spec/json.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl ToJson for Target {
252252
};
253253
($attr:ident, $json_name:expr) => {{
254254
let name = $json_name;
255-
d.insert(name.into(), target.$attr.to_json());
255+
d.insert(name.to_string(), target.$attr.to_json());
256256
}};
257257
}
258258

@@ -262,7 +262,7 @@ impl ToJson for Target {
262262
let name = $json_name;
263263
#[allow(rustc::bad_opt_access)]
264264
if default.$attr != target.$attr {
265-
d.insert(name.into(), target.$attr.to_json());
265+
d.insert(name.to_string(), target.$attr.to_json());
266266
}
267267
}};
268268
(link_args - $attr:ident, $json_name:expr) => {{
@@ -447,7 +447,6 @@ impl schemars::JsonSchema for EndianWrapper {
447447
"type": "string",
448448
"enum": ["big", "little"]
449449
})
450-
.into()
451450
}
452451
}
453452

@@ -473,7 +472,6 @@ impl schemars::JsonSchema for ExternAbiWrapper {
473472
"type": "string",
474473
"enum": all,
475474
})
476-
.into()
477475
}
478476
}
479477

compiler/rustc_target/src/spec/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ impl schemars::JsonSchema for LinkerFlavorCli {
522522
"type": "string",
523523
"enum": all
524524
})
525-
.into()
526525
}
527526
}
528527

@@ -587,7 +586,6 @@ impl schemars::JsonSchema for LinkSelfContainedDefault {
587586
"type": "string",
588587
"enum": ["false", "true", "wasm", "musl", "mingw"]
589588
})
590-
.into()
591589
}
592590
}
593591

@@ -733,7 +731,6 @@ impl schemars::JsonSchema for LinkSelfContainedComponents {
733731
"type": "string",
734732
"enum": all,
735733
})
736-
.into()
737734
}
738735
}
739736

@@ -912,7 +909,6 @@ impl schemars::JsonSchema for SmallDataThresholdSupport {
912909
"type": "string",
913910
"pattern": r#"^none|default-for-arch|llvm-module-flag=.+|llvm-arg=.+$"#,
914911
})
915-
.into()
916912
}
917913
}
918914

@@ -1288,7 +1284,6 @@ impl schemars::JsonSchema for SanitizerSet {
12881284
"type": "string",
12891285
"enum": all,
12901286
})
1291-
.into()
12921287
}
12931288
}
12941289

compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,12 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
562562
// and therefore is treated as rigid.
563563
if let Some(ty::PredicateKind::AliasRelate(lhs, rhs, _)) = pred.kind().no_bound_vars() {
564564
goal.infcx().visit_proof_tree_at_depth(
565-
goal.goal().with(tcx, ty::ClauseKind::WellFormed(lhs.into())),
565+
goal.goal().with(tcx, ty::ClauseKind::WellFormed(lhs)),
566566
goal.depth() + 1,
567567
self,
568568
)?;
569569
goal.infcx().visit_proof_tree_at_depth(
570-
goal.goal().with(tcx, ty::ClauseKind::WellFormed(rhs.into())),
570+
goal.goal().with(tcx, ty::ClauseKind::WellFormed(rhs)),
571571
goal.depth() + 1,
572572
self,
573573
)?;

0 commit comments

Comments
 (0)