]> git.lizzy.rs Git - rust.git/commitdiff
tweak output and tests
authorEsteban Küber <esteban@kuber.com.ar>
Sun, 4 Aug 2019 19:23:05 +0000 (12:23 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 4 Aug 2019 19:23:05 +0000 (12:23 -0700)
src/librustc/mir/interpret/error.rs
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_ssa/mir/analyze.rs
src/test/ui/consts/issue-55878.stderr
src/test/ui/huge-enum.rs
src/test/ui/huge-enum.stderr
src/test/ui/huge-struct.rs
src/test/ui/huge-struct.stderr
src/test/ui/issues/issue-56762.stderr

index fb6f74397fc4c81af712fe0add8d7e5a15a219e5..b875977658794a009f8430d35e14a4a6635ce88a 100644 (file)
@@ -165,7 +165,9 @@ fn struct_generic(
         } else {
             struct_error(tcx, message)
         };
-        err.span_label(self.span, self.error.to_string());
+        if !must_error {
+            err.span_label(self.span, self.error.to_string());
+        }
         // Skip the last, which is just the environment of the constant.  The stacktrace
         // is sometimes empty because we create "fake" eval contexts in CTFE to do work
         // on constant values.
index ee8f1843c1a820d7efedaa1cf4a29ed96142f418..a2aaaddf0931c2e4135a76d675a43a3b7ee97c30 100644 (file)
@@ -867,10 +867,7 @@ fn layout_of(&self, ty: Ty<'tcx>) -> 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 {
-                    Some(span) => self.sess().span_fatal(span, &e.to_string()),
-                    None => self.sess().fatal(&e.to_string()),
-                }
+                self.sess().span_fatal(span, &e.to_string())
             } else {
                 bug!("failed to get layout for `{}`: {}", ty, e)
             })
index 5dc050cbb3672e75ee669cba33e612d0ea7b554c..cc0c733c224103e077e92c5250a8129a1dd7b4ab 100644 (file)
@@ -9,6 +9,7 @@
 use rustc::mir::traversal;
 use rustc::ty;
 use rustc::ty::layout::{LayoutOf, HasTyCtxt};
+use syntax_pos::DUMMY_SP;
 use super::FunctionCx;
 use crate::traits::*;
 
@@ -20,10 +21,13 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
 
     analyzer.visit_body(mir);
 
-    for (index, ty) in mir.local_decls.iter().map(|l| l.ty).enumerate() {
+    for (index, (ty, span)) in mir.local_decls.iter()
+        .map(|l| (l.ty, l.source_info.span))
+        .enumerate()
+    {
         let ty = fx.monomorphize(&ty);
         debug!("local {} has type {:?}", index, ty);
-        let layout = fx.cx.layout_of(ty);
+        let layout = fx.cx.spanned_layout_of(ty, span);
         if fx.cx.is_backend_immediate(layout) {
             // These sorts of types are immediates that we can store
             // in an Value without an alloca.
@@ -93,10 +97,12 @@ fn assign(&mut self, local: mir::Local, location: Location) {
         }
     }
 
-    fn process_place(&mut self,
-                     place_ref: &mir::PlaceRef<'_, 'tcx>,
-                     context: PlaceContext,
-                     location: Location) {
+    fn process_place(
+        &mut self,
+        place_ref: &mir::PlaceRef<'_, 'tcx>,
+        context: PlaceContext,
+        location: Location,
+    ) {
         let cx = self.fx.cx;
 
         if let Some(proj) = place_ref.projection {
@@ -116,12 +122,17 @@ fn process_place(&mut self,
                     .projection_ty(cx.tcx(), &proj.elem)
                     .ty;
                 let elem_ty = self.fx.monomorphize(&elem_ty);
-                if cx.layout_of(elem_ty).is_zst() {
+                let span = if let mir::PlaceBase::Local(index) = place_ref.base {
+                    self.fx.mir.local_decls[*index].source_info.span
+                } else {
+                    DUMMY_SP
+                };
+                if cx.spanned_layout_of(elem_ty, span).is_zst() {
                     return;
                 }
 
                 if let mir::ProjectionElem::Field(..) = proj.elem {
-                    let layout = cx.layout_of(base_ty.ty);
+                    let layout = cx.spanned_layout_of(base_ty.ty, span);
                     if cx.is_backend_immediate(layout) || cx.is_backend_scalar_pair(layout) {
                         // Recurse with the same context, instead of `Projection`,
                         // potentially stopping at non-operand projections,
index 184c6d0e29293b2ad3da6e367970beb9afcbe7b9..aa4dfb719f905538f489120340708807353cdd58 100644 (file)
@@ -2,7 +2,7 @@ error[E0080]: the type `[u8; 18446744073709551615]` is too big for the current a
   --> $SRC_DIR/libcore/mem/mod.rs:LL:COL
    |
 LL |     intrinsics::size_of::<T>()
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 18446744073709551615]` is too big for the current architecture
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: $DIR/issue-55878.rs:3:26
    |
index 2492afbdc8f8180605090fe34649ea5c2315a3eb..8ac15f3156bfdf469bc4fbcc4364ce86ca09f472 100644 (file)
@@ -1,16 +1,14 @@
-// normalize-stderr-test "std::option::Option<\[u32; \d+\]>" -> "TYPE"
-// normalize-stderr-test "\[u32; \d+\]" -> "TYPE"
-
 // FIXME https://github.com/rust-lang/rust/issues/59774
 // normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
 // normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
 
 #[cfg(target_pointer_width = "32")]
-fn main() {
-    let big: Option<[u32; (1<<29)-1]> = None;
-}
+type BIG = Option<[u32; (1<<29)-1]>;
 
 #[cfg(target_pointer_width = "64")]
+type BIG = Option<[u32; (1<<45)-1]>;
+
 fn main() {
-    let big: Option<[u32; (1<<45)-1]> = None;
+    let big: BIG = None;
+    //~^ ERROR is too big for the current architecture
 }
index 67cae3d52ed2dd998bfeadf009438945d9c8f234..94349f475e9be5be260786ecae50985d74cd0811 100644 (file)
@@ -1,4 +1,8 @@
-error: the type `TYPE` is too big for the current architecture
+error: the type `std::option::Option<[u32; 35184372088831]>` is too big for the current architecture
+  --> $DIR/huge-enum.rs:12:9
+   |
+LL |     let big: BIG = None;
+   |         ^^^
 
 error: aborting due to previous error
 
index dc7d75a6f028ea12a592c6543f39351ff6409f30..e120cae7fdd148a822c2b6855de49206d6bb716f 100644 (file)
@@ -47,4 +47,6 @@ struct S1M<T> { val: S1k<S1k<T>> }
 
 fn main() {
     let fat: Option<S1M<S1M<S1M<u32>>>> = None;
+    //~^ ERROR the type `S32<S1M<S1M<u32>>>` is too big for the current architecture
+
 }
index 06b084bdc3a391cb554c96f7907a4602021c8f5f..5c2140df481262a1ca1e7637d5b9992b825c7619 100644 (file)
@@ -1,4 +1,8 @@
 error: the type `SXX<SXX<SXX<u32>>>` is too big for the current architecture
+  --> $DIR/huge-struct.rs:49:9
+   |
+LL |     let fat: Option<SXX<SXX<SXX<u32>>>> = None;
+   |         ^^^
 
 error: aborting due to previous error
 
index e74904f1f68181d75b7115f0e986c442a926012b..69626d4bc7a9e73b0090597f1f1c9ee25d51daea 100644 (file)
@@ -2,13 +2,13 @@ error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current ar
   --> $DIR/issue-56762.rs:19:1
    |
 LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture
   --> $DIR/issue-56762.rs:21:1
    |
 LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors