Skip to content

Commit 6197e4d

Browse files
committed
Don't use RibKind::*
1 parent 4b87ed9 commit 6197e4d

File tree

2 files changed

+108
-105
lines changed

2 files changed

+108
-105
lines changed

compiler/rustc_resolve/src/ident.rs

+33-34
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::{ResolutionError, Resolver, Scope, ScopeSet, Segment, ToNameBinding,
2424

2525
use Determinacy::*;
2626
use Namespace::*;
27-
use RibKind::*;
2827

2928
type Visibility = ty::Visibility<LocalDefId>;
3029

@@ -324,8 +323,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
324323
}
325324

326325
module = match ribs[i].kind {
327-
ModuleRibKind(module) => module,
328-
MacroDefinition(def) if def == self.macro_def(ident.span.ctxt()) => {
326+
RibKind::ModuleRibKind(module) => module,
327+
RibKind::MacroDefinition(def) if def == self.macro_def(ident.span.ctxt()) => {
329328
// If an invocation of this macro created `ident`, give up on `ident`
330329
// and switch to `ident`'s source from the macro definition.
331330
ident.span.remove_mark();
@@ -1084,7 +1083,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
10841083
let ribs = &all_ribs[rib_index + 1..];
10851084

10861085
// An invalid forward use of a generic parameter from a previous default.
1087-
if let ForwardGenericParamBanRibKind = all_ribs[rib_index].kind {
1086+
if let RibKind::ForwardGenericParamBanRibKind = all_ribs[rib_index].kind {
10881087
if let Some(span) = finalize {
10891088
let res_error = if rib_ident.name == kw::SelfUpper {
10901089
ResolutionError::SelfInGenericParamDefault
@@ -1104,14 +1103,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11041103

11051104
for rib in ribs {
11061105
match rib.kind {
1107-
NormalRibKind
1108-
| ClosureOrAsyncRibKind
1109-
| ModuleRibKind(..)
1110-
| MacroDefinition(..)
1111-
| ForwardGenericParamBanRibKind => {
1106+
RibKind::NormalRibKind
1107+
| RibKind::ClosureOrAsyncRibKind
1108+
| RibKind::ModuleRibKind(..)
1109+
| RibKind::MacroDefinition(..)
1110+
| RibKind::ForwardGenericParamBanRibKind => {
11121111
// Nothing to do. Continue.
11131112
}
1114-
ItemRibKind(_) | AssocItemRibKind => {
1113+
RibKind::ItemRibKind(_) | RibKind::AssocItemRibKind => {
11151114
// This was an attempt to access an upvar inside a
11161115
// named function item. This is not allowed, so we
11171116
// report an error.
@@ -1123,7 +1122,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11231122
res_err = Some((span, CannotCaptureDynamicEnvironmentInFnItem));
11241123
}
11251124
}
1126-
ConstantItemRibKind(_, item) => {
1125+
RibKind::ConstantItemRibKind(_, item) => {
11271126
// Still doesn't deal with upvars
11281127
if let Some(span) = finalize {
11291128
let (span, resolution_error) =
@@ -1152,13 +1151,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11521151
}
11531152
return Res::Err;
11541153
}
1155-
ConstParamTyRibKind => {
1154+
RibKind::ConstParamTyRibKind => {
11561155
if let Some(span) = finalize {
11571156
self.report_error(span, ParamInTyOfConstParam(rib_ident.name));
11581157
}
11591158
return Res::Err;
11601159
}
1161-
InlineAsmSymRibKind => {
1160+
RibKind::InlineAsmSymRibKind => {
11621161
if let Some(span) = finalize {
11631162
self.report_error(span, InvalidAsmSym);
11641163
}
@@ -1174,18 +1173,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11741173
Res::Def(DefKind::TyParam, _) | Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } => {
11751174
for rib in ribs {
11761175
let has_generic_params: HasGenericParams = match rib.kind {
1177-
NormalRibKind
1178-
| ClosureOrAsyncRibKind
1179-
| ModuleRibKind(..)
1180-
| MacroDefinition(..)
1181-
| InlineAsmSymRibKind
1182-
| AssocItemRibKind
1183-
| ForwardGenericParamBanRibKind => {
1176+
RibKind::NormalRibKind
1177+
| RibKind::ClosureOrAsyncRibKind
1178+
| RibKind::ModuleRibKind(..)
1179+
| RibKind::MacroDefinition(..)
1180+
| RibKind::InlineAsmSymRibKind
1181+
| RibKind::AssocItemRibKind
1182+
| RibKind::ForwardGenericParamBanRibKind => {
11841183
// Nothing to do. Continue.
11851184
continue;
11861185
}
11871186

1188-
ConstantItemRibKind(trivial, _) => {
1187+
RibKind::ConstantItemRibKind(trivial, _) => {
11891188
let features = self.tcx.sess.features_untracked();
11901189
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
11911190
if !(trivial == ConstantHasGenerics::Yes
@@ -1226,8 +1225,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12261225
}
12271226

12281227
// This was an attempt to use a type parameter outside its scope.
1229-
ItemRibKind(has_generic_params) => has_generic_params,
1230-
ConstParamTyRibKind => {
1228+
RibKind::ItemRibKind(has_generic_params) => has_generic_params,
1229+
RibKind::ConstParamTyRibKind => {
12311230
if let Some(span) = finalize {
12321231
self.report_error(
12331232
span,
@@ -1253,15 +1252,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12531252
Res::Def(DefKind::ConstParam, _) => {
12541253
for rib in ribs {
12551254
let has_generic_params = match rib.kind {
1256-
NormalRibKind
1257-
| ClosureOrAsyncRibKind
1258-
| ModuleRibKind(..)
1259-
| MacroDefinition(..)
1260-
| InlineAsmSymRibKind
1261-
| AssocItemRibKind
1262-
| ForwardGenericParamBanRibKind => continue,
1263-
1264-
ConstantItemRibKind(trivial, _) => {
1255+
RibKind::NormalRibKind
1256+
| RibKind::ClosureOrAsyncRibKind
1257+
| RibKind::ModuleRibKind(..)
1258+
| RibKind::MacroDefinition(..)
1259+
| RibKind::InlineAsmSymRibKind
1260+
| RibKind::AssocItemRibKind
1261+
| RibKind::ForwardGenericParamBanRibKind => continue,
1262+
1263+
RibKind::ConstantItemRibKind(trivial, _) => {
12651264
let features = self.tcx.sess.features_untracked();
12661265
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
12671266
if !(trivial == ConstantHasGenerics::Yes
@@ -1284,8 +1283,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12841283
continue;
12851284
}
12861285

1287-
ItemRibKind(has_generic_params) => has_generic_params,
1288-
ConstParamTyRibKind => {
1286+
RibKind::ItemRibKind(has_generic_params) => has_generic_params,
1287+
RibKind::ConstParamTyRibKind => {
12891288
if let Some(span) = finalize {
12901289
self.report_error(
12911290
span,

0 commit comments

Comments
 (0)