Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created April 20, 2012 21:49
Show Gist options
  • Save nikomatsakis/2432096 to your computer and use it in GitHub Desktop.
Save nikomatsakis/2432096 to your computer and use it in GitHub Desktop.
fn normalize_ty(cx: ctxt, t0: t) -> t {
fold_sty_to_ty(get(t0).struct) { |t|
normalize_ty(cx, t)
}
}
@brson
Copy link

brson commented Apr 20, 2012

#[doc = "                                                                                                                                          
Returns an equivalent type with all the typedefs removed                                                                                           
"]                                                                                                                                                 
fn normalize_types(cx: ctxt, t: t) -> t {                                                                                                          
    fold_ty(cx, t) { |t|                                                                                                                           
        alt t.get().o_def_id {                                                                                                                     
          some(did) {                                                                                                                              
            // This type is defined by a `type` item                                                                                               
            mk_t(cx, t.get().struct)                                                                                                               
          }                                                                                                                                        
          none { t }                                                                                                                               
        }                                                                                                                                          
    }                                                                                                                                              
} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment