Auto merge of #119606 - nnethercote:consuming-emit, r=oli-obk
Consuming `emit` This PR makes `DiagnosticBuilder::emit` consuming, i.e. take `self` instead of `&mut self`. This is good because it doesn't make sense to emit a diagnostic twice. This requires some changes to `DiagnosticBuilder` method changing -- every existing non-consuming chaining method gets a new consuming partner with a `_mv` suffix -- but permits a host of beneficial follow-up changes: more concise code through more chaining, removal of redundant diagnostic construction API methods, and removal of machinery to track the possibility of a diagnostic being emitted multiple times. r? `@compiler-errors`
This commit is contained in:
commit
ca663b06c5
112 changed files with 952 additions and 1275 deletions
|
|
@ -109,7 +109,7 @@ impl Msrv {
|
|||
if let Some(duplicate) = msrv_attrs.last() {
|
||||
sess.dcx()
|
||||
.struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
|
||||
.span_note(msrv_attr.span, "first definition found here")
|
||||
.span_note_mv(msrv_attr.span, "first definition found here")
|
||||
.emit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ pub fn get_unique_attr<'a>(
|
|||
if let Some(duplicate) = unique_attr {
|
||||
sess.dcx()
|
||||
.struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
|
||||
.span_note(duplicate.span, "first definition found here")
|
||||
.span_note_mv(duplicate.span, "first definition found here")
|
||||
.emit();
|
||||
} else {
|
||||
unique_attr = Some(attr);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ impl<'a> Parser<'a> {
|
|||
let mut parser = new_parser_from_file(sess.inner(), path, Some(span));
|
||||
match parser.parse_mod(&TokenKind::Eof) {
|
||||
Ok((a, i, spans)) => Some((a, i, spans.inner_span)),
|
||||
Err(mut e) => {
|
||||
Err(e) => {
|
||||
e.emit();
|
||||
if sess.can_reset_errors() {
|
||||
sess.reset_errors();
|
||||
|
|
@ -165,7 +165,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
match catch_unwind(move || parser.parse_crate_mod()) {
|
||||
Ok(Ok(k)) => Ok(k),
|
||||
Ok(Err(mut db)) => {
|
||||
Ok(Err(db)) => {
|
||||
db.emit();
|
||||
Err(ParserError::ParseError)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue