Skip to content

Path types to associated types with form T::A #19789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2014
Merged

Conversation

nrc
Copy link
Member

@nrc nrc commented Dec 12, 2014

Closes #18433

@nrc
Copy link
Member Author

nrc commented Dec 12, 2014

r? @nikomatsakis

@sfackler
Copy link
Member

😄

@nikomatsakis
Copy link
Contributor

So this patch (applied locally) still seems to pass all tests, and is a touch simpler:

diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index db9f6f5..dbb5ae9 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -1034,7 +1034,8 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
                         // FIXME(#19541): in both branches we should consider
                         // associated types in super-traits.
                         let (assoc_tys, tp_name): (Vec<_>, _) = match typ {
-                            def::TyParamProvenance::FromParam(did) => {
+                            def::TyParamProvenance::FromParam(did) |
+                            def::TyParamProvenance::FromSelf(did) => {
                                 let ty_param_defs = tcx.ty_param_defs.borrow();
                                 let tp_def = &(*ty_param_defs)[did.node];
                                 let assoc_tys = tp_def.bounds.trait_bounds.iter()
@@ -1042,13 +1043,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
                                     .collect();
                                 (assoc_tys, token::get_name(tp_def.name).to_string())
                             }
-                            def::TyParamProvenance::FromSelf(did) => {
-                                let assoc_tys = find_assoc_ty(this,
-                                                              &*this.get_trait_def(did).trait_ref,
-                                                              assoc_ident)
-                                    .into_iter().collect();
-                                (assoc_tys, "Self".to_string())
-                            }
                         };

                         if assoc_tys.len() == 0 {

Basically Self should really not need a different path than other type parameters.

@nikomatsakis
Copy link
Contributor

r+ modulo comments

bors added a commit that referenced this pull request Dec 17, 2014
@bors bors merged commit 743d6a4 into rust-lang:master Dec 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support T::Type shorthand for referencing associated types
4 participants