Rename `*note_without_error` as `*note`.

Because the variant name in `Level` is `Note`, and the `without_error`
suffix is omitted in similar cases like `struct_allow` and
`struct_help`.
This commit is contained in:
Nicholas Nethercote 2023-11-30 14:01:35 +11:00
parent c3628bb970
commit 57d6f840b9
10 changed files with 25 additions and 45 deletions

View File

@ -1477,7 +1477,7 @@ fn print_native_static_libs(
sess.emit_note(errors::StaticLibraryNativeArtifacts);
// Prefix for greppability
// Note: This must not be translated as tools are allowed to depend on this exact string.
sess.note_without_error(format!("native-static-libs: {}", &lib_args.join(" ")));
sess.note(format!("native-static-libs: {}", &lib_args.join(" ")));
}
}
}

View File

@ -1870,7 +1870,7 @@ impl SharedEmitterMain {
let mut err = match level {
Level::Error { lint: false } => sess.struct_err(msg).forget_guarantee(),
Level::Warning(_) => sess.struct_warn(msg),
Level::Note => sess.struct_note_without_error(msg),
Level::Note => sess.struct_note(msg),
_ => bug!("Invalid inline asm diagnostic level"),
};

View File

@ -927,10 +927,7 @@ impl Handler {
/// Construct a builder at the `Note` level with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_note_without_error(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ()> {
pub fn struct_note(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Level::Note, msg)
}
@ -1022,11 +1019,7 @@ impl Handler {
#[track_caller]
#[rustc_lint_diagnostics]
pub fn span_note_without_error(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
) {
pub fn span_note(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
self.emit_diag_at_span(Diagnostic::new(Note, msg), span);
}
@ -1059,7 +1052,7 @@ impl Handler {
}
#[rustc_lint_diagnostics]
pub fn note_without_error(&self, msg: impl Into<DiagnosticMessage>) {
pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
DiagnosticBuilder::new(self, Note, msg).emit();
}

View File

@ -648,10 +648,8 @@ fn is_empty_token_tree(sess: &ParseSess, seq: &mbe::SequenceRepetition) -> bool
iter.next();
}
let span = t.span.to(now.span);
sess.span_diagnostic.span_note_without_error(
span,
"doc comments are ignored in matcher position",
);
sess.span_diagnostic
.span_note(span, "doc comments are ignored in matcher position");
}
mbe::TokenTree::Sequence(_, sub_seq)
if (sub_seq.kleene.op == mbe::KleeneOp::ZeroOrMore

View File

@ -357,7 +357,7 @@ fn parse_sep_and_kleene_op<'a>(
fn span_dollar_dollar_or_metavar_in_the_lhs_err(sess: &ParseSess, token: &Token) {
sess.span_diagnostic
.span_err(token.span, format!("unexpected token: {}", pprust::token_to_string(token)));
sess.span_diagnostic.span_note_without_error(
sess.span_diagnostic.span_note(
token.span,
"`$$` and meta-variable expressions are not allowed inside macro parameter definitions",
);

View File

@ -420,20 +420,16 @@ fn fatally_break_rust(tcx: TyCtxt<'_>) {
MultiSpan::new(),
"It looks like you're trying to break rust; would you like some ICE?",
);
handler.note_without_error("the compiler expectedly panicked. this is a feature.");
handler.note_without_error(
handler.note("the compiler expectedly panicked. this is a feature.");
handler.note(
"we would appreciate a joke overview: \
https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675",
);
handler.note_without_error(format!(
"rustc {} running on {}",
tcx.sess.cfg_version,
config::host_triple(),
));
handler.note(format!("rustc {} running on {}", tcx.sess.cfg_version, config::host_triple(),));
if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() {
handler.note_without_error(format!("compiler flags: {}", flags.join(" ")));
handler.note(format!("compiler flags: {}", flags.join(" ")));
if excluded_cargo_defaults {
handler.note_without_error("some of the compiler flags provided by cargo are hidden");
handler.note("some of the compiler flags provided by cargo are hidden");
}
}
}

View File

@ -653,30 +653,23 @@ impl Session {
#[rustc_lint_diagnostics]
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn note_without_error(&self, msg: impl Into<DiagnosticMessage>) {
self.diagnostic().note_without_error(msg)
pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
self.diagnostic().note(msg)
}
#[track_caller]
#[rustc_lint_diagnostics]
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn span_note_without_error<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
) {
self.diagnostic().span_note_without_error(sp, msg)
pub fn span_note<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
self.diagnostic().span_note(sp, msg)
}
#[rustc_lint_diagnostics]
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn struct_note_without_error(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_note_without_error(msg)
pub fn struct_note(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_note(msg)
}
#[inline]
@ -1743,7 +1736,7 @@ impl EarlyErrorHandler {
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_note(&self, msg: impl Into<DiagnosticMessage>) {
self.handler.struct_note_without_error(msg).emit()
self.handler.struct_note(msg).emit()
}
#[allow(rustc::untranslatable_diagnostic)]

View File

@ -183,7 +183,7 @@ pub fn main() {
// as simple as moving the call from the hook to main, because `install_ice_hook` doesn't
// accept a generic closure.
let version_info = rustc_tools_util::get_version_info!();
handler.note_without_error(format!("Clippy version: {version_info}"));
handler.note(format!("Clippy version: {version_info}"));
});
exit(rustc_driver::catch_with_exit_code(move || {

View File

@ -384,7 +384,7 @@ pub fn report_error<'tcx, 'mir>(
// Include a note like `std` does when we omit frames from a backtrace
if was_pruned {
ecx.tcx.sess.diagnostic().note_without_error(
ecx.tcx.sess.diagnostic().note(
"some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace",
);
}
@ -431,7 +431,7 @@ pub fn report_leaks<'mir, 'tcx>(
);
}
if any_pruned {
ecx.tcx.sess.diagnostic().note_without_error(
ecx.tcx.sess.diagnostic().note(
"some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace",
);
}

View File

@ -464,7 +464,7 @@ pub fn eval_entry<'tcx>(
// Check for thread leaks.
if !ecx.have_all_terminated() {
tcx.sess.err("the main thread terminated without waiting for all remaining threads");
tcx.sess.note_without_error("pass `-Zmiri-ignore-leaks` to disable this check");
tcx.sess.note("pass `-Zmiri-ignore-leaks` to disable this check");
return None;
}
// Check for memory leaks.
@ -475,7 +475,7 @@ pub fn eval_entry<'tcx>(
let leak_message = "the evaluated program leaked memory, pass `-Zmiri-ignore-leaks` to disable this check";
if ecx.machine.collect_leak_backtraces {
// If we are collecting leak backtraces, each leak is a distinct error diagnostic.
tcx.sess.note_without_error(leak_message);
tcx.sess.note(leak_message);
} else {
// If we do not have backtraces, we just report an error without any span.
tcx.sess.err(leak_message);