Disallow associated type constraints on negative bounds
This commit is contained in:
parent
6e01e910cb
commit
86f50b9f5c
6 changed files with 76 additions and 2 deletions
|
@ -1177,6 +1177,18 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// Negative trait bounds are not allowed to have associated constraints
|
||||
if let GenericBound::Trait(trait_ref, TraitBoundModifier::Negative) = bound
|
||||
&& let Some(segment) = trait_ref.trait_ref.path.segments.last()
|
||||
&& let Some(ast::GenericArgs::AngleBracketed(args)) = segment.args.as_deref()
|
||||
{
|
||||
for arg in &args.args {
|
||||
if let ast::AngleBracketedArg::Constraint(constraint) = arg {
|
||||
self.err_handler().emit_err(errors::ConstraintOnNegativeBound { span: constraint.span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_param_bound(self, bound)
|
||||
}
|
||||
|
||||
|
|
|
@ -701,3 +701,10 @@ pub struct NegativeBoundUnsupported {
|
|||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_passes_constraint_on_negative_bound)]
|
||||
pub struct ConstraintOnNegativeBound {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue