@@ -13,7 +13,9 @@ use rustc_span::{Span, DUMMY_SP};
13
13
14
14
use std:: ptr;
15
15
16
- use crate :: late:: { ConstantItemKind , HasGenericParams , PathSource , Rib , RibKind } ;
16
+ use crate :: late:: {
17
+ ConstantHasGenerics , ConstantItemKind , HasGenericParams , PathSource , Rib , RibKind ,
18
+ } ;
17
19
use crate :: macros:: { sub_namespace_match, MacroRulesScope } ;
18
20
use crate :: { AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , Determinacy , Finalize } ;
19
21
use crate :: { ImportKind , LexicalScopeBinding , Module , ModuleKind , ModuleOrUniformRoot } ;
@@ -1103,7 +1105,7 @@ impl<'a> Resolver<'a> {
1103
1105
| ForwardGenericParamBanRibKind => {
1104
1106
// Nothing to do. Continue.
1105
1107
}
1106
- ItemRibKind ( _) | FnItemRibKind | AssocItemRibKind => {
1108
+ ItemRibKind ( _) | AssocItemRibKind => {
1107
1109
// This was an attempt to access an upvar inside a
1108
1110
// named function item. This is not allowed, so we
1109
1111
// report an error.
@@ -1168,10 +1170,10 @@ impl<'a> Resolver<'a> {
1168
1170
let has_generic_params: HasGenericParams = match rib. kind {
1169
1171
NormalRibKind
1170
1172
| ClosureOrAsyncRibKind
1171
- | AssocItemRibKind
1172
1173
| ModuleRibKind ( ..)
1173
1174
| MacroDefinition ( ..)
1174
1175
| InlineAsmSymRibKind
1176
+ | AssocItemRibKind
1175
1177
| ForwardGenericParamBanRibKind => {
1176
1178
// Nothing to do. Continue.
1177
1179
continue ;
@@ -1180,7 +1182,9 @@ impl<'a> Resolver<'a> {
1180
1182
ConstantItemRibKind ( trivial, _) => {
1181
1183
let features = self . session . features_untracked ( ) ;
1182
1184
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
1183
- if !( trivial == HasGenericParams :: Yes || features. generic_const_exprs ) {
1185
+ if !( trivial == ConstantHasGenerics :: Yes
1186
+ || features. generic_const_exprs )
1187
+ {
1184
1188
// HACK(min_const_generics): If we encounter `Self` in an anonymous constant
1185
1189
// we can't easily tell if it's generic at this stage, so we instead remember
1186
1190
// this and then enforce the self type to be concrete later on.
@@ -1207,7 +1211,6 @@ impl<'a> Resolver<'a> {
1207
1211
1208
1212
// This was an attempt to use a type parameter outside its scope.
1209
1213
ItemRibKind ( has_generic_params) => has_generic_params,
1210
- FnItemRibKind => HasGenericParams :: Yes ,
1211
1214
ConstParamTyRibKind => {
1212
1215
if let Some ( span) = finalize {
1213
1216
self . report_error (
@@ -1232,28 +1235,22 @@ impl<'a> Resolver<'a> {
1232
1235
}
1233
1236
}
1234
1237
Res :: Def ( DefKind :: ConstParam , _) => {
1235
- let mut ribs = ribs. iter ( ) . peekable ( ) ;
1236
- if let Some ( Rib { kind : FnItemRibKind , .. } ) = ribs. peek ( ) {
1237
- // When declaring const parameters inside function signatures, the first rib
1238
- // is always a `FnItemRibKind`. In this case, we can skip it, to avoid it
1239
- // (spuriously) conflicting with the const param.
1240
- ribs. next ( ) ;
1241
- }
1242
-
1243
1238
for rib in ribs {
1244
1239
let has_generic_params = match rib. kind {
1245
1240
NormalRibKind
1246
1241
| ClosureOrAsyncRibKind
1247
- | AssocItemRibKind
1248
1242
| ModuleRibKind ( ..)
1249
1243
| MacroDefinition ( ..)
1250
1244
| InlineAsmSymRibKind
1245
+ | AssocItemRibKind
1251
1246
| ForwardGenericParamBanRibKind => continue ,
1252
1247
1253
1248
ConstantItemRibKind ( trivial, _) => {
1254
1249
let features = self . session . features_untracked ( ) ;
1255
1250
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
1256
- if !( trivial == HasGenericParams :: Yes || features. generic_const_exprs ) {
1251
+ if !( trivial == ConstantHasGenerics :: Yes
1252
+ || features. generic_const_exprs )
1253
+ {
1257
1254
if let Some ( span) = finalize {
1258
1255
self . report_error (
1259
1256
span,
@@ -1272,7 +1269,6 @@ impl<'a> Resolver<'a> {
1272
1269
}
1273
1270
1274
1271
ItemRibKind ( has_generic_params) => has_generic_params,
1275
- FnItemRibKind => HasGenericParams :: Yes ,
1276
1272
ConstParamTyRibKind => {
1277
1273
if let Some ( span) = finalize {
1278
1274
self . report_error (
0 commit comments