Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c4c6569
mention the opaque when its hidden type cannot be inferred
Albab-Hasan Sep 2, 2026
9bce023
Upgrade windows-bindgen in generate-windows-sys
ChrisDenton Sep 4, 2026
c27758d
Generate new windows bindings
ChrisDenton Sep 4, 2026
97b1d00
Revert "Rollup merge - CAD97:xdg_basedir, r=aapoalas"
CAD97 Jun 22, 2026
25ee3c3
Align LoongArch64 Linux segments with GNU LD
heiher Sep 8, 2026
f934918
yeet StabilityLevel
mejrs Sep 9, 2026
5fc43e8
Use lld by default on loongarch64-unknown-linux-gnu nightly
heiher Sep 8, 2026
6581f4c
Test the missing Clone requirement for Cow slices
chenyukang Sep 10, 2026
4b5434b
Document transmute layout trees and test alternative pruning
joshlf Sep 10, 2026
c4d1307
Clarify transmutability queries and cover answer composition
joshlf Sep 10, 2026
eb7625d
Document DFA interval union and improve debug output
joshlf Sep 10, 2026
ac29954
Exercise nonzero-sized uninhabited destinations
joshlf Sep 10, 2026
b760816
iter::repeate_with and iter::successors added as diagnostic items (re…
voodookiidoo Sep 10, 2026
7bc87d5
Remove most `Style` variants
nnethercote Sep 8, 2026
63fddb3
Remove `Style::HeaderMsg`
nnethercote Sep 8, 2026
025e029
Reduce unnecessary `Cow` use in error formatting
nnethercote Sep 8, 2026
996ef5d
Replace a `format_diag_messages` use
nnethercote Sep 8, 2026
a956ff0
Tweak a `use` item
nnethercote Sep 8, 2026
6331ab6
Introduce `Sublevel` for errors
nnethercote Sep 8, 2026
23b52a6
iter::from_fn added as diagnostic items (requiered for clippy analysis)
voodookiidoo Sep 10, 2026
fc4de33
Use new windows bindings
ChrisDenton Sep 4, 2026
d45c710
Remove unnecessary manual bindings
ChrisDenton Sep 4, 2026
98d3e1b
Update library/core/src/iter/sources/repeat_with.rs
voodookiidoo Sep 10, 2026
01fd255
regression test for async main diagnostic
malezjaa Sep 10, 2026
4e1c7f9
Rollup merge of #162270 - ChrisDenton:winagain, r=clarfonthey
jhpratt Sep 11, 2026
6036ee7
Rollup merge of #162492 - CAD97:rm-xdg, r=ChrisDenton
jhpratt Sep 11, 2026
8021397
Rollup merge of #162607 - joshlf:transmute-cleanup, r=jswrenn
jhpratt Sep 11, 2026
0180298
Rollup merge of #162619 - chenyukang:yukang-fix-141241-cow-clone-diag…
jhpratt Sep 11, 2026
8abb416
Rollup merge of #162172 - Albab-Hasan:opaque-hidden-type-inference-no…
jhpratt Sep 11, 2026
d971af8
Rollup merge of #162514 - nnethercote:simplify-diag-Levels, r=oli-obk
jhpratt Sep 11, 2026
b1baa4f
Rollup merge of #162546 - heiher:loong64-gnu-lld-nightly, r=chenyukang
jhpratt Sep 11, 2026
e8a9e14
Rollup merge of #162564 - mejrs:yeet, r=chenyukang
jhpratt Sep 11, 2026
ae7ebc8
Rollup merge of #162613 - voodookiidoo:add-iter-diagnostic-items, r=m…
jhpratt Sep 11, 2026
2eaa601
Rollup merge of #162616 - malezjaa:add-async-main-regression-test, r=…
jhpratt Sep 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6569,13 +6569,14 @@ dependencies = [

[[package]]
name = "windows-bindgen"
version = "0.66.0"
version = "0.100.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81b7ec123a4eadd44d1f44f76804316b477b2537abed9a2ab950b3c54afa1fcf"
checksum = "c6bb7c22ca81c6dc1554fd328c12697b4b0ad5c45081df2c3c9a3f89cc467da2"
dependencies = [
"serde",
"serde_json",
"windows-threading 0.2.1",
"proc-macro2",
"quote",
"windows-default",
"windows-metadata",
]

[[package]]
Expand Down Expand Up @@ -6622,6 +6623,12 @@ dependencies = [
"windows-strings 0.5.1",
]

[[package]]
name = "windows-default"
version = "0.100.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4882bb065b03115aa8891d44d076bbe843d286d8bfd0b55caaa4b049141a712"

[[package]]
name = "windows-future"
version = "0.2.1"
Expand Down Expand Up @@ -6678,6 +6685,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"

[[package]]
name = "windows-metadata"
version = "0.100.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d3a758dc1da4ae61aa7f93afbb505d564c72dd6431e513ed581377857896a72"

[[package]]
name = "windows-numerics"
version = "0.2.0"
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
use rustc_errors::emitter::Emitter;
use rustc_errors::{
Diag, DiagArgMap, DiagCtxt, DiagCtxtHandle, DiagMessage, ErrCode, FatalError, FatalErrorMarker,
Level, MultiSpan, Style, Suggestions, catch_fatal_errors,
Level, MultiSpan, Style, Sublevel, Suggestions, catch_fatal_errors,
};
use rustc_fs_util::link_or_copy;
use rustc_incremental::{copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir_sess};
Expand Down Expand Up @@ -1217,7 +1217,7 @@ struct Diagnostic {
// missing the following fields from `rustc_errors::Subdiag`.
// - `span`: it doesn't impl `Send`.
struct Subdiagnostic {
level: Level,
level: Sublevel,
messages: Vec<(DiagMessage, Style)>,
}

Expand Down
42 changes: 20 additions & 22 deletions compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//!
//! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/

use std::borrow::Cow;
use std::fmt::Debug;
use std::io;
use std::io::Write;
Expand All @@ -29,7 +28,7 @@ use crate::emitter::{
use crate::formatting::{format_diag_message, format_diag_messages};
use crate::{
CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, Level, MultiSpan, Style, Subdiag,
SuggestionStyle, TerminalUrl,
Sublevel, SuggestionStyle, TerminalUrl,
};

/// Generates diagnostics using annotate-snippet
Expand Down Expand Up @@ -126,14 +125,23 @@ fn annotation_level_for_level(level: Level) -> annotate_snippets::level::Level<'
}
Level::Fatal | Level::Error => annotate_snippets::level::ERROR,
Level::ForceWarning | Level::Warning => annotate_snippets::Level::WARNING,
Level::Note | Level::OnceNote => annotate_snippets::Level::NOTE,
Level::Help | Level::OnceHelp => annotate_snippets::Level::HELP,
Level::Note => annotate_snippets::Level::NOTE,
Level::Help => annotate_snippets::Level::HELP,
Level::FailureNote => annotate_snippets::Level::NOTE.no_name(),
Level::Allow => panic!("Should not call with Allow"),
Level::Expect => panic!("Should not call with Expect"),
}
}

fn annotation_level_for_sublevel(level: Sublevel) -> annotate_snippets::level::Level<'static> {
match level {
Sublevel::Error => annotate_snippets::Level::ERROR,
Sublevel::Warning => annotate_snippets::Level::WARNING,
Sublevel::Note | Sublevel::OnceNote => annotate_snippets::Level::NOTE,
Sublevel::Help | Sublevel::OnceHelp => annotate_snippets::Level::HELP,
}
}

