]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #55827 - ljedrz:various_stashed, r=alexcrichton
authorPietro Albini <pietro@pietroalbini.org>
Sun, 18 Nov 2018 22:24:33 +0000 (23:24 +0100)
committerGitHub <noreply@github.com>
Sun, 18 Nov 2018 22:24:33 +0000 (23:24 +0100)
A few tweaks to iterations/collecting

- simplify and speed up `dot::GraphWalk::nodes` for `cfg::CFG`
- `reserve` the capacity for `edges` in `DepGraph::query`
- collect directly to a `HirVec` in `LoweringContext::lower_attrs`
- fix overallocation in `OnDiskCache::serialize`
- preallocate the `new_partitioning` vector in `merge_codegen_units`
- simplify `impl FromHex for str`
- improve the creation of `self_arg_names` in `impl MethodDef`

1  2 
src/librustc/hir/lowering.rs
src/libsyntax_ext/deriving/generic/mod.rs

index e532b50a28b6b9d339b89423a87fec8942d68ed9,4f94b427ec169e5d0ea7cfe2750fce1f700979ed..ce1e678043188c5d7802778b97f2e2aa65fb4997
@@@ -588,7 -588,7 +588,7 @@@ impl<'a> LoweringContext<'a> 
              *local_id_counter += 1;
              hir::HirId {
                  owner: def_index,
 -                local_id: hir::ItemLocalId(local_id),
 +                local_id: hir::ItemLocalId::from_u32(local_id),
              }
          })
      }
  
              hir::HirId {
                  owner: def_index,
 -                local_id: hir::ItemLocalId(local_id),
 +                local_id: hir::ItemLocalId::from_u32(local_id),
              }
          })
      }
          attrs
              .iter()
              .map(|a| self.lower_attr(a))
-             .collect::<Vec<_>>()
-             .into()
+             .collect()
      }
  
      fn lower_attr(&mut self, attr: &Attribute) -> Attribute {
index 2f6b306e8f8baa2447dc602e74fbe4336a252e60,bfdb53a9d9e18cfa5ac61a28d0c6a64d82a93b3d..a5b12ce4c4d834c83586cd0f3e2321ffd342be54
@@@ -68,7 -68,7 +68,7 @@@
  //! The `i32`s in `B` and `C0` don't have an identifier, so the
  //! `Option<ident>`s would be `None` for them.
  //!
 -//! In the static cases, the structure is summarised, either into the just
 +//! In the static cases, the structure is summarized, either into the just
  //! spans of the fields or a list of spans and the field idents (for tuple
  //! structs and record structs, respectively), or a list of these, for
  //! enums (one for each variant). For empty struct and empty enum
@@@ -1200,16 -1200,14 +1200,14 @@@ impl<'a> MethodDef<'a> 
          let sp = trait_.span;
          let variants = &enum_def.variants;
  
-         let self_arg_names = self_args.iter()
-             .enumerate()
-             .map(|(arg_count, _self_arg)| {
-                 if arg_count == 0 {
-                     "__self".to_string()
-                 } else {
+         let self_arg_names = iter::once("__self".to_string()).chain(
+             self_args.iter()
+                 .enumerate()
+                 .skip(1)
+                 .map(|(arg_count, _self_arg)|
                      format!("__arg_{}", arg_count)
-                 }
-             })
-             .collect::<Vec<String>>();
+                 )
+             ).collect::<Vec<String>>();
  
          let self_arg_idents = self_arg_names.iter()
              .map(|name| cx.ident_of(&name[..]))
          // The `vi_idents` will be bound, solely in the catch-all, to
          // a series of let statements mapping each self_arg to an int
          // value corresponding to its discriminant.
-         let vi_idents: Vec<ast::Ident> = self_arg_names.iter()
+         let vi_idents = self_arg_names.iter()
              .map(|name| {
                  let vi_suffix = format!("{}_vi", &name[..]);
                  cx.ident_of(&vi_suffix[..]).gensym()