]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/monomorphize.rs
rollup merge of #20707: nikomatsakis/issue-20582
[rust.git] / src / librustc_trans / trans / monomorphize.rs
index a35bae07da09a647034e309114b98f861bf16cb3..93076260349abd5c81aee5d5801823a800ec4a2d 100644 (file)
@@ -32,7 +32,7 @@
 use syntax::ast_util::{local_def, PostExpansionMethod};
 use syntax::attr;
 use syntax::codemap::DUMMY_SP;
-use std::hash::{sip, Hash};
+use std::hash::{Hasher, Hash, SipHasher};
 
 pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                 fn_id: ast::DefId,
@@ -125,13 +125,13 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
     let hash;
     let s = {
-        let mut state = sip::SipState::new();
+        let mut state = SipHasher::new();
         hash_id.hash(&mut state);
         mono_ty.hash(&mut state);
 
-        hash = format!("h{}", state.result());
+        hash = format!("h{}", state.finish());
         ccx.tcx().map.with_path(fn_id.node, |path| {
-            exported_name(path, hash.index(&FullRange))
+            exported_name(path, &hash[])
         })
     };
 
@@ -141,9 +141,9 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     let mut hash_id = Some(hash_id);
     let mut mk_lldecl = |&mut : abi: abi::Abi| {
         let lldecl = if abi != abi::Rust {
-            foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, s.index(&FullRange))
+            foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, &s[])
         } else {
-            decl_internal_rust_fn(ccx, mono_ty, s.index(&FullRange))
+            decl_internal_rust_fn(ccx, mono_ty, &s[])
         };
 
         ccx.monomorphized().borrow_mut().insert(hash_id.take().unwrap(), lldecl);
@@ -177,12 +177,12 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                   ..
               } => {
                   let d = mk_lldecl(abi);
-                  let needs_body = setup_lldecl(d, i.attrs.index(&FullRange));
+                  let needs_body = setup_lldecl(d, &i.attrs[]);
                   if needs_body {
                       if abi != abi::Rust {
                           foreign::trans_rust_fn_with_foreign_abi(
                               ccx, &**decl, &**body, &[], d, psubsts, fn_id.node,
-                              Some(hash.index(&FullRange)));
+                              Some(&hash[]));
                       } else {
                           trans_fn(ccx, &**decl, &**body, d, psubsts, fn_id.node, &[]);
                       }
@@ -206,7 +206,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                     trans_enum_variant(ccx,
                                        parent,
                                        &*v,
-                                       args.index(&FullRange),
+                                       &args[],
                                        this_tv.disr_val,
                                        psubsts,
                                        d);
@@ -220,7 +220,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             match *ii {
                 ast::MethodImplItem(ref mth) => {
                     let d = mk_lldecl(abi::Rust);
-                    let needs_body = setup_lldecl(d, mth.attrs.index(&FullRange));
+                    let needs_body = setup_lldecl(d, &mth.attrs[]);
                     if needs_body {
                         trans_fn(ccx,
                                  mth.pe_fn_decl(),
@@ -241,7 +241,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             match *method {
                 ast::ProvidedMethod(ref mth) => {
                     let d = mk_lldecl(abi::Rust);
-                    let needs_body = setup_lldecl(d, mth.attrs.index(&FullRange));
+                    let needs_body = setup_lldecl(d, &mth.attrs[]);
                     if needs_body {
                         trans_fn(ccx, mth.pe_fn_decl(), mth.pe_body(), d,
                                  psubsts, mth.id, &[]);
@@ -249,8 +249,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                     d
                 }
                 _ => {
-                    ccx.sess().bug(format!("can't monomorphize a {:?}",
-                                           map_node).index(&FullRange))
+                    ccx.sess().bug(&format!("can't monomorphize a {:?}",
+                                           map_node)[])
                 }
             }
         }
@@ -258,7 +258,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             let d = mk_lldecl(abi::Rust);
             set_inline_hint(d);
             base::trans_tuple_struct(ccx,
-                                     struct_def.fields.index(&FullRange),
+                                     &struct_def.fields[],
                                      struct_def.ctor_id.expect("ast-mapped tuple struct \
                                                                 didn't have a ctor id"),
                                      psubsts,
@@ -275,8 +275,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         ast_map::NodeBlock(..) |
         ast_map::NodePat(..) |
         ast_map::NodeLocal(..) => {
-            ccx.sess().bug(format!("can't monomorphize a {:?}",
-                                   map_node).index(&FullRange))
+            ccx.sess().bug(&format!("can't monomorphize a {:?}",
+                                   map_node)[])
         }
     };
 
@@ -300,8 +300,6 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>,
                                   -> T
     where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone
 {
-    assert!(param_substs.regions.is_erased());
-
     let substituted = value.subst(tcx, param_substs);
     normalize_associated_type(tcx, &substituted)
 }