Skip to content

Commit 785e513

Browse files
authored
Rollup merge of rust-lang#111070 - WaffleLapkin:break_ribs, r=lcnr
Don't suffix `RibKind` variants This PR - Removes `use RibKind::*` - Renames `RibKind::{SomethingRibKind => Something}` It seems unnecessary to have "RibKind" in the end of all variants, if we can just use it as a normal enum. Additionally previously it was weird that `MacroDefinition` is the only unsuffixed variant.
2 parents c5a4b40 + 0fa5920 commit 785e513

File tree

3 files changed

+113
-116
lines changed

3 files changed

+113
-116
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::Module(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::ForwardGenericParamBan = 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::Normal
1107+
| RibKind::ClosureOrAsync
1108+
| RibKind::Module(..)
1109+
| RibKind::MacroDefinition(..)
1110+
| RibKind::ForwardGenericParamBan => {
11121111
// Nothing to do. Continue.
11131112
}
1114-
ItemRibKind(_) | AssocItemRibKind => {
1113+
RibKind::Item(_) | RibKind::AssocItem => {
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::ConstantItem(_, 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::ConstParamTy => {
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::InlineAsmSym => {
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::Normal
1177+
| RibKind::ClosureOrAsync
1178+
| RibKind::Module(..)
1179+
| RibKind::MacroDefinition(..)
1180+
| RibKind::InlineAsmSym
1181+
| RibKind::AssocItem
1182+
| RibKind::ForwardGenericParamBan => {
11841183
// Nothing to do. Continue.
11851184
continue;
11861185
}
11871186

1188-
ConstantItemRibKind(trivial, _) => {
1187+
RibKind::ConstantItem(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::Item(has_generic_params) => has_generic_params,
1229+
RibKind::ConstParamTy => {
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::Normal
1256+
| RibKind::ClosureOrAsync
1257+
| RibKind::Module(..)
1258+
| RibKind::MacroDefinition(..)
1259+
| RibKind::InlineAsmSym
1260+
| RibKind::AssocItem
1261+
| RibKind::ForwardGenericParamBan => continue,
1262+
1263+
RibKind::ConstantItem(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::Item(has_generic_params) => has_generic_params,
1287+
RibKind::ConstParamTy => {
12891288
if let Some(span) = finalize {
12901289
self.report_error(
12911290
span,

0 commit comments

Comments
 (0)