]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #20263: crhino/lifetime-elision-help
authorAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 00:36:27 +0000 (16:36 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 00:36:27 +0000 (16:36 -0800)
Fixes #19707.

In terms of output, it currently uses the form `argument #1`, `argument #2`, etc. If anyone has any better suggestions I would be glad to consider them.

1  2 
src/librustc_typeck/astconv.rs

index c8a084584b5e2b186d89c2dda71217374ee29d68,c7dcdba551b70e11f42f3a5317a49ef6224e03e3..d6f1f5fedc5817554a085a5ae922074b65774a01
@@@ -164,10 -164,16 +164,16 @@@ pub fn opt_ast_region_to_region<'tcx, A
                              let mut m = String::new();
                              let len = v.len();
                              for (i, (name, n)) in v.into_iter().enumerate() {
-                                 m.push_str(if n == 1 {
+                                 let help_name = if name.is_empty() {
+                                     format!("argument {}", i + 1)
+                                 } else {
                                      format!("`{}`", name)
+                                 };
+                                 m.push_str(if n == 1 {
+                                     help_name
                                  } else {
-                                     format!("one of `{}`'s {} elided lifetimes", name, n)
+                                     format!("one of {}'s {} elided lifetimes", help_name, n)
                                  }[]);
  
                                  if len == 2 && i == 0 {
@@@ -633,7 -639,7 +639,7 @@@ fn ast_path_to_trait_ref<'tcx,AC,RS>
                                              regions,
                                              assoc_bindings);
  
 -    ty::TraitRef::new(trait_def_id, substs)
 +    ty::TraitRef::new(trait_def_id, this.tcx().mk_substs(substs))
  }
  
  pub fn ast_path_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
@@@ -940,7 -946,7 +946,7 @@@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'
                  let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region);
                  debug!("ty_rptr r={}", r.repr(this.tcx()));
                  let t = ast_ty_to_ty(this, rscope, &*mt.ty);
 -                ty::mk_rptr(tcx, r, ty::mt {ty: t, mutbl: mt.mutbl})
 +                ty::mk_rptr(tcx, tcx.mk_region(r), ty::mt {ty: t, mutbl: mt.mutbl})
              }
              ast::TyTup(ref fields) => {
                  let flds = fields.iter()
                      tcx.sess.span_err(ast_ty.span,
                                        "variadic function must have C calling convention");
                  }
 -                ty::mk_bare_fn(tcx, None, ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl))
 +                let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);
 +                ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(bare_fn))
              }
              ast::TyClosure(ref f) => {
                  // Use corresponding trait store to figure out default bounds
@@@ -1218,7 -1223,7 +1224,7 @@@ fn ty_of_method_or_bare_fn<'a, 'tcx, AC
                  }
                  ty::ByReferenceExplicitSelfCategory(region, mutability) => {
                      (Some(ty::mk_rptr(this.tcx(),
 -                                      region,
 +                                      this.tcx().mk_region(region),
                                        ty::mt {
                                          ty: self_info.untransformed_self_ty,
                                          mutbl: mutability
@@@ -1351,7 -1356,7 +1357,7 @@@ fn determine_explicit_self_category<'a
                  ty::ByValueExplicitSelfCategory
              } else {
                  match explicit_type.sty {
 -                    ty::ty_rptr(r, mt) => ty::ByReferenceExplicitSelfCategory(r, mt.mutbl),
 +                    ty::ty_rptr(r, mt) => ty::ByReferenceExplicitSelfCategory(*r, mt.mutbl),
                      ty::ty_uniq(_) => ty::ByBoxExplicitSelfCategory,
                      _ => ty::ByValueExplicitSelfCategory,
                  }
@@@ -1626,7 -1631,7 +1632,7 @@@ pub fn partition_bounds<'a>(tcx: &ty::c
      let mut trait_def_ids = DefIdMap::new();
      for ast_bound in ast_bounds.iter() {
          match *ast_bound {
 -            ast::TraitTyParamBound(ref b) => {
 +            ast::TraitTyParamBound(ref b, ast::TraitBoundModifier::None) => {
                  match ::lookup_def_tcx(tcx, b.trait_ref.path.span, b.trait_ref.ref_id) {
                      def::DefTrait(trait_did) => {
                          match trait_def_ids.get(&trait_did) {
                  }
                  trait_bounds.push(b);
              }
 +            ast::TraitTyParamBound(_, ast::TraitBoundModifier::Maybe) => {}
              ast::RegionTyParamBound(ref l) => {
                  region_bounds.push(l);
              }