lowering of generic args in AssocTyConstraint
This commit is contained in:
parent
16af7bf3d9
commit
760a6654fb
2 changed files with 37 additions and 9 deletions
|
@ -1076,16 +1076,40 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
fn lower_assoc_ty_constraint(
|
||||
&mut self,
|
||||
constraint: &AssocTyConstraint,
|
||||
itctx: ImplTraitContext<'_, 'hir>,
|
||||
mut itctx: ImplTraitContext<'_, 'hir>,
|
||||
) -> hir::TypeBinding<'hir> {
|
||||
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx);
|
||||
|
||||
if let Some(ref gen_args) = constraint.gen_args {
|
||||
self.sess.span_fatal(
|
||||
gen_args.span(),
|
||||
"generic associated types in trait paths are currently not implemented",
|
||||
);
|
||||
}
|
||||
// lower generic arguments of identifier in constraint
|
||||
let gen_args = if let Some(ref gen_args) = constraint.gen_args {
|
||||
let gen_args_ctor = match gen_args {
|
||||
GenericArgs::AngleBracketed(ref data) => {
|
||||
self.lower_angle_bracketed_parameter_data(
|
||||
data,
|
||||
ParamMode::Explicit,
|
||||
itctx.reborrow(),
|
||||
)
|
||||
.0
|
||||
}
|
||||
GenericArgs::Parenthesized(ref data) => {
|
||||
let mut err = self.sess.struct_span_err(
|
||||
gen_args.span(),
|
||||
"parenthesized generic arguments cannot be used in associated type constraints"
|
||||
);
|
||||
// FIXME: try to write a suggestion here
|
||||
err.emit();
|
||||
self.lower_angle_bracketed_parameter_data(
|
||||
&data.as_angle_bracketed_args(),
|
||||
ParamMode::Explicit,
|
||||
itctx.reborrow(),
|
||||
)
|
||||
.0
|
||||
}
|
||||
};
|
||||
self.arena.alloc(gen_args_ctor.into_generic_args(&self.arena))
|
||||
} else {
|
||||
self.arena.alloc(hir::GenericArgs::none())
|
||||
};
|
||||
|
||||
let kind = match constraint.kind {
|
||||
AssocTyConstraintKind::Equality { ref ty } => {
|
||||
|
@ -1182,6 +1206,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
hir::TypeBinding {
|
||||
hir_id: self.lower_node_id(constraint.id),
|
||||
ident: constraint.ident,
|
||||
gen_args,
|
||||
kind,
|
||||
span: constraint.span,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue