Disentangle ForwardGenericParamBan and ConstParamTy ribs
This commit is contained in:
parent
0998d4095b
commit
42773bfcac
29 changed files with 196 additions and 114 deletions
|
@ -1117,13 +1117,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
debug!("validate_res_from_ribs({:?})", res);
|
||||
let ribs = &all_ribs[rib_index + 1..];
|
||||
|
||||
// An invalid forward use of a generic parameter from a previous default.
|
||||
if let RibKind::ForwardGenericParamBan = all_ribs[rib_index].kind {
|
||||
// An invalid forward use of a generic parameter from a previous default
|
||||
// or in a const param ty.
|
||||
if let RibKind::ForwardGenericParamBan(reason) = all_ribs[rib_index].kind {
|
||||
if let Some(span) = finalize {
|
||||
let res_error = if rib_ident.name == kw::SelfUpper {
|
||||
ResolutionError::SelfInGenericParamDefault
|
||||
ResolutionError::ForwardDeclaredSelf(reason)
|
||||
} else {
|
||||
ResolutionError::ForwardDeclaredGenericParam
|
||||
ResolutionError::ForwardDeclaredGenericParam(rib_ident.name, reason)
|
||||
};
|
||||
self.report_error(span, res_error);
|
||||
}
|
||||
|
@ -1131,17 +1132,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
return Res::Err;
|
||||
}
|
||||
|
||||
if let RibKind::ConstParamTy = all_ribs[rib_index].kind {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInTyOfConstParam { name: rib_ident.name },
|
||||
);
|
||||
}
|
||||
assert_eq!(res, Res::Err);
|
||||
return Res::Err;
|
||||
}
|
||||
|
||||
match res {
|
||||
Res::Local(_) => {
|
||||
use ResolutionError::*;
|
||||
|
@ -1153,7 +1143,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
| RibKind::FnOrCoroutine
|
||||
| RibKind::Module(..)
|
||||
| RibKind::MacroDefinition(..)
|
||||
| RibKind::ForwardGenericParamBan => {
|
||||
| RibKind::ForwardGenericParamBan(_) => {
|
||||
// Nothing to do. Continue.
|
||||
}
|
||||
RibKind::Item(..) | RibKind::AssocItem => {
|
||||
|
@ -1247,12 +1237,27 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
| RibKind::MacroDefinition(..)
|
||||
| RibKind::InlineAsmSym
|
||||
| RibKind::AssocItem
|
||||
| RibKind::ConstParamTy
|
||||
| RibKind::ForwardGenericParamBan => {
|
||||
| RibKind::ForwardGenericParamBan(_) => {
|
||||
// Nothing to do. Continue.
|
||||
continue;
|
||||
}
|
||||
|
||||
RibKind::ConstParamTy => {
|
||||
if !self.tcx.features().generic_const_parameter_types() {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
},
|
||||
);
|
||||
}
|
||||
return Res::Err;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
RibKind::ConstantItem(trivial, _) => {
|
||||
if let ConstantHasGenerics::No(cause) = trivial {
|
||||
// HACK(min_const_generics): If we encounter `Self` in an anonymous
|
||||
|
@ -1325,8 +1330,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
| RibKind::MacroDefinition(..)
|
||||
| RibKind::InlineAsmSym
|
||||
| RibKind::AssocItem
|
||||
| RibKind::ConstParamTy
|
||||
| RibKind::ForwardGenericParamBan => continue,
|
||||
| RibKind::ForwardGenericParamBan(_) => continue,
|
||||
|
||||
RibKind::ConstParamTy => {
|
||||
if !self.tcx.features().generic_const_parameter_types() {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
},
|
||||
);
|
||||
}
|
||||
return Res::Err;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
RibKind::ConstantItem(trivial, _) => {
|
||||
if let ConstantHasGenerics::No(cause) = trivial {
|
||||
|
@ -1377,6 +1397,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue