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