]> git.lizzy.rs Git - rust.git/commitdiff
review comments: clean up
authorEsteban Küber <esteban@kuber.com.ar>
Sun, 4 Aug 2019 16:44:06 +0000 (09:44 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 4 Aug 2019 17:42:46 +0000 (10:42 -0700)
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_ssa/mir/analyze.rs
src/librustc_codegen_ssa/mir/rvalue.rs
src/librustc_target/abi/mod.rs

index 18d82c27d8cc93eb52f9f324cf67f862228fdc1c..ee8f1843c1a820d7efedaa1cf4a29ed96142f418 100644 (file)
@@ -30,7 +30,7 @@
 use std::str;
 use std::sync::Arc;
 use syntax::symbol::LocalInternedString;
-use syntax::source_map::Span;
+use syntax::source_map::{DUMMY_SP, Span};
 use crate::abi::Abi;
 
 /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
@@ -861,10 +861,10 @@ impl LayoutOf for CodegenCx<'ll, 'tcx> {
     type TyLayout = TyLayout<'tcx>;
 
     fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
-        self.spanned_layout_of(ty, None)
+        self.spanned_layout_of(ty, DUMMY_SP)
     }
 
-    fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Option<Span>) -> Self::TyLayout {
+    fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout {
         self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
             .unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e {
                 match span {
index 1ce3dbc4fe3b6587a71f83d30a4422f331d6dd43..5dc050cbb3672e75ee669cba33e612d0ea7b554c 100644 (file)
@@ -182,18 +182,13 @@ fn visit_assign(&mut self,
                     rvalue: &mir::Rvalue<'tcx>,
                     location: Location) {
         debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
-        let mut decl_span = None;
-        if let mir::PlaceBase::Local(local) = &place.base {
-            if let Some(decl) = self.fx.mir.local_decls.get(*local) {
-                decl_span = Some(decl.source_info.span);
-            }
-        }
 
         if let mir::Place {
             base: mir::PlaceBase::Local(index),
             projection: None,
         } = *place {
             self.assign(index, location);
+            let decl_span = self.fx.mir.local_decls[index].source_info.span;
             if !self.fx.rvalue_creates_operand(rvalue, decl_span) {
                 self.not_ssa(index);
             }
index 4df45d1586086ae3368ca7f2831412a901ec0691..29a97894bdca9c97bc050055b23bb9ca0b1ea47f 100644 (file)
@@ -6,7 +6,7 @@
 use rustc_apfloat::{ieee, Float, Status, Round};
 use std::{u128, i128};
 use syntax::symbol::sym;
-use syntax::source_map::Span;
+use syntax::source_map::{DUMMY_SP, Span};
 
 use crate::base;
 use crate::MemFlags;
@@ -137,7 +137,7 @@ pub fn codegen_rvalue(
             }
 
             _ => {
-                assert!(self.rvalue_creates_operand(rvalue, None));
+                assert!(self.rvalue_creates_operand(rvalue, DUMMY_SP));
                 let (mut bx, temp) = self.codegen_rvalue_operand(bx, rvalue);
                 temp.val.store(&mut bx, dest);
                 bx
@@ -171,7 +171,7 @@ pub fn codegen_rvalue_operand(
         rvalue: &mir::Rvalue<'tcx>
     ) -> (Bx, OperandRef<'tcx, Bx::Value>) {
         assert!(
-            self.rvalue_creates_operand(rvalue, None),
+            self.rvalue_creates_operand(rvalue, DUMMY_SP),
             "cannot codegen {:?} to operand",
             rvalue,
         );
@@ -696,7 +696,7 @@ pub fn codegen_scalar_checked_binop(
 }
 
 impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
-    pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Option<Span>) -> bool {
+    pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
         match *rvalue {
             mir::Rvalue::Ref(..) |
             mir::Rvalue::Len(..) |
index 4f53c7795c2be0652aa2584e2feaf4f07d3c548e..dd7ae742a63c622ed11307520a8e2e94c9a1c489 100644 (file)
@@ -1013,7 +1013,7 @@ pub trait LayoutOf {
     type TyLayout;
 
     fn layout_of(&self, ty: Self::Ty) -> Self::TyLayout;
-    fn spanned_layout_of(&self, ty: Self::Ty, _span: Option<Span>) -> Self::TyLayout {
+    fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyLayout {
         self.layout_of(ty)
     }
 }