review, improve note span

This commit is contained in:
Bastian Kauschke 2020-09-08 11:37:27 +02:00
parent e5b82a56c5
commit c552717e9d
5 changed files with 40 additions and 41 deletions

View file

@ -2627,25 +2627,23 @@ impl<'a> Resolver<'a> {
continue;
}
ConstantItemRibKind(trivial) => {
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;
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
if !trivial && self.session.features_untracked().min_const_generics {
// 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;
}
}