]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_mir_build/build/matches/test.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / src / librustc_mir_build / build / matches / test.rs
index d23a2708dc478d2a2bdaf7a101e810757734886b..3e7bfc7d59b9b58d416c1da4368430fb5b660dab 100644 (file)
@@ -9,14 +9,14 @@ use crate::build::matches::{Candidate, MatchPair, Test, TestKind};
 use crate::build::Builder;
 use crate::hair::pattern::compare_const_vals;
 use crate::hair::*;
-use rustc::mir::*;
-use rustc::ty::layout::VariantIdx;
-use rustc::ty::util::IntTypeExt;
-use rustc::ty::{self, adjustment::PointerCast, Ty};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_hir::RangeEnd;
 use rustc_index::bit_set::BitSet;
+use rustc_middle::mir::*;
+use rustc_middle::ty::util::IntTypeExt;
+use rustc_middle::ty::{self, adjustment::PointerCast, Ty};
 use rustc_span::symbol::sym;
+use rustc_target::abi::VariantIdx;
 
 use std::cmp::Ordering;
 
@@ -202,7 +202,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 );
                 let discr_ty = adt_def.repr.discr_type().to_ty(tcx);
                 let discr = self.temp(discr_ty, test.span);
-                self.cfg.push_assign(block, source_info, &discr, Rvalue::Discriminant(place));
+                self.cfg.push_assign(block, source_info, discr, Rvalue::Discriminant(place));
                 assert_eq!(values.len() + 1, targets.len());
                 self.cfg.terminate(
                     block,
@@ -303,7 +303,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 let actual = self.temp(usize_ty, test.span);
 
                 // actual = len(place)
-                self.cfg.push_assign(block, source_info, &actual, Rvalue::Len(place));
+                self.cfg.push_assign(block, source_info, actual, Rvalue::Len(place));
 
                 // expected = <N>
                 let expected = self.push_usize(block, source_info, len);
@@ -342,7 +342,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         let result = self.temp(bool_ty, source_info.span);
 
         // result = op(left, right)
-        self.cfg.push_assign(block, source_info, &result, Rvalue::BinaryOp(op, left, right));
+        self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, left, right));
 
         // branch based on result
         self.cfg.terminate(
@@ -362,7 +362,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         place: Place<'tcx>,
         mut ty: Ty<'tcx>,
     ) {
-        use rustc::middle::lang_items::EqTraitLangItem;
+        use rustc_hir::lang_items::EqTraitLangItem;
 
         let mut expect = self.literal_operand(source_info.span, value);
         let mut val = Operand::Copy(place);
@@ -394,7 +394,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     self.cfg.push_assign(
                         block,
                         source_info,
-                        &temp,
+                        temp,
                         Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), val, ty),
                     );
                     val = Operand::Move(temp);
@@ -404,7 +404,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     self.cfg.push_assign(
                         block,
                         source_info,
-                        &slice,
+                        slice,
                         Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), expect, ty),
                     );
                     expect = Operand::Move(slice);
@@ -443,6 +443,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 destination: Some((eq_result, eq_block)),
                 cleanup: Some(cleanup),
                 from_hir_call: false,
+                fn_span: source_info.span
             },
         );
 
@@ -582,7 +583,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                         // enough elements.
                         Some(1)
                     }
-                    (Ordering::Equal, &Some(_)) | (Ordering::Greater, &Some(_)) => {
+                    (Ordering::Equal | Ordering::Greater, &Some(_)) => {
                         // This can match both if $actual_len = test_len >= pat_len,
                         // and if $actual_len > test_len. We can't advance.
                         None
@@ -681,7 +682,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
             (&TestKind::Range { .. }, _) => None,
 
-            (&TestKind::Eq { .. }, _) | (&TestKind::Len { .. }, _) => {
+            (&TestKind::Eq { .. } | &TestKind::Len { .. }, _) => {
                 // These are all binary tests.
                 //
                 // FIXME(#29623) we can be more clever here