allow concrete self types in consts
This commit is contained in:
parent
7402a39447
commit
e5b82a56c5
11 changed files with 141 additions and 18 deletions
|
@ -2539,7 +2539,7 @@ impl<'a> Resolver<'a> {
|
|||
&mut self,
|
||||
rib_index: usize,
|
||||
rib_ident: Ident,
|
||||
res: Res,
|
||||
mut res: Res,
|
||||
record_used: bool,
|
||||
span: Span,
|
||||
all_ribs: &[Rib<'a>],
|
||||
|
@ -2627,15 +2627,26 @@ impl<'a> Resolver<'a> {
|
|||
continue;
|
||||
}
|
||||
ConstantItemRibKind(trivial) => {
|
||||
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
|
||||
if !trivial && self.session.features_untracked().min_const_generics {
|
||||
if record_used {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInNonTrivialAnonConst(rib_ident.name),
|
||||
);
|
||||
if self.session.features_untracked().min_const_generics {
|
||||
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
|
||||
if !trivial {
|
||||
// HACK(min_const_generics): If we encounter `Self` in an anonymous constant
|
||||
// we can't easily tell if it's generic at this stage, so we instead remember
|
||||
// this and then enforce the self type to be concrete later on.
|
||||
if let Res::SelfTy(trait_def, Some((impl_def, _))) = res {
|
||||
res = Res::SelfTy(trait_def, Some((impl_def, true)));
|
||||
} else {
|
||||
if record_used {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInNonTrivialAnonConst(
|
||||
rib_ident.name,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Res::Err;
|
||||
}
|
||||
}
|
||||
return Res::Err;
|
||||
}
|
||||
|
||||
if in_ty_param_default {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue