@@ -71,6 +71,7 @@ use util::ppaux::{ty_to_string, Repr};
7171
7272use syntax:: ast:: { MutImmutable , MutMutable } ;
7373use syntax:: ast;
74+ use syntax:: ast_map;
7475use syntax:: codemap:: Span ;
7576use syntax:: print:: pprust;
7677use syntax:: parse:: token;
@@ -85,7 +86,6 @@ pub enum categorization {
8586 cat_copied_upvar( CopiedUpvar ) , // upvar copied into proc env
8687 cat_upvar( ty:: UpvarId , ty:: UpvarBorrow ) , // by ref upvar from stack closure
8788 cat_local( ast:: NodeId ) , // local variable
88- cat_arg( ast:: NodeId ) , // formal argument
8989 cat_deref( cmt , uint , PointerKind ) , // deref of a ptr
9090 cat_interior( cmt , InteriorKind ) , // something interior: field, tuple, etc
9191 cat_downcast( cmt ) , // selects a particular enum variant (*1)
@@ -326,8 +326,6 @@ impl MutabilityCategory {
326326 def:: DefStatic ( _, false ) => McImmutable ,
327327 def:: DefStatic ( _, true ) => McDeclared ,
328328
329- def:: DefArg ( _, binding_mode) |
330- def:: DefBinding ( _, binding_mode) |
331329 def:: DefLocal ( _, binding_mode) => match binding_mode {
332330 ast:: BindByValue ( ast:: MutMutable ) => McDeclared ,
333331 _ => McImmutable
@@ -556,19 +554,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
556554 } ) )
557555 }
558556
559- def:: DefArg ( vid, _) => {
560- // Idea: make this could be rewritten to model by-ref
561- // stuff as `&const` and `&mut`?
562-
563- Ok ( Rc :: new ( cmt_ {
564- id : id,
565- span : span,
566- cat : cat_arg ( vid) ,
567- mutbl : MutabilityCategory :: from_def ( & def) ,
568- ty : expr_ty
569- } ) )
570- }
571-
572557 def:: DefUpvar ( var_id, _, fn_node_id, _) => {
573558 let ty = if_ok ! ( self . node_ty( fn_node_id) ) ;
574559 match ty:: get ( ty) . sty {
@@ -634,9 +619,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
634619 }
635620 }
636621
637- def:: DefLocal ( vid, _) |
638- def:: DefBinding ( vid, _) => {
639- // by-value/by-ref bindings are local variables
622+ def:: DefLocal ( vid, _) => {
640623 Ok ( Rc :: new ( cmt_ {
641624 id : id,
642625 span : span,
@@ -1196,11 +1179,13 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
11961179 cat_rvalue( ..) => {
11971180 "non-lvalue" . to_string ( )
11981181 }
1199- cat_local( _) => {
1200- "local variable" . to_string ( )
1201- }
1202- cat_arg( ..) => {
1203- "argument" . to_string ( )
1182+ cat_local( vid) => {
1183+ match self . tcx ( ) . map . find ( vid) {
1184+ Some ( ast_map:: NodeArg ( _) ) => {
1185+ "argument" . to_string ( )
1186+ }
1187+ _ => "local variable" . to_string ( )
1188+ }
12041189 }
12051190 cat_deref( ref base, _, pk) => {
12061191 match base. cat {
@@ -1267,7 +1252,6 @@ impl cmt_ {
12671252 cat_static_item |
12681253 cat_copied_upvar( ..) |
12691254 cat_local( ..) |
1270- cat_arg( ..) |
12711255 cat_deref( _, _, UnsafePtr ( ..) ) |
12721256 cat_deref( _, _, GcPtr ( ..) ) |
12731257 cat_deref( _, _, BorrowedPtr ( ..) ) |
@@ -1311,7 +1295,6 @@ impl cmt_ {
13111295 cat_rvalue( ..) |
13121296 cat_local( ..) |
13131297 cat_upvar( ..) |
1314- cat_arg( _) |
13151298 cat_deref( _, _, UnsafePtr ( ..) ) => { // yes, it's aliasable, but...
13161299 None
13171300 }
@@ -1363,8 +1346,7 @@ impl Repr for categorization {
13631346 cat_rvalue( ..) |
13641347 cat_copied_upvar( ..) |
13651348 cat_local( ..) |
1366- cat_upvar( ..) |
1367- cat_arg( ..) => {
1349+ cat_upvar( ..) => {
13681350 format ! ( "{:?}" , * self )
13691351 }
13701352 cat_deref( ref cmt, derefs, ptr) => {
0 commit comments