Skip to content

Commit 5075457

Browse files
authored
Rollup merge of #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 b194b43 + 0fa5920 commit 5075457

File tree

3 files changed

+113
-116
lines changed

3 files changed

+113
-116
lines changed

Diff for: 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
}
@@ -1177,18 +1176,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11771176
| Res::SelfCtor(_) => {
11781177
for rib in ribs {
11791178
let has_generic_params: HasGenericParams = match rib.kind {
1180-
NormalRibKind
1181-
| ClosureOrAsyncRibKind
1182-
| ModuleRibKind(..)
1183-
| MacroDefinition(..)
1184-
| InlineAsmSymRibKind
1185-
| AssocItemRibKind
1186-
| ForwardGenericParamBanRibKind => {
1179+
RibKind::Normal
1180+
| RibKind::ClosureOrAsync
1181+
| RibKind::Module(..)
1182+
| RibKind::MacroDefinition(..)
1183+
| RibKind::InlineAsmSym
1184+
| RibKind::AssocItem
1185+
| RibKind::ForwardGenericParamBan => {
11871186
// Nothing to do. Continue.
11881187
continue;
11891188
}
11901189

1191-
ConstantItemRibKind(trivial, _) => {
1190+
RibKind::ConstantItem(trivial, _) => {
11921191
let features = self.tcx.sess.features_untracked();
11931192
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
11941193
if !(trivial == ConstantHasGenerics::Yes
@@ -1229,8 +1228,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12291228
}
12301229

12311230
// This was an attempt to use a type parameter outside its scope.
1232-
ItemRibKind(has_generic_params) => has_generic_params,
1233-
ConstParamTyRibKind => {
1231+
RibKind::Item(has_generic_params) => has_generic_params,
1232+
RibKind::ConstParamTy => {
12341233
if let Some(span) = finalize {
12351234
self.report_error(
12361235
span,
@@ -1256,15 +1255,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12561255
Res::Def(DefKind::ConstParam, _) => {
12571256
for rib in ribs {
12581257
let has_generic_params = match rib.kind {
1259-
NormalRibKind
1260-
| ClosureOrAsyncRibKind
1261-
| ModuleRibKind(..)
1262-
| MacroDefinition(..)
1263-
| InlineAsmSymRibKind
1264-
| AssocItemRibKind
1265-
| ForwardGenericParamBanRibKind => continue,
1266-
1267-
ConstantItemRibKind(trivial, _) => {
1258+
RibKind::Normal
1259+
| RibKind::ClosureOrAsync
1260+
| RibKind::Module(..)
1261+
| RibKind::MacroDefinition(..)
1262+
| RibKind::InlineAsmSym
1263+
| RibKind::AssocItem
1264+
| RibKind::ForwardGenericParamBan => continue,
1265+
1266+
RibKind::ConstantItem(trivial, _) => {
12681267
let features = self.tcx.sess.features_untracked();
12691268
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
12701269
if !(trivial == ConstantHasGenerics::Yes
@@ -1287,8 +1286,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12871286
continue;
12881287
}
12891288

1290-
ItemRibKind(has_generic_params) => has_generic_params,
1291-
ConstParamTyRibKind => {
1289+
RibKind::Item(has_generic_params) => has_generic_params,
1290+
RibKind::ConstParamTy => {
12921291
if let Some(span) = finalize {
12931292
self.report_error(
12941293
span,

0 commit comments

Comments
 (0)