impl AnnotateSnippetEmitter {
pub fn new(dst: Destination) -> Self {
Self {
Expand Down Expand Up @@ -166,9 +174,7 @@ impl AnnotateSnippetEmitter {
// If at least one portion of the message is styled, we need to
// "pre-style" the message
let mut title = if msgs.iter().any(|(_, style)| style != &crate::Style::NoStyle) {
annotation_level
.clone()
.secondary_title(Cow::Owned(self.pre_style_msgs(msgs, *level, args)))
annotation_level.clone().secondary_title(self.pre_style_msgs(msgs, args))
} else {
annotation_level.clone().primary_title(format_diag_messages(msgs, args))
};
Expand All @@ -186,8 +192,8 @@ impl AnnotateSnippetEmitter {
// If we don't have span information, emit and exit
let Some(sm) = self.sm.as_ref() else {
group = group.elements(children.iter().map(|c| {
let msg = format_diag_messages(&c.messages, args).to_string();
let level = annotation_level_for_level(c.level);
let msg = format_diag_messages(&c.messages, args);
let level = annotation_level_for_sublevel(c.level);
level.message(msg)
}));

Expand Down Expand Up @@ -250,12 +256,12 @@ impl AnnotateSnippetEmitter {
}

for c in children {
let level = annotation_level_for_level(c.level);
let level = annotation_level_for_sublevel(c.level);

// If at least one portion of the message is styled, we need to
// "pre-style" the message
let msg = if c.messages.iter().any(|(_, style)| style != &crate::Style::NoStyle) {
Cow::Owned(self.pre_style_msgs(&c.messages, c.level, args))
self.pre_style_msgs(&c.messages, args)
} else {
format_diag_messages(&c.messages, args)
};
Expand Down Expand Up @@ -309,10 +315,7 @@ impl AnnotateSnippetEmitter {
// do not display this suggestion, it is meant only for tools
}
SuggestionStyle::HideCodeAlways => {
let msg = format_diag_messages(
&[(suggestion.msg.to_owned(), Style::HeaderMsg)],
args,
);
let msg = format_diag_message(&suggestion.msg, args).into_owned();
group = group.element(annotate_snippets::Level::HELP.message(msg));
}
SuggestionStyle::HideCodeInline
Expand Down Expand Up @@ -544,16 +547,11 @@ impl AnnotateSnippetEmitter {
.short_message(self.short_message)
}

fn pre_style_msgs(
&self,
msgs: &[(DiagMessage, Style)],
level: Level,
args: &DiagArgMap,
) -> String {
fn pre_style_msgs(&self, msgs: &[(DiagMessage, Style)], args: &DiagArgMap) -> String {
msgs.iter()
.filter_map(|(m, style)| {
let text = format_diag_message(m, args);
let style = style.anstyle(level);
let style = style.anstyle();
if text.is_empty() { None } else { Some(format!("{style}{text}{style:#}")) }
})
.collect()
Expand Down
46 changes: 25 additions & 21 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use tracing::debug;

use crate::{
CodeSuggestion, DiagCtxtHandle, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level,
MultiSpan, StashKey, Style, Substitution, SubstitutionPart, SuggestionStyle, Suggestions,
MultiSpan, StashKey, Style, Sublevel, Substitution, SubstitutionPart, SuggestionStyle,
Suggestions,
};

/// Trait for types that `Diag::emit` can return as a "guarantee" (or "proof")
Expand Down Expand Up @@ -314,9 +315,7 @@ impl DiagInner {
Level::ForceWarning
| Level::Warning
| Level::Note
| Level::OnceNote
| Level::Help
| Level::OnceHelp
| Level::FailureNote
| Level::Allow
| Level::Expect => false,
Expand All @@ -343,7 +342,12 @@ impl DiagInner {
}
}

pub(crate) fn sub(&mut self, level: Level, message: impl Into<DiagMessage>, span: MultiSpan) {
pub(crate) fn sub(
&mut self,
level: Sublevel,
message: impl Into<DiagMessage>,
span: MultiSpan,
) {
let sub = Subdiag { level, messages: vec![(message.into(), Style::NoStyle)], span };
self.children.push(sub);
}
Expand All @@ -367,7 +371,7 @@ impl DiagInner {
pub fn emitted_at_sub_diag(&self) -> Subdiag {
let track = format!("-Ztrack-diagnostics: created at {}", self.emitted_at);
Subdiag {
level: crate::Level::Note,
level: crate::Sublevel::Note,
messages: vec![(DiagMessage::Str(Cow::Owned(track)), Style::NoStyle)],
span: MultiSpan::new(),
}
Expand Down Expand Up @@ -420,7 +424,7 @@ impl PartialEq for DiagInner {
/// For example, a note attached to an error.
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
pub struct Subdiag {
pub level: Level,
pub level: Sublevel,
pub messages: Vec<(DiagMessage, Style)>,
pub span: MultiSpan,
}
Expand Down Expand Up @@ -701,12 +705,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_note,
/// Add a note attached to this diagnostic.
pub fn note(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
self.sub(Level::Note, msg, MultiSpan::new());
self.sub(Sublevel::Note, msg, MultiSpan::new());
self
} }

pub fn highlighted_note(&mut self, msg: Vec<StringPart>) -> &mut Self {
self.sub_with_highlights(Level::Note, msg, MultiSpan::new());
self.sub_with_highlights(Sublevel::Note, msg, MultiSpan::new());
self
}

Expand All @@ -715,13 +719,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
span: impl Into<MultiSpan>,
msg: Vec<StringPart>,
) -> &mut Self {
self.sub_with_highlights(Level::Note, msg, span.into());
self.sub_with_highlights(Sublevel::Note, msg, span.into());
self
}

/// This is like [`Diag::note()`], but it's only printed once.
pub fn note_once(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
self.sub(Level::OnceNote, msg, MultiSpan::new());
self.sub(Sublevel::OnceNote, msg, MultiSpan::new());
self
}

Expand All @@ -733,7 +737,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
sp: impl Into<MultiSpan>,
msg: impl Into<DiagMessage>,
) -> &mut Self {
self.sub(Level::Note, msg, sp.into());
self.sub(Sublevel::Note, msg, sp.into());
self
} }

Expand All @@ -744,14 +748,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
sp: S,
msg: impl Into<DiagMessage>,
) -> &mut Self {
self.sub(Level::OnceNote, msg, sp.into());
self.sub(Sublevel::OnceNote, msg, sp.into());
self
}

with_fn! { with_warn,
/// Add a warning attached to this diagnostic.
pub fn warn(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
self.sub(Level::Warning, msg, MultiSpan::new());
self.sub(Sublevel::Warning, msg, MultiSpan::new());
self
} }

Expand All @@ -762,26 +766,26 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
sp: S,
msg: impl Into<DiagMessage>,
) -> &mut Self {
self.sub(Level::Warning, msg, sp.into());
self.sub(Sublevel::Warning, msg, sp.into());
self
}

with_fn! { with_help,
/// Add a help message attached to this diagnostic.
pub fn help(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
self.sub(Level::Help, msg, MultiSpan::new());
self.sub(Sublevel::Help, msg, MultiSpan::new());
self
} }

/// This is like [`Diag::help()`], but it's only printed once.
pub fn help_once(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
self.sub(Level::OnceHelp, msg, MultiSpan::new());
self.sub(Sublevel::OnceHelp, msg, MultiSpan::new());
self
}

/// Add a help message attached to this diagnostic with a customizable highlighted message.
pub fn highlighted_help(&mut self, msg: Vec<StringPart>) -> &mut Self {
self.sub_with_highlights(Level::Help, msg, MultiSpan::new());
self.sub_with_highlights(Sublevel::Help, msg, MultiSpan::new());
self
}

Expand All @@ -791,7 +795,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
span: impl Into<MultiSpan>,
msg: Vec<StringPart>,
) -> &mut Self {
self.sub_with_highlights(Level::Help, msg, span.into());
self.sub_with_highlights(Sublevel::Help, msg, span.into());
self
}

Expand All @@ -803,7 +807,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
sp: impl Into<MultiSpan>,
msg: impl Into<DiagMessage>,
) -> &mut Self {
self.sub(Level::Help, msg, sp.into());
self.sub(Sublevel::Help, msg, sp.into());
self
} }

Expand Down Expand Up @@ -1226,13 +1230,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// public methods above.
///
/// Used by `proc_macro_server` for implementing `server::Diagnostic`.
pub fn sub(&mut self, level: Level, message: impl Into<DiagMessage>, span: MultiSpan) {
pub fn sub(&mut self, level: Sublevel, message: impl Into<DiagMessage>, span: MultiSpan) {
self.deref_mut().sub(level, message, span);
}

/// Convenience function for internal use, clients should use one of the
/// public methods above.
fn sub_with_highlights(&mut self, level: Level, messages: Vec<StringPart>, span: MultiSpan) {
fn sub_with_highlights(&mut self, level: Sublevel, messages: Vec<StringPart>, span: MultiSpan) {
let messages = messages.into_iter().map(|m| (m.content.into(), m.style)).collect();
let sub = Subdiag { level, messages, span };
self.children.push(sub);
Expand Down
Loading
Loading