about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Vittal <christopher.vittal@gmail.com>2017-11-14 12:27:55 -0500
committerChristopher Vittal <christopher.vittal@gmail.com>2017-11-15 15:46:01 -0500
commit7e9948f92f5972e9b87b6f08dab51a7073b8a495 (patch)
tree006827e4c5d8b7b14b88c64a7bc9ddb2e4854305
parent2786ea662d338f92130f6965cbf38114a49f577c (diff)
downloadrust-7e9948f92f5972e9b87b6f08dab51a7073b8a495.tar.gz
rust-7e9948f92f5972e9b87b6f08dab51a7073b8a495.zip
Add proper names to impl Trait parameters.
Uses Symbol::intern and hir.node_to_pretty_string to create a name for
the impl Trait parameter that is just impl and then a ' + ' separated
list of bounds that the user typed.
-rw-r--r--src/librustc/hir/print.rs2
-rw-r--r--src/librustc_typeck/astconv.rs5
-rw-r--r--src/librustc_typeck/collect.rs4
3 files changed, 7 insertions, 4 deletions
diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs
index 5d8e732b17c..451e870f500 100644
--- a/src/librustc/hir/print.rs
+++ b/src/librustc/hir/print.rs
@@ -423,7 +423,7 @@ impl<'a> State<'a> {
             }
             hir::TyImplTraitExistential(ref bounds) |
                 hir::TyImplTraitUniversal(_, ref bounds) => {
-                self.print_bounds("impl ", &bounds[..])?;
+                self.print_bounds("impl", &bounds[..])?;
             }
             hir::TyArray(ref ty, v) => {
                 self.s.word("[")?;
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 34d617a2054..7aaf65e1fd0 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -30,7 +30,7 @@ use util::nodemap::FxHashSet;
 
 use std::iter;
 use syntax::{abi, ast};
-use syntax::symbol::keywords;
+use syntax::symbol::Symbol;
 use syntax::feature_gate::{GateIssue, emit_feature_err};
 use syntax_pos::Span;
 
@@ -1042,7 +1042,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
                 let impl_trait_def_id = tcx.hir.local_def_id(ast_ty.id);
                 let generics = tcx.generics_of(fn_def_id);
                 let index = generics.type_param_to_index[&impl_trait_def_id.index];
-                tcx.mk_param(index, keywords::Invalid.name() /* FIXME(chrisvittal) invalid? */)
+                tcx.mk_param(index,
+                             Symbol::intern(&tcx.hir.node_to_pretty_string(ast_ty.id)))
             }
             hir::TyPath(hir::QPath::Resolved(ref maybe_qself, ref path)) => {
                 debug!("ast_ty_to_ty: maybe_qself={:?} path={:?}", maybe_qself, path);
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 909855c1669..76afd4e2bd1 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -1001,7 +1001,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         .chain(univ_impl_trait_info.iter().enumerate().map(|(i, info)| {
             ty::TypeParameterDef {
                 index: other_type_start + i as u32,
-                name: keywords::Invalid.name() /* FIXME(chrisvittal) maybe make not Invalid */,
+                name: Symbol::intern(&tcx.hir.node_to_pretty_string(info.id)),
                 def_id: info.def_id,
                 has_default: false,
                 object_lifetime_default: rl::Set1::Empty,
@@ -1732,6 +1732,7 @@ fn is_auto_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 struct ImplTraitUniversalInfo<'hir> {
+    id: ast::NodeId,
     def_id: DefId,
     span: Span,
     bounds: &'hir [hir::TyParamBound],
@@ -1767,6 +1768,7 @@ fn extract_universal_impl_trait_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     });
     visitor.items.into_iter().map(|ty| if let hir::TyImplTraitUniversal(_, ref bounds) = ty.node {
         ImplTraitUniversalInfo {
+            id: ty.id,
             def_id: tcx.hir.local_def_id(ty.id),
             span: ty.span,
             bounds: bounds