plugins - How to find out what type a rustc::middle::ty::Ty represents? -


for writing yet lint in rust, need make sure type of expr option<_> (or pointer one). have walked ptrs , rptrs conclusion , left rustc::middle::ty in test case debugs (manually formatted better readability):

tys {    sty: ty_enum(     defid {        krate: 2,        node: 117199      },      substs {        types: vecperparamspace {         typespace: [           tys {              sty: ty_int(i32),              flags: 0,              region_depth: 0            }         ],         selfspace: [],          fnspace: [],        },        regions: nonerasedregions(         vecperparamspace {           typespace: [],            selfspace: [],            fnspace: [],          }       )     }   ),    flags: 0,    region_depth: 0  } 

however, i'm bit lost – how find out if tys option<_> type?

you need use with_path on defid. provided iterator on pathelems must consume.

the following rough sketch, should give array of names if tweak bit.

if let ty_enum(did, ..) = ty.sty {   tcx.with_path(did, |iter| iter.map(|elem| elem.name())).collect::<vec<name>>; } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -