Rollup merge of #47613 - estebank:rustc_on_unimplemented, r=nikomatsakis
Add filtering options to `rustc_on_unimplemented` - Add filtering options to `rustc_on_unimplemented` for local traits, filtering on `Self` and type arguments. - Add a way to provide custom notes. - Tweak binops text. - Add filter to detect wether `Self` is local or belongs to another crate. - Add filter to `Iterator` diagnostic for `&str`. Partly addresses #44755 with a different syntax, as a first approach. Fixes #46216, fixes #37522, CC #34297, #46806.
This commit is contained in:
commit
aee22556a9
19 changed files with 234 additions and 83 deletions
|
@ -761,6 +761,18 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn expected_ident_found(&self) -> DiagnosticBuilder<'a> {
|
||||
let mut err = self.struct_span_err(self.span,
|
||||
&format!("expected identifier, found {}",
|
||||
self.this_token_descr()));
|
||||
if let Some(token_descr) = self.token_descr() {
|
||||
err.span_label(self.span, format!("expected identifier, found {}", token_descr));
|
||||
} else {
|
||||
err.span_label(self.span, "expected identifier");
|
||||
}
|
||||
err
|
||||
}
|
||||
|
||||
pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
|
||||
self.parse_ident_common(true)
|
||||
}
|
||||
|
@ -769,15 +781,7 @@ impl<'a> Parser<'a> {
|
|||
match self.token {
|
||||
token::Ident(i) => {
|
||||
if self.token.is_reserved_ident() {
|
||||
let mut err = self.struct_span_err(self.span,
|
||||
&format!("expected identifier, found {}",
|
||||
self.this_token_descr()));
|
||||
if let Some(token_descr) = self.token_descr() {
|
||||
err.span_label(self.span, format!("expected identifier, found {}",
|
||||
token_descr));
|
||||
} else {
|
||||
err.span_label(self.span, "expected identifier");
|
||||
}
|
||||
let mut err = self.expected_ident_found();
|
||||
if recover {
|
||||
err.emit();
|
||||
} else {
|
||||
|
@ -791,14 +795,7 @@ impl<'a> Parser<'a> {
|
|||
Err(if self.prev_token_kind == PrevTokenKind::DocComment {
|
||||
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
|
||||
} else {
|
||||
let mut err = self.fatal(&format!("expected identifier, found `{}`",
|
||||
self.this_token_to_string()));
|
||||
if let Some(token_descr) = self.token_descr() {
|
||||
err.span_label(self.span, format!("expected identifier, found {}",
|
||||
token_descr));
|
||||
} else {
|
||||
err.span_label(self.span, "expected identifier");
|
||||
}
|
||||
let mut err = self.expected_ident_found();
|
||||
if self.token == token::Underscore {
|
||||
err.note("`_` is a wildcard pattern, not an identifier");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue