]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/common.rs
rollup merge of #20707: nikomatsakis/issue-20582
[rust.git] / src / librustc_trans / trans / common.rs
index 017593f387e234f6f34f4ee528b797e6cdd1eceb..ab5b563b99c7259ada392acf0ac6b1e427515d45 100644 (file)
@@ -50,7 +50,7 @@
 use syntax::ast::Ident;
 use syntax::ast;
 use syntax::ast_map::{PathElem, PathName};
-use syntax::codemap::Span;
+use syntax::codemap::{DUMMY_SP, Span};
 use syntax::parse::token::InternedString;
 use syntax::parse::token;
 use util::common::memoized;
@@ -118,8 +118,9 @@ fn fold_substs(&mut self,
 }
 
 // Is the type's representation size known at compile time?
-pub fn type_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
-ty::type_contents(cx, ty).is_sized(cx)
+pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
+    let param_env = ty::empty_parameter_environment(tcx);
+    ty::type_is_sized(&param_env, DUMMY_SP, ty)
 }
 
 pub fn lltype_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
@@ -277,7 +278,7 @@ pub fn gensym_name(name: &str) -> PathElem {
 let num = token::gensym(name).uint();
 // use one colon which will get translated to a period by the mangler, and
 // we're guaranteed that `num` is globally unique for this crate.
-PathName(token::gensym(format!("{}:{}", name, num).index(&FullRange)))
+PathName(token::gensym(&format!("{}:{}", name, num)[]))
 }
 
 #[derive(Copy)]
@@ -604,8 +605,8 @@ pub fn def(&self, nid: ast::NodeId) -> def::Def {
     match self.tcx().def_map.borrow().get(&nid) {
         Some(v) => v.clone(),
         None => {
-            self.tcx().sess.bug(format!(
-                "no def associated with node id {}", nid).index(&FullRange));
+            self.tcx().sess.bug(&format!(
+                "no def associated with node id {}", nid)[]);
         }
     }
 }
@@ -1033,9 +1034,9 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     Err(e) => {
         tcx.sess.span_bug(
             span,
-            format!("Encountered error `{}` selecting `{}` during trans",
+            &format!("Encountered error `{}` selecting `{}` during trans",
                     e.repr(tcx),
-                    trait_ref.repr(tcx)).index(&FullRange))
+                    trait_ref.repr(tcx))[])
     }
 };
 
@@ -1127,8 +1128,8 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(span: Span,
         } else {
             infcx.tcx.sess.span_bug(
                 span,
-                format!("Encountered errors `{}` fulfilling during trans",
-                        errors.repr(infcx.tcx)).index(&FullRange));
+                &format!("Encountered errors `{}` fulfilling during trans",
+                        errors.repr(infcx.tcx))[]);
         }
     }
 }
@@ -1167,8 +1168,8 @@ pub fn node_id_substs<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 };
 
 if substs.types.any(|t| ty::type_needs_infer(*t)) {
-        tcx.sess.bug(format!("type parameters for node {:?} include inference types: {:?}",
-                             node, substs.repr(tcx)).index(&FullRange));
+        tcx.sess.bug(&format!("type parameters for node {:?} include inference types: {:?}",
+                             node, substs.repr(tcx))[]);
     }
 
     monomorphize::apply_param_substs(tcx,
@@ -1186,8 +1187,8 @@ pub fn langcall(bcx: Block,
         Err(s) => {
             let msg = format!("{} {}", msg, s);
             match span {
-                Some(span) => bcx.tcx().sess.span_fatal(span, msg.index(&FullRange)),
-                None => bcx.tcx().sess.fatal(msg.index(&FullRange)),
+                Some(span) => bcx.tcx().sess.span_fatal(span, &msg[]),
+                None => bcx.tcx().sess.fatal(&msg[]),
             }
         }
     }