Skip to content

Conversation

@Muscraft
Copy link
Member

@Muscraft Muscraft commented Oct 27, 2025

This PR switches the default renderer to use annotate-snippets on nightly, but does not affect stable. This is part of the ongoing effort to use annotate-snippets to render all diagnostics.

MCP

Note: This contains the test change from #148004, without the change to the default emitter.

#59346
rust-lang/rust-project-goals#123

r? @davidtwco

@rustbot
Copy link
Collaborator

rustbot commented Oct 27, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 27, 2025
@Kobzol
Copy link
Member

Kobzol commented Oct 27, 2025

@bors try @rust-timer queue

Let's test perf outright :)

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 27, 2025
…, r=<try>

feat: Use annotate-snippets by default on nightly
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 27, 2025
@rust-log-analyzer

This comment has been minimized.

@fmease fmease added the S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. label Oct 27, 2025
@Muscraft Muscraft force-pushed the annotate-snippets-default-on-nightly branch from 32fab73 to 249682e Compare October 27, 2025 20:22
Comment on lines +381 to +412
match je.json_rendered {
HumanReadableErrorType::AnnotateSnippet { short, unicode } => {
AnnotateSnippetEmitter::new(dst, je.translator.clone())
.short_message(short)
.sm(je.sm.clone())
.diagnostic_width(je.diagnostic_width)
.macro_backtrace(je.macro_backtrace)
.track_diagnostics(je.track_diagnostics)
.terminal_url(je.terminal_url)
.ui_testing(je.ui_testing)
.ignored_directories_in_source_blocks(
je.ignored_directories_in_source_blocks.clone(),
)
.theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii })
.emit_diagnostic(diag, registry)
}
HumanReadableErrorType::Default { short } => {
HumanEmitter::new(dst, je.translator.clone())
.short_message(short)
.sm(je.sm.clone())
.diagnostic_width(je.diagnostic_width)
.macro_backtrace(je.macro_backtrace)
.track_diagnostics(je.track_diagnostics)
.terminal_url(je.terminal_url)
.ui_testing(je.ui_testing)
.ignored_directories_in_source_blocks(
je.ignored_directories_in_source_blocks.clone(),
)
.theme(OutputTheme::Ascii)
.emit_diagnostic(diag, registry)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be nicer to do

Suggested change
match je.json_rendered {
HumanReadableErrorType::AnnotateSnippet { short, unicode } => {
AnnotateSnippetEmitter::new(dst, je.translator.clone())
.short_message(short)
.sm(je.sm.clone())
.diagnostic_width(je.diagnostic_width)
.macro_backtrace(je.macro_backtrace)
.track_diagnostics(je.track_diagnostics)
.terminal_url(je.terminal_url)
.ui_testing(je.ui_testing)
.ignored_directories_in_source_blocks(
je.ignored_directories_in_source_blocks.clone(),
)
.theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii })
.emit_diagnostic(diag, registry)
}
HumanReadableErrorType::Default { short } => {
HumanEmitter::new(dst, je.translator.clone())
.short_message(short)
.sm(je.sm.clone())
.diagnostic_width(je.diagnostic_width)
.macro_backtrace(je.macro_backtrace)
.track_diagnostics(je.track_diagnostics)
.terminal_url(je.terminal_url)
.ui_testing(je.ui_testing)
.ignored_directories_in_source_blocks(
je.ignored_directories_in_source_blocks.clone(),
)
.theme(OutputTheme::Ascii)
.emit_diagnostic(diag, registry)
}
}
let (short, unicode) = match je.json_rendered {
HumanReadableErrorType::AnnotateSnippet { short, unicode } => (short, unicode),
HumanReadableErrorType::Default { short } => (short, false),
};
HumanEmitter::new(dst, je.translator.clone())
.short_message(short)
.sm(je.sm.clone())
.diagnostic_width(je.diagnostic_width)
.macro_backtrace(je.macro_backtrace)
.track_diagnostics(je.track_diagnostics)
.terminal_url(je.terminal_url)
.ui_testing(je.ui_testing)
.ignored_directories_in_source_blocks(
je.ignored_directories_in_source_blocks.clone(),
)
.theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii })
.emit_diagnostic(diag, registry)

@rust-log-analyzer

This comment has been minimized.

@Muscraft Muscraft force-pushed the annotate-snippets-default-on-nightly branch from 249682e to af7d82c Compare October 27, 2025 21:06
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/errors/emitter-overflow-bad-whitespace.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/errors/emitter-overflow-bad-whitespace.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/errors/emitter-overflow-bad-whitespace" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--diagnostic-width=1"
stdout: none
--- stderr -------------------------------

thread 'rustc' (72678) panicked at /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/annotate-snippets-0.12.7/src/renderer/margin.rs:74:16:
attempt to subtract with overflow
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_const::panic_const_sub_overflow
   3: <annotate_snippets::renderer::margin::Margin>::new
   4: annotate_snippets::renderer::render::render_snippet_annotations
   5: annotate_snippets::renderer::render::render
   6: <rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter>::emit_messages_default
   7: <rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
   8: <rustc_errors::json::Diagnostic>::from_errors_diagnostic
   9: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  10: <rustc_errors::DiagCtxtInner>::emit_diagnostic::{closure#3}
  11: rustc_interface::callbacks::track_diagnostic::<core::option::Option<rustc_span::ErrorGuaranteed>>
  12: <rustc_errors::DiagCtxtInner>::emit_diagnostic
  13: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
  14: <rustc_errors::diagnostic::Diag>::emit_producing_error_guaranteed
  15: <rustc_parse::lexer::Lexer>::next_token_from_cursor
  16: <rustc_parse::lexer::Lexer>::lex_token_trees
  17: rustc_parse::lexer::lex_token_trees
  18: rustc_parse::source_file_to_stream
  19: rustc_parse::new_parser_from_source_file
  20: rustc_parse::new_parser_from_file
  21: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::diagnostic::Diag>, rustc_interface::passes::parse::{closure#0}>
  22: rustc_interface::passes::parse
---
note: please make sure that you have updated to the latest nightly

note: rustc 1.93.0-nightly (dc4b015aa 2025-10-27) running on aarch64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
end of query stack
error: aborting due to 1 previous error
------------------------------------------

@rust-bors
Copy link

rust-bors bot commented Oct 27, 2025

☀️ Try build successful (CI)
Build commit: 9642289 (9642289ca0cc666c0a012091ea4605836db294e4, parent: 9ea8d67cc60e88ad6fffbf299a454c44227e001c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9642289): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.6% [0.3%, 0.9%] 12
Regressions ❌
(secondary)
0.4% [0.1%, 1.1%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [0.3%, 0.9%] 12

Max RSS (memory usage)

Results (secondary 1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.2% [2.4%, 4.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary -5.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.4% [-5.4%, -5.4%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 474.628s -> 473.869s (-0.16%)
Artifact size: 390.61 MiB -> 390.65 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants