1
Fork 0

Simple modification of diagnostic information

fixes #119067
This commit is contained in:
surechen 2023-12-20 15:06:36 +08:00
parent b37d43efd9
commit 4897d5eccf
15 changed files with 91 additions and 40 deletions

View file

@ -52,8 +52,8 @@ pub struct TraitFnConst {
}
#[derive(Diagnostic)]
#[diag(ast_passes_forbidden_lifetime_bound)]
pub struct ForbiddenLifetimeBound {
#[diag(ast_passes_forbidden_bound)]
pub struct ForbiddenBound {
#[primary_span]
pub spans: Vec<Span>,
}

View file

@ -152,8 +152,8 @@ impl<'a> PostExpansionVisitor<'a> {
}
fn check_late_bound_lifetime_defs(&self, params: &[ast::GenericParam]) {
// Check only lifetime parameters are present and that the lifetime
// parameters that are present have no bounds.
// Check only lifetime parameters are present and that the
// generic parameters that are present have no bounds.
let non_lt_param_spans = params.iter().filter_map(|param| match param.kind {
ast::GenericParamKind::Lifetime { .. } => None,
_ => Some(param.ident.span),
@ -164,10 +164,11 @@ impl<'a> PostExpansionVisitor<'a> {
non_lt_param_spans,
crate::fluent_generated::ast_passes_forbidden_non_lifetime_param
);
for param in params {
if !param.bounds.is_empty() {
let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect();
self.sess.emit_err(errors::ForbiddenLifetimeBound { spans });
self.sess.emit_err(errors::ForbiddenBound { spans });
}
}
}