@@ -53,7 +53,6 @@ use rustc::ty::subst::{ParamSpace, FnSpace, TypeSpace};
53
53
use rustc:: hir:: { Freevar , FreevarMap , TraitCandidate , TraitMap , GlobMap } ;
54
54
use rustc:: util:: nodemap:: { NodeMap , NodeSet , FnvHashMap , FnvHashSet } ;
55
55
56
- use syntax:: ext:: mtwt;
57
56
use syntax:: ast:: { self , FloatTy } ;
58
57
use syntax:: ast:: { CRATE_NODE_ID , Name , NodeId , CrateNum , IntTy , UintTy } ;
59
58
use syntax:: parse:: token:: { self , keywords} ;
@@ -462,7 +461,7 @@ struct BindingInfo {
462
461
}
463
462
464
463
// Map from the name in a pattern to its binding mode.
465
- type BindingMap = HashMap < Name , BindingInfo > ;
464
+ type BindingMap = HashMap < ast :: Ident , BindingInfo > ;
466
465
467
466
#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
468
467
enum PatternSource {
@@ -668,7 +667,7 @@ enum ModulePrefixResult<'a> {
668
667
/// One local scope.
669
668
#[ derive( Debug ) ]
670
669
struct Rib < ' a > {
671
- bindings : HashMap < Name , Def > ,
670
+ bindings : HashMap < ast :: Ident , Def > ,
672
671
kind : RibKind < ' a > ,
673
672
}
674
673
@@ -1385,15 +1384,17 @@ impl<'a> Resolver<'a> {
1385
1384
/// Invariant: This must only be called during main resolution, not during
1386
1385
/// import resolution.
1387
1386
fn resolve_ident_in_lexical_scope ( & mut self ,
1388
- ident : ast:: Ident ,
1387
+ mut ident : ast:: Ident ,
1389
1388
ns : Namespace ,
1390
1389
record_used : bool )
1391
1390
-> Option < LexicalScopeBinding < ' a > > {
1392
- let name = match ns { ValueNS => mtwt:: resolve ( ident) , TypeNS => ident. name } ;
1391
+ if ns == TypeNS {
1392
+ ident = ast:: Ident :: with_empty_ctxt ( ident. name ) ;
1393
+ }
1393
1394
1394
1395
// Walk backwards up the ribs in scope.
1395
1396
for i in ( 0 .. self . get_ribs ( ns) . len ( ) ) . rev ( ) {
1396
- if let Some ( def) = self . get_ribs ( ns) [ i] . bindings . get ( & name ) . cloned ( ) {
1397
+ if let Some ( def) = self . get_ribs ( ns) [ i] . bindings . get ( & ident ) . cloned ( ) {
1397
1398
// The ident resolves to a type parameter or local variable.
1398
1399
return Some ( LexicalScopeBinding :: LocalDef ( LocalDef {
1399
1400
ribs : Some ( ( ns, i) ) ,
@@ -1556,7 +1557,7 @@ impl<'a> Resolver<'a> {
1556
1557
1557
1558
/// Searches the current set of local scopes for labels.
1558
1559
/// Stops after meeting a closure.
1559
- fn search_label ( & self , name : Name ) -> Option < Def > {
1560
+ fn search_label ( & self , ident : ast :: Ident ) -> Option < Def > {
1560
1561
for rib in self . label_ribs . iter ( ) . rev ( ) {
1561
1562
match rib. kind {
1562
1563
NormalRibKind => {
@@ -1567,7 +1568,7 @@ impl<'a> Resolver<'a> {
1567
1568
return None ;
1568
1569
}
1569
1570
}
1570
- let result = rib. bindings . get ( & name ) . cloned ( ) ;
1571
+ let result = rib. bindings . get ( & ident ) . cloned ( ) ;
1571
1572
if result. is_some ( ) {
1572
1573
return result;
1573
1574
}
@@ -1716,7 +1717,7 @@ impl<'a> Resolver<'a> {
1716
1717
// plain insert (no renaming)
1717
1718
let def_id = self . definitions . local_def_id ( type_parameter. id ) ;
1718
1719
let def = Def :: TyParam ( space, index as u32 , def_id, name) ;
1719
- function_type_rib. bindings . insert ( name, def) ;
1720
+ function_type_rib. bindings . insert ( ast :: Ident :: with_empty_ctxt ( name) , def) ;
1720
1721
}
1721
1722
self . type_ribs . push ( function_type_rib) ;
1722
1723
}
@@ -1887,7 +1888,7 @@ impl<'a> Resolver<'a> {
1887
1888
let mut self_type_rib = Rib :: new ( NormalRibKind ) ;
1888
1889
1889
1890
// plain insert (no renaming, types are not currently hygienic....)
1890
- self_type_rib. bindings . insert ( keywords:: SelfType . name ( ) , self_def) ;
1891
+ self_type_rib. bindings . insert ( keywords:: SelfType . ident ( ) , self_def) ;
1891
1892
self . type_ribs . push ( self_type_rib) ;
1892
1893
f ( self ) ;
1893
1894
self . type_ribs . pop ( ) ;
@@ -1998,7 +1999,7 @@ impl<'a> Resolver<'a> {
1998
1999
_ => false ,
1999
2000
} {
2000
2001
let binding_info = BindingInfo { span : ident. span , binding_mode : binding_mode } ;
2001
- binding_map. insert ( mtwt :: resolve ( ident. node ) , binding_info) ;
2002
+ binding_map. insert ( ident. node , binding_info) ;
2002
2003
}
2003
2004
}
2004
2005
true
@@ -2020,15 +2021,14 @@ impl<'a> Resolver<'a> {
2020
2021
for ( & key, & binding_0) in & map_0 {
2021
2022
match map_i. get ( & key) {
2022
2023
None => {
2023
- resolve_error ( self ,
2024
- p. span ,
2025
- ResolutionError :: VariableNotBoundInPattern ( key, 1 , i + 1 ) ) ;
2024
+ let error = ResolutionError :: VariableNotBoundInPattern ( key. name , 1 , i + 1 ) ;
2025
+ resolve_error ( self , p. span , error) ;
2026
2026
}
2027
2027
Some ( binding_i) => {
2028
2028
if binding_0. binding_mode != binding_i. binding_mode {
2029
2029
resolve_error ( self ,
2030
2030
binding_i. span ,
2031
- ResolutionError :: VariableBoundWithDifferentMode ( key,
2031
+ ResolutionError :: VariableBoundWithDifferentMode ( key. name ,
2032
2032
i + 1 ) ) ;
2033
2033
}
2034
2034
}
@@ -2039,7 +2039,7 @@ impl<'a> Resolver<'a> {
2039
2039
if !map_0. contains_key ( & key) {
2040
2040
resolve_error ( self ,
2041
2041
binding. span ,
2042
- ResolutionError :: VariableNotBoundInPattern ( key, i + 1 , 1 ) ) ;
2042
+ ResolutionError :: VariableNotBoundInPattern ( key. name , i + 1 , 1 ) ) ;
2043
2043
}
2044
2044
}
2045
2045
}
@@ -2173,16 +2173,15 @@ impl<'a> Resolver<'a> {
2173
2173
pat_id : NodeId ,
2174
2174
outer_pat_id : NodeId ,
2175
2175
pat_src : PatternSource ,
2176
- bindings : & mut HashMap < Name , NodeId > )
2176
+ bindings : & mut HashMap < ast :: Ident , NodeId > )
2177
2177
-> PathResolution {
2178
2178
// Add the binding to the local ribs, if it
2179
2179
// doesn't already exist in the bindings map. (We
2180
2180
// must not add it if it's in the bindings map
2181
2181
// because that breaks the assumptions later
2182
2182
// passes make about or-patterns.)
2183
- let renamed = mtwt:: resolve ( ident. node ) ;
2184
2183
let mut def = Def :: Local ( self . definitions . local_def_id ( pat_id) , pat_id) ;
2185
- match bindings. get ( & renamed ) . cloned ( ) {
2184
+ match bindings. get ( & ident . node ) . cloned ( ) {
2186
2185
Some ( id) if id == outer_pat_id => {
2187
2186
// `Variant(a, a)`, error
2188
2187
resolve_error (
@@ -2204,7 +2203,7 @@ impl<'a> Resolver<'a> {
2204
2203
Some ( ..) if pat_src == PatternSource :: Match => {
2205
2204
// `Variant1(a) | Variant2(a)`, ok
2206
2205
// Reuse definition from the first `a`.
2207
- def = self . value_ribs . last_mut ( ) . unwrap ( ) . bindings [ & renamed ] ;
2206
+ def = self . value_ribs . last_mut ( ) . unwrap ( ) . bindings [ & ident . node ] ;
2208
2207
}
2209
2208
Some ( ..) => {
2210
2209
span_bug ! ( ident. span, "two bindings with the same name from \
@@ -2213,8 +2212,8 @@ impl<'a> Resolver<'a> {
2213
2212
None => {
2214
2213
// A completely fresh binding, add to the lists if it's valid.
2215
2214
if ident. node . name != keywords:: Invalid . name ( ) {
2216
- bindings. insert ( renamed , outer_pat_id) ;
2217
- self . value_ribs . last_mut ( ) . unwrap ( ) . bindings . insert ( renamed , def) ;
2215
+ bindings. insert ( ident . node , outer_pat_id) ;
2216
+ self . value_ribs . last_mut ( ) . unwrap ( ) . bindings . insert ( ident . node , def) ;
2218
2217
}
2219
2218
}
2220
2219
}
@@ -2275,7 +2274,7 @@ impl<'a> Resolver<'a> {
2275
2274
pat_src : PatternSource ,
2276
2275
// Maps idents to the node ID for the
2277
2276
// outermost pattern that binds them.
2278
- bindings : & mut HashMap < Name , NodeId > ) {
2277
+ bindings : & mut HashMap < ast :: Ident , NodeId > ) {
2279
2278
// Visit all direct subpatterns of this pattern.
2280
2279
let outer_pat_id = pat. id ;
2281
2280
pat. walk ( & mut |pat| {
@@ -2748,7 +2747,7 @@ impl<'a> Resolver<'a> {
2748
2747
let names = self . value_ribs
2749
2748
. iter ( )
2750
2749
. rev ( )
2751
- . flat_map ( |rib| rib. bindings . keys ( ) ) ;
2750
+ . flat_map ( |rib| rib. bindings . keys ( ) . map ( |ident| & ident . name ) ) ;
2752
2751
2753
2752
if let Some ( found) = find_best_match_for_name ( names, name, None ) {
2754
2753
if name != found {
@@ -2759,7 +2758,7 @@ impl<'a> Resolver<'a> {
2759
2758
2760
2759
fn resolve_labeled_block ( & mut self , label : Option < ast:: Ident > , id : NodeId , block : & Block ) {
2761
2760
if let Some ( label) = label {
2762
- let ( label , def) = ( mtwt :: resolve ( label ) , Def :: Label ( id) ) ;
2761
+ let def = Def :: Label ( id) ;
2763
2762
self . with_label_rib ( |this| {
2764
2763
this. label_ribs . last_mut ( ) . unwrap ( ) . bindings . insert ( label, def) ;
2765
2764
this. visit_block ( block) ;
@@ -2966,15 +2965,15 @@ impl<'a> Resolver<'a> {
2966
2965
2967
2966
{
2968
2967
let rib = this. label_ribs . last_mut ( ) . unwrap ( ) ;
2969
- rib. bindings . insert ( mtwt :: resolve ( label. node ) , def) ;
2968
+ rib. bindings . insert ( label. node , def) ;
2970
2969
}
2971
2970
2972
2971
visit:: walk_expr ( this, expr) ;
2973
2972
} )
2974
2973
}
2975
2974
2976
2975
ExprKind :: Break ( Some ( label) ) | ExprKind :: Continue ( Some ( label) ) => {
2977
- match self . search_label ( mtwt :: resolve ( label. node ) ) {
2976
+ match self . search_label ( label. node ) {
2978
2977
None => {
2979
2978
self . record_def ( expr. id , err_path_resolution ( ) ) ;
2980
2979
resolve_error ( self ,
0 commit comments