@@ -4164,6 +4164,9 @@ impl<'a> Resolver<'a> {
4164
4164
span_bug ! ( span, "unexpected {:?} in bindings" , def)
4165
4165
}
4166
4166
Def :: Local ( node_id) => {
4167
+ use ResolutionError :: * ;
4168
+ let mut res_err = None ;
4169
+
4167
4170
for rib in ribs {
4168
4171
match rib. kind {
4169
4172
NormalRibKind | ModuleRibKind ( ..) | MacroDefinition ( ..) |
@@ -4199,21 +4202,26 @@ impl<'a> Resolver<'a> {
4199
4202
// named function item. This is not allowed, so we
4200
4203
// report an error.
4201
4204
if record_used {
4202
- resolve_error ( self , span,
4203
- ResolutionError :: CannotCaptureDynamicEnvironmentInFnItem ) ;
4205
+ // We don't immediately trigger a resolve error, because
4206
+ // we want certain other resolution errors (namely those
4207
+ // emitted for `ConstantItemRibKind` below) to take
4208
+ // precedence.
4209
+ res_err = Some ( CannotCaptureDynamicEnvironmentInFnItem ) ;
4204
4210
}
4205
- return Def :: Err ;
4206
4211
}
4207
4212
ConstantItemRibKind => {
4208
4213
// Still doesn't deal with upvars
4209
4214
if record_used {
4210
- resolve_error ( self , span,
4211
- ResolutionError :: AttemptToUseNonConstantValueInConstant ) ;
4215
+ resolve_error ( self , span, AttemptToUseNonConstantValueInConstant ) ;
4212
4216
}
4213
4217
return Def :: Err ;
4214
4218
}
4215
4219
}
4216
4220
}
4221
+ if let Some ( res_err) = res_err {
4222
+ resolve_error ( self , span, res_err) ;
4223
+ return Def :: Err ;
4224
+ }
4217
4225
}
4218
4226
Def :: TyParam ( ..) | Def :: SelfTy ( ..) => {
4219
4227
for rib in ribs {
0 commit comments