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

Commit 2bf93bd

Browse files
committed
compiler: fold by value
1 parent 3ec6720 commit 2bf93bd

File tree

140 files changed

+679
-699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+679
-699
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn make_mir_scope(
9292
let callee = cx.tcx.subst_and_normalize_erasing_regions(
9393
instance.substs,
9494
ty::ParamEnv::reveal_all(),
95-
&callee,
95+
callee,
9696
);
9797
let callee_fn_abi = FnAbi::of_instance(cx, callee, &[]);
9898
cx.dbg_scope_fn(callee, &callee_fn_abi, None)

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl TypeMap<'ll, 'tcx> {
189189
// something that provides more than the 64 bits of the DefaultHasher.
190190
let mut hasher = StableHasher::new();
191191
let mut hcx = cx.tcx.create_stable_hashing_context();
192-
let type_ = cx.tcx.erase_regions(&type_);
192+
let type_ = cx.tcx.erase_regions(type_);
193193
hcx.while_hashing_spans(false, |hcx| {
194194
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
195195
type_.hash_stable(hcx, &mut hasher);
@@ -427,7 +427,7 @@ fn subroutine_type_metadata(
427427
span: Span,
428428
) -> MetadataCreationResult<'ll> {
429429
let signature =
430-
cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &signature);
430+
cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), signature);
431431

432432
let signature_metadata: Vec<_> = iter::once(
433433
// return type

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
501501
let impl_self_ty = cx.tcx.subst_and_normalize_erasing_regions(
502502
instance.substs,
503503
ty::ParamEnv::reveal_all(),
504-
&cx.tcx.type_of(impl_def_id),
504+
cx.tcx.type_of(impl_def_id),
505505
);
506506

507507
// Only "class" methods are generally understood by LLVM,

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
9191
};
9292

9393
let sig = callee_ty.fn_sig(tcx);
94-
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
94+
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig);
9595
let arg_tys = sig.inputs();
9696
let ret_ty = sig.output();
9797
let name = tcx.item_name(def_id);
@@ -777,8 +777,8 @@ fn generic_simd_intrinsic(
777777
}
778778

779779
let tcx = bx.tcx();
780-
let sig = tcx
781-
.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &callee_ty.fn_sig(tcx));
780+
let sig =
781+
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx));
782782
let arg_tys = sig.inputs();
783783
let name_str = &*name.as_str();
784784

compiler/rustc_codegen_llvm/src/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
252252

253253
// Make sure lifetimes are erased, to avoid generating distinct LLVM
254254
// types for Rust types that only differ in the choice of lifetimes.
255-
let normal_ty = cx.tcx.erase_regions(&self.ty);
255+
let normal_ty = cx.tcx.erase_regions(self.ty);
256256

