@@ -250,7 +250,7 @@ enum FallbackSuggestion {
250
250
Method ,
251
251
TraitItem ,
252
252
StaticMethod ( String ) ,
253
- StaticTraitMethod ( String ) ,
253
+ TraitMethod ( String ) ,
254
254
}
255
255
256
256
enum TypeParameters < ' a > {
@@ -1386,17 +1386,17 @@ impl<'a> Resolver<'a> {
1386
1386
. node {
1387
1387
SelfStatic => {
1388
1388
// Static methods become
1389
- // `def_static_method`s.
1390
- DefStaticMethod (
1391
- local_def ( method. id ) ,
1392
- FromImpl ( local_def ( item. id ) ) ,
1393
- method. pe_fn_style ( ) )
1389
+ // `DefStaticMethod`s.
1390
+ DefStaticMethod ( local_def ( method. id ) ,
1391
+ FromImpl ( local_def ( item. id ) ) ,
1392
+ method. pe_fn_style ( ) )
1394
1393
}
1395
1394
_ => {
1396
1395
// Non-static methods become
1397
- // `def_method `s.
1396
+ // `DefMethod `s.
1398
1397
DefMethod ( local_def ( method. id ) ,
1399
- None )
1398
+ None ,
1399
+ FromImpl ( local_def ( item. id ) ) )
1400
1400
}
1401
1401
} ;
1402
1402
@@ -1476,19 +1476,18 @@ impl<'a> Resolver<'a> {
1476
1476
let ( def, static_flag) = match ty_m. explicit_self
1477
1477
. node {
1478
1478
SelfStatic => {
1479
- // Static methods become
1480
- // `def_static_method`s.
1479
+ // Static methods become `DefStaticMethod`s.
1481
1480
( DefStaticMethod (
1482
1481
local_def ( ty_m. id ) ,
1483
1482
FromTrait ( local_def ( item. id ) ) ,
1484
1483
ty_m. fn_style ) ,
1485
1484
StaticMethodTraitItemKind )
1486
1485
}
1487
1486
_ => {
1488
- // Non-static methods become
1489
- // `def_method`s.
1487
+ // Non-static methods become `DefMethod`s.
1490
1488
( DefMethod ( local_def ( ty_m. id ) ,
1491
- Some ( local_def ( item. id ) ) ) ,
1489
+ Some ( local_def ( item. id ) ) ,
1490
+ FromTrait ( local_def ( item. id ) ) ) ,
1492
1491
NonstaticMethodTraitItemKind )
1493
1492
}
1494
1493
} ;
@@ -4607,8 +4606,7 @@ impl<'a> Resolver<'a> {
4607
4606
// We also need a new scope for the method-
4608
4607
// specific type parameters.
4609
4608
this. resolve_method (
4610
- MethodRibKind ( id,
4611
- ProvidedMethod ( method. id ) ) ,
4609
+ MethodRibKind ( id, ProvidedMethod ( method. id ) ) ,
4612
4610
& * * method) ;
4613
4611
}
4614
4612
TypeImplItem ( ref typedef) => {
@@ -5393,8 +5391,8 @@ impl<'a> Resolver<'a> {
5393
5391
5394
5392
let ident = path. segments . last ( ) . unwrap ( ) . identifier ;
5395
5393
let def = match self . resolve_definition_of_name_in_module ( containing_module. clone ( ) ,
5396
- ident. name ,
5397
- namespace) {
5394
+ ident. name ,
5395
+ namespace) {
5398
5396
NoNameDefinition => {
5399
5397
// We failed to resolve the name. Report an error.
5400
5398
return None ;
@@ -5403,26 +5401,6 @@ impl<'a> Resolver<'a> {
5403
5401
( def, last_private. or ( lp) )
5404
5402
}
5405
5403
} ;
5406
- match containing_module. kind . get ( ) {
5407
- TraitModuleKind | ImplModuleKind => {
5408
- match containing_module. def_id . get ( ) {
5409
- Some ( def_id) => {
5410
- match self . trait_item_map . find ( & ( ident. name , def_id) ) {
5411
- Some ( & StaticMethodTraitItemKind ) => ( ) ,
5412
- Some ( & TypeTraitItemKind ) => ( ) ,
5413
- None => ( ) ,
5414
- Some ( & NonstaticMethodTraitItemKind ) => {
5415
- debug ! ( "containing module was a trait or impl \
5416
- and name was a method -> not resolved") ;
5417
- return None ;
5418
- }
5419
- }
5420
- } ,
5421
- _ => ( ) ,
5422
- }
5423
- } ,
5424
- _ => ( ) ,
5425
- }
5426
5404
match containing_module. def_id . get ( ) {
5427
5405
Some ( DefId { krate : kid, ..} ) => { self . used_crates . insert ( kid) ; } ,
5428
5406
_ => { }
@@ -5668,8 +5646,8 @@ impl<'a> Resolver<'a> {
5668
5646
FromTrait ( _) => unreachable ! ( )
5669
5647
}
5670
5648
}
5671
- Some ( DefMethod ( _, None ) ) if allowed == Everything => return Method ,
5672
- Some ( DefMethod ( _, Some ( _) ) ) => return TraitItem ,
5649
+ Some ( DefMethod ( _, None , _ ) ) if allowed == Everything => return Method ,
5650
+ Some ( DefMethod ( _, Some ( _) , _ ) ) => return TraitItem ,
5673
5651
_ => ( )
5674
5652
}
5675
5653
}
@@ -5684,7 +5662,9 @@ impl<'a> Resolver<'a> {
5684
5662
let path_str = self . path_idents_to_string ( & trait_ref. path ) ;
5685
5663
5686
5664
match self . trait_item_map . find ( & ( name, did) ) {
5687
- Some ( & StaticMethodTraitItemKind ) => return StaticTraitMethod ( path_str) ,
5665
+ Some ( & StaticMethodTraitItemKind ) => {
5666
+ return TraitMethod ( path_str)
5667
+ }
5688
5668
Some ( _) => return TraitItem ,
5689
5669
None => { }
5690
5670
}
@@ -5751,22 +5731,6 @@ impl<'a> Resolver<'a> {
5751
5731
// Write the result into the def map.
5752
5732
debug ! ( "(resolving expr) resolved `{}`" ,
5753
5733
self . path_idents_to_string( path) ) ;
5754
-
5755
- // First-class methods are not supported yet; error
5756
- // out here.
5757
- match def {
5758
- ( DefMethod ( ..) , _) => {
5759
- self . resolve_error ( expr. span ,
5760
- "first-class methods \
5761
- are not supported") ;
5762
- self . session . span_note ( expr. span ,
5763
- "call the method \
5764
- using the `.` \
5765
- syntax") ;
5766
- }
5767
- _ => { }
5768
- }
5769
-
5770
5734
self . record_def ( expr. id , def) ;
5771
5735
}
5772
5736
None => {
@@ -5826,7 +5790,7 @@ impl<'a> Resolver<'a> {
5826
5790
Method
5827
5791
| TraitItem =>
5828
5792
format ! ( "to call `self.{}`" , wrong_name) ,
5829
- StaticTraitMethod ( path_str)
5793
+ TraitMethod ( path_str)
5830
5794
| StaticMethod ( path_str) =>
5831
5795
format ! ( "to call `{}::{}`" , path_str, wrong_name)
5832
5796
} ;
0 commit comments