Ban non-static in const generics in AST.
This commit is contained in:
@@ -199,6 +199,11 @@ enum LifetimeRibKind {
|
||||
/// This rib declares generic parameters.
|
||||
Generics { parent: NodeId, span: Span, kind: LifetimeBinderKind },
|
||||
|
||||
/// FIXME(const_generics): This patches over an ICE caused by non-'static lifetimes in const
|
||||
/// generics. We are disallowing this until we can decide on how we want to handle non-'static
|
||||
/// lifetimes in const generics. See issue #74052 for discussion.
|
||||
ConstGeneric,
|
||||
|
||||
/// For **Modern** cases, create a new anonymous region parameter
|
||||
/// and reference that.
|
||||
///
|
||||
@@ -1102,14 +1107,18 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||
|
||||
this.ribs[TypeNS].push(Rib::new(ConstParamTyRibKind));
|
||||
this.ribs[ValueNS].push(Rib::new(ConstParamTyRibKind));
|
||||
this.visit_ty(ty);
|
||||
this.with_lifetime_rib(LifetimeRibKind::ConstGeneric, |this| {
|
||||
this.visit_ty(ty)
|
||||
});
|
||||
this.ribs[TypeNS].pop().unwrap();
|
||||
this.ribs[ValueNS].pop().unwrap();
|
||||
|
||||
if let Some(ref expr) = default {
|
||||
this.ribs[TypeNS].push(forward_ty_ban_rib);
|
||||
this.ribs[ValueNS].push(forward_const_ban_rib);
|
||||
this.visit_anon_const(expr);
|
||||
this.with_lifetime_rib(LifetimeRibKind::ConstGeneric, |this| {
|
||||
this.visit_anon_const(expr)
|
||||
});
|
||||
forward_const_ban_rib = this.ribs[ValueNS].pop().unwrap();
|
||||
forward_ty_ban_rib = this.ribs[TypeNS].pop().unwrap();
|
||||
}
|
||||
@@ -1158,8 +1167,14 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||
return;
|
||||
}
|
||||
|
||||
if let LifetimeRibKind::Item = rib.kind {
|
||||
break;
|
||||
match rib.kind {
|
||||
LifetimeRibKind::Item => break,
|
||||
LifetimeRibKind::ConstGeneric => {
|
||||
self.emit_non_static_lt_in_const_generic_error(lifetime);
|
||||
self.r.lifetimes_res_map.insert(lifetime.id, LifetimeRes::Error);
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user