Rollup merge of #119154 - surechen:fix_119067, r=fmease
Simple modification of `non_lifetime_binders`'s diagnostic information to adapt to type binders fixes #119067 Replace diagnostic information "lifetime bounds cannot be used in this context" to "bounds cannot be used in this context". ```rust #![allow(incomplete_features)] #![feature(non_lifetime_binders)] trait Trait {} trait Trait2 where for <T: Trait> ():{} //~^ ERROR bounds cannot be used in this context ```
This commit is contained in:
commit
2b48e7dbcb
15 changed files with 91 additions and 40 deletions
|
@ -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>,
|
||||
}
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue