Remove FnItemRibKind.
This commit is contained in:
parent
6e88d738be
commit
da9ccc2c98
2 changed files with 10 additions and 27 deletions
|
@ -1105,7 +1105,7 @@ impl<'a> Resolver<'a> {
|
||||||
| ForwardGenericParamBanRibKind => {
|
| ForwardGenericParamBanRibKind => {
|
||||||
// Nothing to do. Continue.
|
// Nothing to do. Continue.
|
||||||
}
|
}
|
||||||
ItemRibKind(_) | FnItemRibKind | AssocItemRibKind => {
|
ItemRibKind(_) | AssocItemRibKind => {
|
||||||
// This was an attempt to access an upvar inside a
|
// This was an attempt to access an upvar inside a
|
||||||
// named function item. This is not allowed, so we
|
// named function item. This is not allowed, so we
|
||||||
// report an error.
|
// report an error.
|
||||||
|
@ -1173,7 +1173,6 @@ impl<'a> Resolver<'a> {
|
||||||
| ModuleRibKind(..)
|
| ModuleRibKind(..)
|
||||||
| MacroDefinition(..)
|
| MacroDefinition(..)
|
||||||
| InlineAsmSymRibKind
|
| InlineAsmSymRibKind
|
||||||
| FnItemRibKind
|
|
||||||
| AssocItemRibKind
|
| AssocItemRibKind
|
||||||
| ForwardGenericParamBanRibKind => {
|
| ForwardGenericParamBanRibKind => {
|
||||||
// Nothing to do. Continue.
|
// Nothing to do. Continue.
|
||||||
|
@ -1236,14 +1235,6 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Res::Def(DefKind::ConstParam, _) => {
|
Res::Def(DefKind::ConstParam, _) => {
|
||||||
let mut ribs = ribs.iter().peekable();
|
|
||||||
if let Some(Rib { kind: FnItemRibKind, .. }) = ribs.peek() {
|
|
||||||
// When declaring const parameters inside function signatures, the first rib
|
|
||||||
// is always a `FnItemRibKind`. In this case, we can skip it, to avoid it
|
|
||||||
// (spuriously) conflicting with the const param.
|
|
||||||
ribs.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
for rib in ribs {
|
for rib in ribs {
|
||||||
let has_generic_params = match rib.kind {
|
let has_generic_params = match rib.kind {
|
||||||
NormalRibKind
|
NormalRibKind
|
||||||
|
@ -1251,7 +1242,6 @@ impl<'a> Resolver<'a> {
|
||||||
| ModuleRibKind(..)
|
| ModuleRibKind(..)
|
||||||
| MacroDefinition(..)
|
| MacroDefinition(..)
|
||||||
| InlineAsmSymRibKind
|
| InlineAsmSymRibKind
|
||||||
| FnItemRibKind
|
|
||||||
| AssocItemRibKind
|
| AssocItemRibKind
|
||||||
| ForwardGenericParamBanRibKind => continue,
|
| ForwardGenericParamBanRibKind => continue,
|
||||||
|
|
||||||
|
|
|
@ -132,10 +132,6 @@ pub(crate) enum RibKind<'a> {
|
||||||
/// We passed through a closure. Disallow labels.
|
/// We passed through a closure. Disallow labels.
|
||||||
ClosureOrAsyncRibKind,
|
ClosureOrAsyncRibKind,
|
||||||
|
|
||||||
/// We passed through a function definition. Disallow upvars.
|
|
||||||
/// Permit only those const parameters that are specified in the function's generics.
|
|
||||||
FnItemRibKind,
|
|
||||||
|
|
||||||
/// We passed through an item scope. Disallow upvars.
|
/// We passed through an item scope. Disallow upvars.
|
||||||
ItemRibKind(HasGenericParams),
|
ItemRibKind(HasGenericParams),
|
||||||
|
|
||||||
|
@ -172,7 +168,6 @@ impl RibKind<'_> {
|
||||||
match self {
|
match self {
|
||||||
NormalRibKind
|
NormalRibKind
|
||||||
| ClosureOrAsyncRibKind
|
| ClosureOrAsyncRibKind
|
||||||
| FnItemRibKind
|
|
||||||
| ConstantItemRibKind(..)
|
| ConstantItemRibKind(..)
|
||||||
| ModuleRibKind(_)
|
| ModuleRibKind(_)
|
||||||
| MacroDefinition(_)
|
| MacroDefinition(_)
|
||||||
|
@ -189,7 +184,6 @@ impl RibKind<'_> {
|
||||||
|
|
||||||
AssocItemRibKind
|
AssocItemRibKind
|
||||||
| ClosureOrAsyncRibKind
|
| ClosureOrAsyncRibKind
|
||||||
| FnItemRibKind
|
|
||||||
| ItemRibKind(..)
|
| ItemRibKind(..)
|
||||||
| ConstantItemRibKind(..)
|
| ConstantItemRibKind(..)
|
||||||
| ModuleRibKind(..)
|
| ModuleRibKind(..)
|
||||||
|
@ -793,7 +787,8 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn visit_fn(&mut self, fn_kind: FnKind<'ast>, sp: Span, fn_id: NodeId) {
|
fn visit_fn(&mut self, fn_kind: FnKind<'ast>, sp: Span, fn_id: NodeId) {
|
||||||
let rib_kind = match fn_kind {
|
let previous_value = self.diagnostic_metadata.current_function;
|
||||||
|
match fn_kind {
|
||||||
// Bail if the function is foreign, and thus cannot validly have
|
// Bail if the function is foreign, and thus cannot validly have
|
||||||
// a body, or if there's no body for some other reason.
|
// a body, or if there's no body for some other reason.
|
||||||
FnKind::Fn(FnCtxt::Foreign, _, sig, _, generics, _)
|
FnKind::Fn(FnCtxt::Foreign, _, sig, _, generics, _)
|
||||||
|
@ -816,20 +811,18 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FnKind::Fn(FnCtxt::Free, ..) => FnItemRibKind,
|
FnKind::Fn(..) => {
|
||||||
FnKind::Fn(FnCtxt::Assoc(_), ..) => NormalRibKind,
|
self.diagnostic_metadata.current_function = Some((fn_kind, sp));
|
||||||
FnKind::Closure(..) => ClosureOrAsyncRibKind,
|
}
|
||||||
|
// Do not update `current_function` for closures: it suggests `self` parameters.
|
||||||
|
FnKind::Closure(..) => {}
|
||||||
};
|
};
|
||||||
let previous_value = self.diagnostic_metadata.current_function;
|
|
||||||
if matches!(fn_kind, FnKind::Fn(..)) {
|
|
||||||
self.diagnostic_metadata.current_function = Some((fn_kind, sp));
|
|
||||||
}
|
|
||||||
debug!("(resolving function) entering function");
|
debug!("(resolving function) entering function");
|
||||||
|
|
||||||
// Create a value rib for the function.
|
// Create a value rib for the function.
|
||||||
self.with_rib(ValueNS, rib_kind, |this| {
|
self.with_rib(ValueNS, ClosureOrAsyncRibKind, |this| {
|
||||||
// Create a label rib for the function.
|
// Create a label rib for the function.
|
||||||
this.with_label_rib(FnItemRibKind, |this| {
|
this.with_label_rib(ClosureOrAsyncRibKind, |this| {
|
||||||
match fn_kind {
|
match fn_kind {
|
||||||
FnKind::Fn(_, _, sig, _, generics, body) => {
|
FnKind::Fn(_, _, sig, _, generics, body) => {
|
||||||
this.visit_generics(generics);
|
this.visit_generics(generics);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue