@@ -1059,64 +1059,22 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
1059
1059
match arg {
1060
1060
// Lower the lifetime regularly; we'll resolve the lifetime and check
1061
1061
// it's a parameter later on in HIR lowering.
1062
- PreciseCapturingArg :: Lifetime ( _) => visit :: walk_precise_capturing_arg ( self , arg ) ,
1062
+ PreciseCapturingArg :: Lifetime ( _) => { }
1063
1063
1064
- PreciseCapturingArg :: Arg ( ident, node_id) => {
1065
- let ident = ident. normalize_to_macros_2_0 ( ) ;
1066
- ' found: {
1067
- for ( rib_t, rib_v) in
1068
- std:: iter:: zip ( & self . ribs . type_ns , & self . ribs . value_ns ) . rev ( )
1069
- {
1070
- if let Some ( res) = rib_t. bindings . get ( & ident) . or ( rib_v. bindings . get ( & ident) )
1071
- {
1072
- self . r . record_partial_res ( * node_id, PartialRes :: new ( * res) ) ;
1073
-
1074
- // Validate that this is a parameter
1075
- match res {
1076
- Res :: Def ( DefKind :: TyParam | DefKind :: ConstParam , _)
1077
- | Res :: SelfTyParam { .. } => { }
1078
- Res :: SelfTyAlias { .. } => {
1079
- self . report_error (
1080
- ident. span ,
1081
- ResolutionError :: FailedToResolve {
1082
- segment : Some ( ident. name ) ,
1083
- label : "`Self` cannot be captured because it is not a type parameter" . to_string ( ) ,
1084
- suggestion : None ,
1085
- module : None ,
1086
- } ,
1087
- ) ;
1088
- }
1089
- _ => {
1090
- self . report_error (
1091
- ident. span ,
1092
- ResolutionError :: FailedToResolve {
1093
- segment : Some ( ident. name ) ,
1094
- label : format ! (
1095
- "expected type or const parameter, found {}" ,
1096
- res. descr( )
1097
- ) ,
1098
- suggestion : None ,
1099
- module : None ,
1100
- } ,
1101
- ) ;
1102
- }
1103
- }
1104
-
1105
- break ' found;
1106
- }
1107
- }
1108
- self . report_error (
1109
- ident. span ,
1110
- ResolutionError :: FailedToResolve {
1111
- segment : Some ( ident. name ) ,
1112
- label : "could not find type or const parameter" . to_string ( ) ,
1113
- suggestion : None ,
1114
- module : None ,
1115
- } ,
1116
- ) ;
1064
+ PreciseCapturingArg :: Arg ( path, id) => {
1065
+ let mut check_ns = |ns| {
1066
+ self . maybe_resolve_ident_in_lexical_scope ( path. segments [ 0 ] . ident , ns) . is_some ( )
1067
+ } ;
1068
+ // Like `Ty::Param`, we try resolving this as both a const and a type.
1069
+ if !check_ns ( TypeNS ) && check_ns ( ValueNS ) {
1070
+ self . smart_resolve_path ( * id, & None , path, PathSource :: Expr ( None ) ) ;
1071
+ } else {
1072
+ self . smart_resolve_path ( * id, & None , path, PathSource :: Type ) ;
1117
1073
}
1118
1074
}
1119
1075
}
1076
+
1077
+ visit:: walk_precise_capturing_arg ( self , arg)
1120
1078
}
1121
1079
1122
1080
fn visit_generics ( & mut self , generics : & ' ast Generics ) {
0 commit comments