Skip to content
Closed
Changes from 2 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
fdefffe
compiler: report error when trait object type param reference self
xtexx Mar 30, 2025
6966416
Update to new rinja version (askama)
GuillaumeGomez Apr 3, 2025
f343b9d
Don't construct preds w escaping bound vars in diagnostic_hir_wf_check
compiler-errors Apr 4, 2025
86a7ee6
create new option `build.compiletest-use-stage0-libtest`
onur-ozkan Apr 4, 2025
17fad21
utilize `compiletest_use_stage0_libtest` option
onur-ozkan Apr 4, 2025
afe3834
add change-entry
onur-ozkan Apr 4, 2025
45afefa
Fix trait upcasting to dyn type with no principal when there are proj…
compiler-errors Apr 5, 2025
a6b7a26
Update rinja version in `generate-copyright`
GuillaumeGomez Apr 4, 2025
d37bd4d
Update proc-macro deps list
GuillaumeGomez Apr 3, 2025
1f06a6a
Tell LLVM about impossible niche tags
scottmcm Mar 29, 2025
51e67e2
LLVM18 compatibility fixes in the tests
scottmcm Mar 29, 2025
253da2f
Don't call Span.with_parent on the good path in has_stashed_diagnostic
compiler-errors Apr 7, 2025
c830665
enable in-tree std on some runners
onur-ozkan Apr 5, 2025
1862b31
rm `RegionInferenceContext::var_infos`
lcnr Apr 7, 2025
1a48634
Sort job duration changes by absolute duration
Kobzol Apr 7, 2025
cae28b5
implement `check` step for `compiletest` separately
onur-ozkan Apr 7, 2025
6ece1de
Add job summary links to post-merge report
Kobzol Apr 7, 2025
42048ea
compiletest: Cleanup collection of actual errors
petrochenkov Apr 7, 2025
b86b3fb
compiletest: Always preserve kind for compiler diagnostics
petrochenkov Apr 7, 2025
5c160f5
compiletest: Stricter parsing for diagnostic kinds
petrochenkov Apr 7, 2025
e1a69da
unstable-book/intrinsics: wordsmith MIR-lowering intrinsic docs
RalfJung Apr 7, 2025
fd854a7
compiletest: Avoid ignoring empty diagnostics in one more place
petrochenkov Apr 7, 2025
2fb550b
Update books
rustbot Apr 7, 2025
a7400a8
update intrinsics/mod.rs comment about const intrinsics
RalfJung Apr 7, 2025
bc29123
Revert "remove rust-analyser support for `extern "rust-intrinsic"` b…
Skgland Apr 7, 2025
250b848
Make error message for missing fields with .. and without .. more con…
compiler-errors Mar 27, 2025
268c56e
Implement overflow for infinite implied lifetime bounds
compiler-errors Apr 7, 2025
4aab8e8
document panic behavior of Vec::resize and Vec::resize_with
jogru0 Apr 7, 2025
b08e9c2
Fix stack overflow in exhaustiveness due to recursive HIR opaque type…
compiler-errors Apr 7, 2025
01e44b1
add missing word in doc comment
tshepang Apr 8, 2025
8501dcb
remove unusual indentation
tshepang Apr 8, 2025
502f7f9
Address PR feedback
scottmcm Apr 8, 2025
9bfb203
compiletest: Trim whitespace from environment variable names
Zalathar Apr 8, 2025
2b80521
Rollup merge of #138676 - compiler-errors:overflow-implied-bounds, r=…
Zalathar Apr 8, 2025
8a31cc2
Rollup merge of #139024 - compiler-errors:tweak-default-value-err, r=…
Zalathar Apr 8, 2025
3701847
Rollup merge of #139098 - scottmcm:assert-impossible-tags, r=WaffleLa…
Zalathar Apr 8, 2025
39eecc7
Rollup merge of #139124 - xtexx:gh-139082, r=compiler-errors
Zalathar Apr 8, 2025
a5e7f0e
Rollup merge of #139321 - GuillaumeGomez:update-rinja, r=notriddle,lo…
Zalathar Apr 8, 2025
c8f0356
Rollup merge of #139346 - compiler-errors:non-lifetime-binder-diag-hi…
Zalathar Apr 8, 2025
a1ab3d9
Rollup merge of #139386 - onur-ozkan:configurable-compiletest-libtest…
Zalathar Apr 8, 2025
73bed4f
Rollup merge of #139421 - compiler-errors:upcast-no-principal-with-pr…
Zalathar Apr 8, 2025
4f2734d
Rollup merge of #139468 - compiler-errors:has_stashed_diagnostic, r=o…
Zalathar Apr 8, 2025
8e50682
Rollup merge of #139476 - lcnr:rm-var_infos, r=compiler-errors
Zalathar Apr 8, 2025
e179592
Rollup merge of #139481 - Kobzol:post-merge-links, r=marcoieni
Zalathar Apr 8, 2025
fdb7828
Rollup merge of #139485 - petrochenkov:errkind-light, r=oli-obk,jieyouxu
Zalathar Apr 8, 2025
7ad48aa
Rollup merge of #139490 - RalfJung:unstable-intrinsics-docs, r=oli-obk
Zalathar Apr 8, 2025
1748007
Rollup merge of #139491 - rustbot:docs-update, r=ehuss
Zalathar Apr 8, 2025
d1b8f8e
Rollup merge of #139496 - Skgland:139455-went-too-far, r=Veykril
Zalathar Apr 8, 2025
77666b8
Rollup merge of #139500 - jogru0:117437, r=tgross35
Zalathar Apr 8, 2025
58af9cd
Rollup merge of #139501 - compiler-errors:suppress-stack-overflow, r=…
Zalathar Apr 8, 2025
62721da
Rollup merge of #139504 - tshepang:patch-5, r=jieyouxu
Zalathar Apr 8, 2025
7d32832
Rollup merge of #139507 - Zalathar:trim-env-name, r=jieyouxu
Zalathar Apr 8, 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
70 changes: 44 additions & 26 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ struct DiagCtxtInner {
/// add more information). All stashed diagnostics must be emitted with
/// `emit_stashed_diagnostics` by the time the `DiagCtxtInner` is dropped,
/// otherwise an assertion failure will occur.
stashed_diagnostics: FxIndexMap<(Span, StashKey), (DiagInner, Option<ErrorGuaranteed>)>,
stashed_diagnostics:
FxIndexMap<StashKey, FxIndexMap<Span, (DiagInner, Option<ErrorGuaranteed>)>>,

future_breakage_diagnostics: Vec<DiagInner>,

Expand Down Expand Up @@ -912,8 +913,12 @@ impl<'a> DiagCtxtHandle<'a> {
// FIXME(Centril, #69537): Consider reintroducing panic on overwriting a stashed diagnostic
// if/when we have a more robust macro-friendly replacement for `(span, key)` as a key.
// See the PR for a discussion.
let key = (span.with_parent(None), key);
self.inner.borrow_mut().stashed_diagnostics.insert(key, (diag, guar));
self.inner
.borrow_mut()
.stashed_diagnostics
.entry(key)
.or_default()
.insert(span.with_parent(None), (diag, guar));

guar
}
Expand All @@ -922,9 +927,10 @@ impl<'a> DiagCtxtHandle<'a> {
/// and [`StashKey`] as the key. Panics if the found diagnostic is an
/// error.
pub fn steal_non_err(self, span: Span, key: StashKey) -> Option<Diag<'a, ()>> {
let key = (span.with_parent(None), key);
// FIXME(#120456) - is `swap_remove` correct?
let (diag, guar) = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key)?;
let (diag, guar) = self.inner.borrow_mut().stashed_diagnostics.get_mut(&key).and_then(
|stashed_diagnostics| stashed_diagnostics.swap_remove(&span.with_parent(None)),
)?;
assert!(!diag.is_error());
assert!(guar.is_none());
Some(Diag::new_diagnostic(self, diag))
Expand All @@ -943,9 +949,10 @@ impl<'a> DiagCtxtHandle<'a> {
where
F: FnMut(&mut Diag<'_>),
{
let key = (span.with_parent(None), key);
// FIXME(#120456) - is `swap_remove` correct?
let err = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key);
let err = self.inner.borrow_mut().stashed_diagnostics.get_mut(&key).and_then(
|stashed_diagnostics| stashed_diagnostics.swap_remove(&span.with_parent(None)),
);
err.map(|(err, guar)| {
// The use of `::<ErrorGuaranteed>` is safe because level is `Level::Error`.
assert_eq!(err.level, Error);
Expand All @@ -966,9 +973,10 @@ impl<'a> DiagCtxtHandle<'a> {
key: StashKey,
new_err: Diag<'_>,
) -> ErrorGuaranteed {
let key = (span.with_parent(None), key);
// FIXME(#120456) - is `swap_remove` correct?
let old_err = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key);
let old_err = self.inner.borrow_mut().stashed_diagnostics.get_mut(&key).and_then(
|stashed_diagnostics| stashed_diagnostics.swap_remove(&span.with_parent(None)),
);
match old_err {
Some((old_err, guar)) => {
assert_eq!(old_err.level, Error);
Expand All @@ -983,7 +991,14 @@ impl<'a> DiagCtxtHandle<'a> {
}

pub fn has_stashed_diagnostic(&self, span: Span, key: StashKey) -> bool {
self.inner.borrow().stashed_diagnostics.get(&(span.with_parent(None), key)).is_some()
let inner = self.inner.borrow();
if let Some(stashed_diagnostics) = inner.stashed_diagnostics.get(&key)
&& !stashed_diagnostics.is_empty()
{
stashed_diagnostics.contains_key(&span.with_parent(None))
} else {
false
}
}

/// Emit all stashed diagnostics.
Expand All @@ -997,7 +1012,11 @@ impl<'a> DiagCtxtHandle<'a> {
let inner = self.inner.borrow();
inner.err_guars.len()
+ inner.lint_err_guars.len()
+ inner.stashed_diagnostics.values().filter(|(_diag, guar)| guar.is_some()).count()
+ inner
.stashed_diagnostics
.values()
.map(|a| a.values().filter(|(_, guar)| guar.is_some()).count())
.sum::<usize>()
}

/// This excludes lint errors and delayed bugs. Unless absolutely
Expand Down Expand Up @@ -1486,16 +1505,18 @@ impl DiagCtxtInner {
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
let mut guar = None;
let has_errors = !self.err_guars.is_empty();
for (_, (diag, _guar)) in std::mem::take(&mut self.stashed_diagnostics).into_iter() {
if !diag.is_error() {
// Unless they're forced, don't flush stashed warnings when
// there are errors, to avoid causing warning overload. The
// stash would've been stolen already if it were important.
if !diag.is_force_warn() && has_errors {
continue;
for (_, stashed_diagnostics) in std::mem::take(&mut self.stashed_diagnostics).into_iter() {
for (_, (diag, _guar)) in stashed_diagnostics {
if !diag.is_error() {
// Unless they're forced, don't flush stashed warnings when
// there are errors, to avoid causing warning overload. The
// stash would've been stolen already if it were important.
if !diag.is_force_warn() && has_errors {
continue;
}
}
guar = guar.or(self.emit_diagnostic(diag, None));
}
guar = guar.or(self.emit_diagnostic(diag, None));
}
guar
}
Expand Down Expand Up @@ -1688,6 +1709,7 @@ impl DiagCtxtInner {
if let Some((_diag, guar)) = self
.stashed_diagnostics
.values()
.flat_map(|stashed_diagnostics| stashed_diagnostics.values())
.find(|(diag, guar)| guar.is_some() && diag.is_lint.is_none())
{
*guar
Expand All @@ -1700,13 +1722,9 @@ impl DiagCtxtInner {
fn has_errors(&self) -> Option<ErrorGuaranteed> {
self.err_guars.get(0).copied().or_else(|| self.lint_err_guars.get(0).copied()).or_else(
|| {
if let Some((_diag, guar)) =
self.stashed_diagnostics.values().find(|(_diag, guar)| guar.is_some())
{
*guar
} else {
None
}
self.stashed_diagnostics.values().find_map(|stashed_diagnostics| {
stashed_diagnostics.values().find_map(|(_, guar)| *guar)
})
},
)
}
Expand Down