Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3e2c614
Fix invalid tag closing when leaving expansion "original code"
GuillaumeGomez Oct 28, 2025
8442380
Add regression test for #148184
GuillaumeGomez Oct 28, 2025
2fbb751
Un-shadow object bound candidate in `NormalizesTo` goal
adwinwhite Oct 30, 2025
e2ac9d9
Apply suggestions
adwinwhite Oct 31, 2025
e23c155
implement VecDeque extend_front and prepend, add tests
antonilol Sep 30, 2025
5b96677
add specialization for extend_front and prepend with copied slice ite…
antonilol Nov 3, 2025
d2cfc47
add test for alias self_ty
adwinwhite Nov 5, 2025
fd6466a
run-make tests: use edition 2024
hkBst Nov 5, 2025
457cbb0
chore: Update annotate-snippets to 0.12.8
Muscraft Oct 28, 2025
37bb0c2
chore: Make AnnotateSnippetEmitter match revert of "all spans must be…
Muscraft Oct 28, 2025
a75bd03
fix: Respect HumanReadableErrorType::AnnotateSnippet
Muscraft Oct 15, 2025
4748d92
feat: Always use annotate-snippets for Unicode output
Muscraft Oct 14, 2025
9cb7deb
refactor: Make short a field on HumanReadableErrorType varinants
Muscraft Oct 27, 2025
9243928
feat: Use annotate-snippets by default on nightly
Muscraft Oct 15, 2025
55b0125
Add regression test for ice
chenyukang Nov 6, 2025
a9795db
Fix ICE from async closure variance
chenyukang Nov 6, 2025
c8b2a9a
rustdoc-search: remove broken index special case
notriddle Nov 6, 2025
f7f128f
Rollup merge of #146861 - antonilol:vec_deque_extend_front, r=joboet
matthiaskrgr Nov 6, 2025
7b766e0
Rollup merge of #148213 - GuillaumeGomez:fix-exit-of-expansion, r=yot…
matthiaskrgr Nov 6, 2025
fc31898
Rollup merge of #148292 - adwinwhite:assemble_object_candidate, r=lcnr
matthiaskrgr Nov 6, 2025
320af6b
Rollup merge of #148528 - hkBst:run-make-tests-1, r=jieyouxu
matthiaskrgr Nov 6, 2025
a3409fd
Rollup merge of #148554 - chenyukang:test-issue-148542, r=jieyouxu
matthiaskrgr Nov 6, 2025
76dae76
Rollup merge of #148561 - chenyukang:yukang-fix-148488, r=lqd
matthiaskrgr Nov 6, 2025
1a6770c
Rollup merge of #148563 - notriddle:index-typedata-bug, r=GuillaumeGomez
matthiaskrgr Nov 6, 2025
c5e283b
Auto merge of #148188 - Muscraft:annotate-snippets-default-on-nightly…
bors Nov 6, 2025
c90bcb9
Auto merge of #148573 - matthiaskrgr:rollup-cn5viia, r=matthiaskrgr
bors Nov 6, 2025
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
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ dependencies = [

[[package]]
name = "annotate-snippets"
version = "0.12.7"
version = "0.12.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47224528f74de27d1d06aad6a5dda4f865b6ebe2e56c538943d746a7270cb67e"
checksum = "025c7edcdffa4ccc5c0905f472a0ae3759378cfbef88ef518a3575e19ae3aebd"
dependencies = [
"anstyle",
"unicode-width 0.2.2",
Expand Down Expand Up @@ -3766,7 +3766,7 @@ dependencies = [
name = "rustc_errors"
version = "0.0.0"
dependencies = [
"annotate-snippets 0.12.7",
"annotate-snippets 0.12.8",
"anstream",
"anstyle",
"derive_setters",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2024"

[dependencies]
# tidy-alphabetical-start
annotate-snippets = "0.12.7"
annotate-snippets = "0.12.8"
anstream = "0.6.20"
anstyle = "1.0.13"
derive_setters = "0.1.6"
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,22 @@ impl AnnotateSnippetEmitter {
let substitutions = suggestion
.substitutions
.into_iter()
.filter_map(|mut subst| {
.filter(|subst| {
// Suggestions coming from macros can have malformed spans. This is a heavy
// handed approach to avoid ICEs by ignoring the suggestion outright.
let invalid =
subst.parts.iter().any(|item| sm.is_valid_span(item.span).is_err());
if invalid {
debug!("suggestion contains an invalid span: {:?}", subst);
}

!invalid
})
.filter_map(|mut subst| {
// Assumption: all spans are in the same file, and all spans
// are disjoint. Sort in ascending order.
subst.parts.sort_by_key(|part| part.span.lo());
// Verify the assumption that all spans are disjoint
assert_eq!(
debug_assert_eq!(
subst.parts.array_windows().find(|[a, b]| a.span.overlaps(b.span)),
None,
"all spans must be disjoint",
Expand All @@ -355,13 +357,11 @@ impl AnnotateSnippetEmitter {

let item_span = subst.parts.first()?;
let file = sm.lookup_source_file(item_span.span.lo());
if !invalid
&& should_show_source_code(
&self.ignored_directories_in_source_blocks,
sm,
&file,
)
{
if should_show_source_code(
&self.ignored_directories_in_source_blocks,
sm,
&file,
) {
Some(subst)
} else {
None
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ const DEFAULT_COLUMN_WIDTH: usize = 140;
/// Describes the way the content of the `rendered` field of the json output is generated
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HumanReadableErrorType {
Default,
Unicode,
AnnotateSnippet,
Short,
Default { short: bool },
AnnotateSnippet { short: bool, unicode: bool },
}

impl HumanReadableErrorType {
pub fn short(&self) -> bool {
*self == HumanReadableErrorType::Short
match self {
HumanReadableErrorType::Default { short }
| HumanReadableErrorType::AnnotateSnippet { short, .. } => *short,
}
}
}

Expand Down
50 changes: 34 additions & 16 deletions compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use rustc_span::hygiene::ExpnData;
use rustc_span::source_map::{FilePathMapping, SourceMap};
use serde::Serialize;

use crate::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
use crate::diagnostic::IsLint;
use crate::emitter::{
ColorConfig, Destination, Emitter, HumanEmitter, HumanReadableErrorType, OutputTheme,
Expand Down Expand Up @@ -370,29 +371,46 @@ impl Diagnostic {
.insert(0, Diagnostic::from_sub_diagnostic(&diag.emitted_at_sub_diag(), &args, je));
}
let buf = BufWriter(Arc::new(Mutex::new(Vec::new())));
let short = je.json_rendered.short();
let dst: Destination = AutoStream::new(
Box::new(buf.clone()),
match je.color_config.to_color_choice() {
ColorChoice::Auto => ColorChoice::Always,
choice => choice,
},
);
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 let HumanReadableErrorType::Unicode = je.json_rendered {
OutputTheme::Unicode
} else {
OutputTheme::Ascii
})
.emit_diagnostic(diag, registry);
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 buf = Arc::try_unwrap(buf.0).unwrap().into_inner().unwrap();
let buf = String::from_utf8(buf).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/json/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
Some(sm),
translator,
true, // pretty
HumanReadableErrorType::Short,
HumanReadableErrorType::Default { short: true },
ColorConfig::Never,
);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ fn test_search_paths_tracking_hash_different_order() {
let early_dcx = EarlyDiagCtxt::new(JSON);
const JSON: ErrorOutputType = ErrorOutputType::Json {
pretty: false,
json_rendered: HumanReadableErrorType::Default,
json_rendered: HumanReadableErrorType::Default { short: false },
color_config: ColorConfig::Never,
};

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
}

Closure(..)
| CoroutineClosure(..)
| FnDef(..)
| Infer(..)
| Coroutine(..)
Expand Down
11 changes: 10 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,16 @@ where
self.assemble_object_bound_candidates(goal, &mut candidates);
}
}
AssembleCandidatesFrom::EnvAndBounds => {}
AssembleCandidatesFrom::EnvAndBounds => {
// This is somewhat inconsistent and may make #57893 slightly easier to exploit.
// However, it matches the behavior of the old solver. See
// `tests/ui/traits/next-solver/normalization-shadowing/use_object_if_empty_env.rs`.
if matches!(normalized_self_ty.kind(), ty::Dynamic(..))
&& !candidates.iter().any(|c| matches!(c.source, CandidateSource::ParamEnv(_)))
{
self.assemble_object_bound_candidates(goal, &mut candidates);
}
}
}

(candidates, failed_candidate_info)
Expand Down
24 changes: 17 additions & 7 deletions compiler/rustc_parse/src/parser/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(rustc::symbol_intern_string_literal)]

use std::assert_matches::assert_matches;
use std::io::prelude::*;
use std::iter::Peekable;
Expand All @@ -12,6 +11,7 @@ use rustc_ast::token::{self, Delimiter, Token};
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
use rustc_ast::{self as ast, PatKind, visit};
use rustc_ast_pretty::pprust::item_to_string;
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
use rustc_errors::emitter::{HumanEmitter, OutputTheme};
use rustc_errors::translation::Translator;
use rustc_errors::{AutoStream, DiagCtxt, MultiSpan, PResult};
Expand Down Expand Up @@ -43,12 +43,22 @@ fn create_test_handler(theme: OutputTheme) -> (DiagCtxt, Arc<SourceMap>, Arc<Mut
let output = Arc::new(Mutex::new(Vec::new()));
let source_map = Arc::new(SourceMap::new(FilePathMapping::empty()));
let translator = Translator::with_fallback_bundle(vec![crate::DEFAULT_LOCALE_RESOURCE], false);
let mut emitter =
HumanEmitter::new(AutoStream::never(Box::new(Shared { data: output.clone() })), translator)
.sm(Some(source_map.clone()))
.diagnostic_width(Some(140));
emitter = emitter.theme(theme);
let dcx = DiagCtxt::new(Box::new(emitter));
let shared: Box<dyn Write + Send> = Box::new(Shared { data: output.clone() });
let auto_stream = AutoStream::never(shared);
let dcx = DiagCtxt::new(match theme {
OutputTheme::Ascii => Box::new(
HumanEmitter::new(auto_stream, translator)
.sm(Some(source_map.clone()))
.diagnostic_width(Some(140))
.theme(theme),
),
OutputTheme::Unicode => Box::new(
AnnotateSnippetEmitter::new(auto_stream, translator)
.sm(Some(source_map.clone()))
.diagnostic_width(Some(140))
.theme(theme),
),
});
(dcx, source_map, output)
}

Expand Down
Loading
Loading