257257
let mut defer = None;
258258
let llty = if self.ty != normal_ty {

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
399399
// late-bound regions, since late-bound
400400
// regions must appear in the argument
401401
// listing.
402-
let main_ret_ty = cx.tcx().erase_regions(&main_ret_ty.no_bound_vars().unwrap());
402+
let main_ret_ty = cx.tcx().erase_regions(main_ret_ty.no_bound_vars().unwrap());
403403

404404
let llfn = match cx.declare_c_main(llfty) {
405405
Some(llfn) => llfn,

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ pub fn push_debuginfo_type_name<'tcx>(
120120
}
121121
ty::Dynamic(ref trait_data, ..) => {
122122
if let Some(principal) = trait_data.principal() {
123-
let principal = tcx
124-
.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &principal);
123+
let principal =
124+
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), principal);
125125
push_item_name(tcx, principal.def_id, false, output);
126126
push_type_params(tcx, principal.substs, output, visited);
127127
} else {
@@ -159,7 +159,7 @@ pub fn push_debuginfo_type_name<'tcx>(
159159

160160
output.push_str("fn(");
161161

162-
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
162+
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig);
163163
if !sig.inputs().is_empty() {
164164
for &parameter_type in sig.inputs() {
165165
push_debuginfo_type_name(tcx, parameter_type, true, output, visited);

compiler/rustc_codegen_ssa/src/mir/analyze.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
2424
analyzer.visit_body(&mir);
2525

2626
for (local, decl) in mir.local_decls.iter_enumerated() {
27-
let ty = fx.monomorphize(&decl.ty);
27+
let ty = fx.monomorphize(decl.ty);
2828
debug!("local {:?} has type `{}`", local, ty);
2929
let layout = fx.cx.spanned_layout_of(ty, decl.source_info.span);
3030
if fx.cx.is_backend_immediate(layout) {
@@ -121,10 +121,10 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
121121
if is_consume {
122122
let base_ty =
123123
mir::Place::ty_from(place_ref.local, proj_base, self.fx.mir, cx.tcx());
124-
let base_ty = self.fx.monomorphize(&base_ty);
124+
let base_ty = self.fx.monomorphize(base_ty);
125125

126126
// ZSTs don't require any actual memory access.
127-
let elem_ty = base_ty.projection_ty(cx.tcx(), self.fx.monomorphize(&elem)).ty;
127+
let elem_ty = base_ty.projection_ty(cx.tcx(), self.fx.monomorphize(elem)).ty;
128128
let span = self.fx.mir.local_decls[place_ref.local].source_info.span;
129129
if cx.spanned_layout_of(elem_ty, span).is_zst() {
130130
return;
@@ -313,7 +313,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
313313

314314
PlaceContext::MutatingUse(MutatingUseContext::Drop) => {
315315
let ty = self.fx.mir.local_decls[local].ty;
316-
let ty = self.fx.monomorphize(&ty);
316+
let ty = self.fx.monomorphize(ty);
317317

318318
// Only need the place if we're actually dropping it.
319319
if self.fx.cx.type_needs_drop(ty) {

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
306306
unwind: Option<mir::BasicBlock>,
307307
) {
308308
let ty = location.ty(self.mir, bx.tcx()).ty;
309-
let ty = self.monomorphize(&ty);
309+
let ty = self.monomorphize(ty);
310310
let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
311311

312312
if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def {
@@ -576,7 +576,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
576576
.iter()
577577
.map(|op_arg| {
578578
let op_ty = op_arg.ty(self.mir, bx.tcx());
579-
self.monomorphize(&op_ty)
579+
self.monomorphize(op_ty)
580580
})
581581
.collect::<Vec<_>>();
582582

@@ -900,7 +900,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
900900
}
901901
}
902902
mir::InlineAsmOperand::SymFn { ref value } => {
903-
let literal = self.monomorphize(&value.literal);
903+
let literal = self.monomorphize(value.literal);
904904
if let ty::FnDef(def_id, substs) = *literal.ty.kind() {
905905
let instance = ty::Instance::resolve_for_fn_ptr(
906906
bx.tcx(),

compiler/rustc_codegen_ssa/src/mir/constant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1616
constant: &mir::Constant<'tcx>,
1717
) -> Result<OperandRef<'tcx, Bx::Value>, ErrorHandled> {
1818
let val = self.eval_mir_constant(constant)?;
19-
let ty = self.monomorphize(&constant.literal.ty);
19+
let ty = self.monomorphize(constant.literal.ty);
2020
Ok(OperandRef::from_const(bx, val, ty))
2121
}
2222

2323
pub fn eval_mir_constant(
2424
&mut self,
2525
constant: &mir::Constant<'tcx>,
2626
) -> Result<ConstValue<'tcx>, ErrorHandled> {
27-
match self.monomorphize(&constant.literal).val {
27+
match self.monomorphize(constant.literal).val {
2828
ty::ConstKind::Unevaluated(def, substs, promoted) => self
2929
.cx
3030
.tcx()
@@ -83,7 +83,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
8383
.unwrap_or_else(|_| {
8484
bx.tcx().sess.span_err(span, "could not evaluate shuffle_indices at compile time");
8585
// We've errored, so we don't have to produce working code.
86-
let ty = self.monomorphize(&ty);
86+
let ty = self.monomorphize(ty);
8787
let llty = bx.backend_type(bx.layout_of(ty));
8888
(bx.const_undef(llty), ty)
8989
})

0 commit comments

Comments
 (0)