Skip to content

Commit 77e90f1

Browse files
committed
Sync from rust 539402c
2 parents ffd6fdd + 56e6380 commit 77e90f1

File tree

9 files changed

+45
-46
lines changed

9 files changed

+45
-46
lines changed

src/abi/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub(crate) fn get_function_name_and_sig<'tcx>(
216216
assert!(!inst.substs.needs_infer());
217217
let fn_sig = tcx.normalize_erasing_late_bound_regions(
218218
ParamEnv::reveal_all(),
219-
&fn_sig_for_fn_abi(tcx, inst),
219+
fn_sig_for_fn_abi(tcx, inst),
220220
);
221221
if fn_sig.c_variadic && !support_vararg {
222222
tcx.sess.span_fatal(
@@ -372,7 +372,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(
372372
.mir
373373
.args_iter()
374374
.map(|local| {
375-
let arg_ty = fx.monomorphize(&fx.mir.local_decls[local].ty);
375+
let arg_ty = fx.monomorphize(fx.mir.local_decls[local].ty);
376376

377377
// Adapted from https://github.com/rust-lang/rust/blob/145155dc96757002c7b2e9de8489416e2fdbbd57/src/librustc_codegen_llvm/mir/mod.rs#L442-L482
378378
if Some(local) == fx.mir.spread_arg {
@@ -470,7 +470,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(
470470
}
471471

472472
for local in fx.mir.vars_and_temps_iter() {
473-
let ty = fx.monomorphize(&fx.mir.local_decls[local].ty);
473+
let ty = fx.monomorphize(fx.mir.local_decls[local].ty);
474474
let layout = fx.layout_of(ty);
475475

476476
let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa;
@@ -492,10 +492,10 @@ pub(crate) fn codegen_terminator_call<'tcx>(
492492
args: &[Operand<'tcx>],
493493
destination: Option<(Place<'tcx>, BasicBlock)>,
494494
) {
495-
let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx));
495+
let fn_ty = fx.monomorphize(func.ty(fx.mir, fx.tcx));
496496
let fn_sig = fx
497497
.tcx
498-
.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx));
498+
.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), fn_ty.fn_sig(fx.tcx));
499499

500500
let destination = destination.map(|(place, bb)| (codegen_place(fx, place), bb));
501501

@@ -711,7 +711,7 @@ pub(crate) fn codegen_drop<'tcx>(
711711
let drop_fn_ty = drop_fn.ty(fx.tcx, ParamEnv::reveal_all());
712712
let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(
713713
ParamEnv::reveal_all(),
714-
&drop_fn_ty.fn_sig(fx.tcx),
714+
drop_fn_ty.fn_sig(fx.tcx),
715715
);
716716
assert_eq!(fn_sig.output(), fx.tcx.mk_unit());
717717

src/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Module>) -> IndexVec<Local, S
1717
.local_decls
1818
.iter()
1919
.map(|local_decl| {
20-
let ty = fx.monomorphize(&local_decl.ty);
20+
let ty = fx.monomorphize(local_decl.ty);
2121
if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() {
2222
SsaKind::Ssa
2323
} else {

src/base.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -449,43 +449,43 @@ fn codegen_stmt<'tcx>(
449449
StatementKind::Assign(to_place_and_rval) => {
450450
let lval = codegen_place(fx, to_place_and_rval.0);
451451
let dest_layout = lval.layout();
452-
match &to_place_and_rval.1 {
453-
Rvalue::Use(operand) => {
452+
match to_place_and_rval.1 {
453+
Rvalue::Use(ref operand) => {
454454
let val = codegen_operand(fx, operand);
455455
lval.write_cvalue(fx, val);
456456
}
457457
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
458-
let place = codegen_place(fx, *place);
458+
let place = codegen_place(fx, place);
459459
let ref_ = place.place_ref(fx, lval.layout());
460460
lval.write_cvalue(fx, ref_);
461461
}
462462
Rvalue::ThreadLocalRef(def_id) => {
463-
let val = crate::constant::codegen_tls_ref(fx, *def_id, lval.layout());
463+
let val = crate::constant::codegen_tls_ref(fx, def_id, lval.layout());
464464
lval.write_cvalue(fx, val);
465465
}
466-
Rvalue::BinaryOp(bin_op, lhs, rhs) => {
466+
Rvalue::BinaryOp(bin_op, ref lhs, ref rhs) => {
467467
let lhs = codegen_operand(fx, lhs);
468468
let rhs = codegen_operand(fx, rhs);
469469

470-
let res = crate::num::codegen_binop(fx, *bin_op, lhs, rhs);
470+
let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs);
471471
lval.write_cvalue(fx, res);
472472
}
473-
Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => {
473+
Rvalue::CheckedBinaryOp(bin_op, ref lhs, ref rhs) => {
474474
let lhs = codegen_operand(fx, lhs);
475475
let rhs = codegen_operand(fx, rhs);
476476

477477
let res = if !fx.tcx.sess.overflow_checks() {
478478
let val =
479-
crate::num::codegen_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx);
479+
crate::num::codegen_int_binop(fx, bin_op, lhs, rhs).load_scalar(fx);
480480
let is_overflow = fx.bcx.ins().iconst(types::I8, 0);
481481
CValue::by_val_pair(val, is_overflow, lval.layout())
482482
} else {
483-
crate::num::codegen_checked_int_binop(fx, *bin_op, lhs, rhs)
483+
crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs)
484484
};
485485

486486
lval.write_cvalue(fx, res);
487487
}
488-
Rvalue::UnaryOp(un_op, operand) => {
488+
Rvalue::UnaryOp(un_op, ref operand) => {
489489
let operand = codegen_operand(fx, operand);
490490
let layout = operand.layout();
491491
let val = operand.load_scalar(fx);
@@ -514,8 +514,8 @@ fn codegen_stmt<'tcx>(
514514
};
515515
lval.write_cvalue(fx, res);
516516
}
517-
Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, to_ty) => {
518-
let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx));
517+
Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), ref operand, to_ty) => {
518+
let from_ty = fx.monomorphize(operand.ty(&fx.mir.local_decls, fx.tcx));
519519
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
520520
match *from_ty.kind() {
521521
ty::FnDef(def_id, substs) => {
@@ -535,14 +535,14 @@ fn codegen_stmt<'tcx>(
535535
_ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", from_ty),
536536
}
537537
}
538-
Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), operand, to_ty)
539-
| Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, to_ty)
540-
| Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, to_ty) => {
538+
Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), ref operand, to_ty)
539+
| Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), ref operand, to_ty)
540+
| Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), ref operand, to_ty) => {
541541
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
542542
let operand = codegen_operand(fx, operand);
543543
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
544544
}
545-
Rvalue::Cast(CastKind::Misc, operand, to_ty) => {
545+
Rvalue::Cast(CastKind::Misc, ref operand, to_ty) => {
546546
let operand = codegen_operand(fx, operand);
547547
let from_ty = operand.layout().ty;
548548
let to_ty = fx.monomorphize(to_ty);
@@ -582,12 +582,12 @@ fn codegen_stmt<'tcx>(
582582

583583
use rustc_target::abi::{Int, TagEncoding, Variants};
584584

585-
match &operand.layout().variants {
585+
match operand.layout().variants {
586586
Variants::Single { index } => {
587587
let discr = operand
588588
.layout()
589589
.ty
590-
.discriminant_for_variant(fx.tcx, *index)
590+
.discriminant_for_variant(fx.tcx, index)
591591
.unwrap();
592592
let discr = if discr.ty.is_signed() {
593593
fx.layout_of(discr.ty).size.sign_extend(discr.val)
@@ -600,7 +600,7 @@ fn codegen_stmt<'tcx>(
600600
lval.write_cvalue(fx, discr);
601601
}
602602
Variants::Multiple {
603-
tag,
603+
ref tag,
604604
tag_field,
605605
tag_encoding: TagEncoding::Direct,
606606
variants: _,
@@ -609,7 +609,7 @@ fn codegen_stmt<'tcx>(
609609

610610
// Read the tag/niche-encoded discriminant from memory.
611611
let encoded_discr =
612-
operand.value_field(fx, mir::Field::new(*tag_field));
612+
operand.value_field(fx, mir::Field::new(tag_field));
613613
let encoded_discr = encoded_discr.load_scalar(fx);
614614

615615
// Decode the discriminant (specifically if it's niche-encoded).
@@ -639,7 +639,7 @@ fn codegen_stmt<'tcx>(
639639
}
640640
Rvalue::Cast(
641641
CastKind::Pointer(PointerCast::ClosureFnPointer(_)),
642-
operand,
642+
ref operand,
643643
_to_ty,
644644
) => {
645645
let operand = codegen_operand(fx, operand);
@@ -659,18 +659,18 @@ fn codegen_stmt<'tcx>(
659659
_ => bug!("{} cannot be cast to a fn ptr", operand.layout().ty),
660660
}
661661
}
662-
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _to_ty) => {
662+
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), ref operand, _to_ty) => {
663663
let operand = codegen_operand(fx, operand);
664664
operand.unsize_value(fx, lval);
665665
}
666666
Rvalue::Discriminant(place) => {
667-
let place = codegen_place(fx, *place);
667+
let place = codegen_place(fx, place);
668668
let value = place.to_cvalue(fx);
669669
let discr =
670670
crate::discriminant::codegen_get_discriminant(fx, value, dest_layout);
671671
lval.write_cvalue(fx, discr);
672672
}
673-
Rvalue::Repeat(operand, times) => {
673+
Rvalue::Repeat(ref operand, times) => {
674674
let operand = codegen_operand(fx, operand);
675675
let times = fx
676676
.monomorphize(times)
@@ -709,7 +709,7 @@ fn codegen_stmt<'tcx>(
709709
}
710710
}
711711
Rvalue::Len(place) => {
712-
let place = codegen_place(fx, *place);
712+
let place = codegen_place(fx, place);
713713
let usize_layout = fx.layout_of(fx.tcx.types.usize);
714714
let len = codegen_array_len(fx, place);
715715
lval.write_cvalue(fx, CValue::by_val(len, usize_layout));
@@ -754,7 +754,7 @@ fn codegen_stmt<'tcx>(
754754
CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), ty_size.into());
755755
lval.write_cvalue(fx, val);
756756
}
757-
Rvalue::Aggregate(kind, operands) => match **kind {
757+
Rvalue::Aggregate(ref kind, ref operands) => match kind.as_ref() {
758758
AggregateKind::Array(_ty) => {
759759
for (i, operand) in operands.iter().enumerate() {
760760
let operand = codegen_operand(fx, operand);
@@ -882,8 +882,7 @@ fn codegen_array_len<'tcx>(
882882
match *place.layout().ty.kind() {
883883
ty::Array(_elem_ty, len) => {
884884
let len = fx
885-
.monomorphize(&len)
886-
.eval(fx.tcx, ParamEnv::reveal_all())
885+
.monomorphize(len)
887886
.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64;
888887
fx.bcx.ins().iconst(fx.pointer_type, len)
889888
}

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl<'tcx, M: Module> HasTargetSpec for FunctionCx<'_, 'tcx, M> {
357357
}
358358

359359
impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> {
360-
pub(crate) fn monomorphize<T>(&self, value: &T) -> T
360+
pub(crate) fn monomorphize<T>(&self, value: T) -> T
361361
where
362362
T: TypeFoldable<'tcx> + Copy,
363363
{

src/constant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl ConstantCx {
3838

3939
pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Module>) {
4040
for constant in &fx.mir.required_consts {
41-
let const_ = fx.monomorphize(&constant.literal);
41+
let const_ = fx.monomorphize(constant.literal);
4242
match const_.val {
4343
ConstKind::Value(_) => {}
4444
ConstKind::Unevaluated(def, ref substs, promoted) => {
@@ -110,7 +110,7 @@ pub(crate) fn codegen_constant<'tcx>(
110110
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
111111
constant: &Constant<'tcx>,
112112
) -> CValue<'tcx> {
113-
let const_ = fx.monomorphize(&constant.literal);
113+
let const_ = fx.monomorphize(constant.literal);
114114
let const_val = match const_.val {
115115
ConstKind::Value(const_val) => const_val,
116116
ConstKind::Unevaluated(def, ref substs, promoted) if fx.tcx.is_static(def.did) => {
@@ -461,7 +461,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
461461
match operand {
462462
Operand::Copy(_) | Operand::Move(_) => None,
463463
Operand::Constant(const_) => Some(
464-
fx.monomorphize(&const_.literal)
464+
fx.monomorphize(const_.literal)
465465
.eval(fx.tcx, ParamEnv::reveal_all()),
466466
),
467467
}

src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl<'tcx> DebugContext<'tcx> {
365365
let ty = self.tcx.subst_and_normalize_erasing_regions(
366366
instance.substs,
367367
ty::ParamEnv::reveal_all(),
368-
&mir.local_decls[local].ty,
368+
mir.local_decls[local].ty,
369369
);
370370
let var_id = self.define_local(entry_id, format!("{:?}", local), ty);
371371

src/main_shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(crate) fn maybe_create_entry_wrapper(
5050
// late-bound regions, since late-bound
5151
// regions must appear in the argument
5252
// listing.
53-
let main_ret_ty = tcx.erase_regions(&main_ret_ty.no_bound_vars().unwrap());
53+
let main_ret_ty = tcx.erase_regions(main_ret_ty.no_bound_vars().unwrap());
5454

5555
let cmain_sig = Signature {
5656
params: vec![

src/pretty_clif.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl CommentWriter {
8080
"sig {:?}",
8181
tcx.normalize_erasing_late_bound_regions(
8282
ParamEnv::reveal_all(),
83-
&crate::abi::fn_sig_for_fn_abi(tcx, instance)
83+
crate::abi::fn_sig_for_fn_abi(tcx, instance)
8484
)
8585
),
8686
String::new(),

src/value_and_place.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl<'tcx> CPlace<'tcx> {
455455
from_ty: Ty<'tcx>,
456456
to_ty: Ty<'tcx>,
457457
) {
458-
match (&from_ty.kind(), &to_ty.kind()) {
458+
match (from_ty.kind(), to_ty.kind()) {
459459
(ty::Ref(_, a, _), ty::Ref(_, b, _))
460460
| (
461461
ty::RawPtr(TypeAndMut { ty: a, mutbl: _ }),
@@ -466,11 +466,11 @@ impl<'tcx> CPlace<'tcx> {
466466
(ty::FnPtr(_), ty::FnPtr(_)) => {
467467
let from_sig = fx.tcx.normalize_erasing_late_bound_regions(
468468
ParamEnv::reveal_all(),
469-
&from_ty.fn_sig(fx.tcx),
469+
from_ty.fn_sig(fx.tcx),
470470
);
471471
let to_sig = fx.tcx.normalize_erasing_late_bound_regions(
472472
ParamEnv::reveal_all(),
473-
&to_ty.fn_sig(fx.tcx),
473+
to_ty.fn_sig(fx.tcx),
474474
);
475475
assert_eq!(
476476
from_sig, to_sig,
@@ -479,7 +479,7 @@ impl<'tcx> CPlace<'tcx> {
479479
);
480480
// fn(&T) -> for<'l> fn(&'l T) is allowed
481481
}
482-
(ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => {
482+
(&ty::Dynamic(from_traits, _), &ty::Dynamic(to_traits, _)) => {
483483
let from_traits = fx
484484
.tcx
485485
.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), from_traits);

0 commit comments

Comments
 (0)