diff options
| author | bors <bors@rust-lang.org> | 2024-01-08 16:06:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-08 16:06:28 +0000 |
| commit | ca663b06c5492ac2dde5e53cd11579fa8e4d68bd (patch) | |
| tree | dbc8c5a057699093a6c544c6df2d65accc0fffb5 /src | |
| parent | 0ee9cfd54db7b5f4be35f026588904500c866196 (diff) | |
| parent | db09eb2d3accf8909ea2813ebb00c58c7f2fad64 (diff) | |
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`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/config.rs | 10 | ||||
| -rw-r--r-- | src/librustdoc/core.rs | 12 | ||||
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 2 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_config/src/msrvs.rs | 2 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/attrs.rs | 2 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/parse/parser.rs | 4 |
7 files changed, 17 insertions, 17 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1a25d3f7993..0e81b31dd6c 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3001,7 +3001,7 @@ fn clean_use_statement_inner<'tcx>( E0780, "anonymous imports cannot be inlined" ) - .span_label(import.span, "anonymous import") + .span_label_mv(import.span, "anonymous import") .emit(); } diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index f3d63fad711..614a64d4020 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -577,13 +577,13 @@ impl Options { { if !theme_file.is_file() { dcx.struct_err(format!("invalid argument: \"{theme_s}\"")) - .help("arguments to --theme must be files") + .help_mv("arguments to --theme must be files") .emit(); return Err(1); } if theme_file.extension() != Some(OsStr::new("css")) { dcx.struct_err(format!("invalid argument: \"{theme_s}\"")) - .help("arguments to --theme must have a .css extension") + .help_mv("arguments to --theme must have a .css extension") .emit(); return Err(1); } @@ -595,8 +595,8 @@ impl Options { dcx.struct_warn(format!( "theme file \"{theme_s}\" is missing CSS rules from the default theme", )) - .warn("the theme may appear incorrect when loaded") - .help(format!( + .warn_mv("the theme may appear incorrect when loaded") + .help_mv(format!( "to see what rules are missing, call `rustdoc --check-theme \"{theme_s}\"`", )) .emit(); @@ -809,7 +809,7 @@ fn check_deprecated_options(matches: &getopts::Matches, dcx: &rustc_errors::Diag for &flag in deprecated_flags.iter() { if matches.opt_present(flag) { dcx.struct_warn(format!("the `{flag}` flag is deprecated")) - .note( + .note_mv( "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \ for more information", ) diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 359d5ec485e..40ea4346f93 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -495,16 +495,16 @@ impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> { .intersperse("::") .collect::<String>() ); - let mut err = rustc_errors::struct_span_err!( + rustc_errors::struct_span_err!( self.tcx.dcx(), path.span, E0433, "failed to resolve: {label}", - ); - err.span_label(path.span, label); - err.note("this error was originally ignored because you are running `rustdoc`"); - err.note("try running again with `rustc` or `cargo check` and you may get a more detailed error"); - err.emit(); + ) + .span_label_mv(path.span, label) + .note_mv("this error was originally ignored because you are running `rustdoc`") + .note_mv("try running again with `rustc` or `cargo check` and you may get a more detailed error") + .emit(); } // We could have an outer resolution that succeeded, // but with generic parameters that failed. diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 506eb56fdc8..176494a3863 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1228,7 +1228,7 @@ impl LinkCollector<'_, '_> { span, "linking to associated items of raw pointers is experimental", ) - .note("rustdoc does not allow disambiguating between `*const` and `*mut`, and pointers are unstable until it does") + .note_mv("rustdoc does not allow disambiguating between `*const` and `*mut`, and pointers are unstable until it does") .emit(); } diff --git a/src/tools/clippy/clippy_config/src/msrvs.rs b/src/tools/clippy/clippy_config/src/msrvs.rs index 471ad73e207..76f3663f04f 100644 --- a/src/tools/clippy/clippy_config/src/msrvs.rs +++ b/src/tools/clippy/clippy_config/src/msrvs.rs @@ -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(); } diff --git a/src/tools/clippy/clippy_utils/src/attrs.rs b/src/tools/clippy/clippy_utils/src/attrs.rs index db80e07ca1c..19d38903ade 100644 --- a/src/tools/clippy/clippy_utils/src/attrs.rs +++ b/src/tools/clippy/clippy_utils/src/attrs.rs @@ -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); diff --git a/src/tools/rustfmt/src/parse/parser.rs b/src/tools/rustfmt/src/parse/parser.rs index 6bc53159b38..7045a7dd9ce 100644 --- a/src/tools/rustfmt/src/parse/parser.rs +++ b/src/tools/rustfmt/src/parse/parser.rs @@ -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) } |
