Skip to content

Commit 1a3fad5

Browse files
Tweak name of good-path bugs
1 parent 07c993e commit 1a3fad5

File tree

5 files changed

+26
-27
lines changed

5 files changed

+26
-27
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
267267
{
268268
write!(f, "inside closure")
269269
} else {
270-
// Note: this triggers a `good_path_bug` state, which means that if we ever get here
271-
// we must emit a diagnostic. We should never display a `FrameInfo` unless we
272-
// actually want to emit a warning or error to the user.
270+
// Note: this triggers a `bug_unless_diagnostic_emitted` state, which means
271+
// that if we ever get here we must emit a diagnostic. We should never display
272+
// a `FrameInfo` unless we actually want to emit a warning or error to the user.
273273
write!(f, "inside `{}`", self.instance)
274274
}
275275
})

compiler/rustc_errors/src/lib.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,10 @@ struct HandlerInner {
410410
deduplicated_err_count: usize,
411411
emitter: Box<dyn Emitter + sync::Send>,
412412
delayed_span_bugs: Vec<DelayedDiagnostic>,
413-
delayed_good_path_bugs: Vec<DelayedDiagnostic>,
413+
/// Bugs that are delayed unless a diagnostic (warn/lint/error) is emitted.
414+
delayed_expect_diagnostic_bugs: Vec<DelayedDiagnostic>,
414415
/// This flag indicates that an expected diagnostic was emitted and suppressed.
415-
/// This is used for the `delayed_good_path_bugs` check.
416+
/// This is used for the `delayed_bugs_unless_diagnostic_emitted` check.
416417
suppressed_expected_diag: bool,
417418

418419
/// This set contains the `DiagnosticId` of all emitted diagnostics to avoid
@@ -520,16 +521,14 @@ impl Drop for HandlerInner {
520521
self.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued");
521522
}
522523

523-
// FIXME(eddyb) this explains what `delayed_good_path_bugs` are!
524524
// They're `delayed_span_bugs` but for "require some diagnostic happened"
525525
// instead of "require some error happened". Sadly that isn't ideal, as
526526
// lints can be `#[allow]`'d, potentially leading to this triggering.
527-
// Also, "good path" should be replaced with a better naming.
528527
if !self.has_any_message() && !self.suppressed_expected_diag {
529-
let bugs = std::mem::replace(&mut self.delayed_good_path_bugs, Vec::new());
528+
let bugs = std::mem::replace(&mut self.delayed_expect_diagnostic_bugs, Vec::new());
530529
self.flush_delayed(
531530
bugs,
532-
"no warnings or errors encountered even though `delayed_good_path_bugs` issued",
531+
"no warnings or errors encountered even though `delayed_bugs_unless_diagnostic_emitted` issued",
533532
);
534533
}
535534

@@ -608,7 +607,7 @@ impl Handler {
608607
deduplicated_warn_count: 0,
609608
emitter,
610609
delayed_span_bugs: Vec::new(),
611-
delayed_good_path_bugs: Vec::new(),
610+
delayed_expect_diagnostic_bugs: Vec::new(),
612611
suppressed_expected_diag: false,
613612
taught_diagnostics: Default::default(),
614613
emitted_diagnostic_codes: Default::default(),
@@ -662,7 +661,7 @@ impl Handler {
662661

663662
// actually free the underlying memory (which `clear` would not do)
664663
inner.delayed_span_bugs = Default::default();
665-
inner.delayed_good_path_bugs = Default::default();
664+
inner.delayed_expect_diagnostic_bugs = Default::default();
666665
inner.taught_diagnostics = Default::default();
667666
inner.emitted_diagnostic_codes = Default::default();
668667
inner.emitted_diagnostics = Default::default();
@@ -1005,10 +1004,9 @@ impl Handler {
10051004
self.inner.borrow_mut().delay_span_bug(span, msg)
10061005
}
10071006

1008-
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
1009-
// where the explanation of what "good path" is (also, it should be renamed).
1010-
pub fn delay_good_path_bug(&self, msg: impl Into<DiagnosticMessage>) {
1011-
self.inner.borrow_mut().delay_good_path_bug(msg)
1007+
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`.
1008+
pub fn delay_bug_unless_diagnostic_emitted(&self, msg: impl Into<DiagnosticMessage>) {
1009+
self.inner.borrow_mut().delay_bug_unless_diagnostic_emitted(msg)
10121010
}
10131011

10141012
#[track_caller]
@@ -1436,7 +1434,7 @@ impl HandlerInner {
14361434
}
14371435

14381436
fn delayed_bug_count(&self) -> usize {
1439-
self.delayed_span_bugs.len() + self.delayed_good_path_bugs.len()
1437+
self.delayed_span_bugs.len() + self.delayed_expect_diagnostic_bugs.len()
14401438
}
14411439

14421440
fn print_error_count(&mut self, registry: &Registry) {
@@ -1609,15 +1607,15 @@ impl HandlerInner {
16091607
self.emit_diagnostic(&mut diagnostic).unwrap()
16101608
}
16111609

1612-
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
1613-
// where the explanation of what "good path" is (also, it should be renamed).
1614-
fn delay_good_path_bug(&mut self, msg: impl Into<DiagnosticMessage>) {
1610+
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`.
1611+
fn delay_bug_unless_diagnostic_emitted(&mut self, msg: impl Into<DiagnosticMessage>) {
16151612
let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg);
16161613
if self.flags.report_delayed_bugs {
16171614
self.emit_diagnostic(&mut diagnostic);
16181615
}
16191616
let backtrace = std::backtrace::Backtrace::force_capture();
1620-
self.delayed_good_path_bugs.push(DelayedDiagnostic::with_backtrace(diagnostic, backtrace));
1617+
self.delayed_expect_diagnostic_bugs
1618+
.push(DelayedDiagnostic::with_backtrace(diagnostic, backtrace));
16211619
}
16221620

16231621
fn failure(&mut self, msg: impl Into<DiagnosticMessage>) {

compiler/rustc_middle/src/ty/print/pretty.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2947,8 +2947,9 @@ fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
29472947
//
29482948
// For good paths causing this bug, the `rustc_middle::ty::print::with_no_trimmed_paths`
29492949
// wrapper can be used to suppress this query, in exchange for full paths being formatted.
2950-
tcx.sess.delay_good_path_bug(
2951-
"trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging",
2950+
tcx.sess.delay_bug_unless_diagnostic_emitted(
2951+
"trimmed_def_paths constructed but no diagnostic emitted; \
2952+
use `DelayDm` for lints or `with_no_trimmed_paths` for debugging",
29522953
);
29532954
}
29542955

compiler/rustc_session/src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ pub enum TrimmedDefPaths {
413413
/// `try_print_trimmed_def_path` never prints a trimmed path and never calls the expensive query
414414
#[default]
415415
Never,
416-
/// `try_print_trimmed_def_path` calls the expensive query, the query doesn't call `delay_good_path_bug`
416+
/// `try_print_trimmed_def_path` calls the expensive query, the query doesn't call `delay_bug_unless_diagnostic_emitted`
417417
Always,
418-
/// `try_print_trimmed_def_path` calls the expensive query, the query calls `delay_good_path_bug`
418+
/// `try_print_trimmed_def_path` calls the expensive query, the query calls `delay_bug_unless_diagnostic_emitted`
419419
GoodPath,
420420
}
421421

compiler/rustc_session/src/session.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ impl Session {
631631
/// Used for code paths of expensive computations that should only take place when
632632
/// warnings or errors are emitted. If no messages are emitted ("good path"), then
633633
/// it's likely a bug.
634-
pub fn delay_good_path_bug(&self, msg: impl Into<DiagnosticMessage>) {
634+
pub fn delay_bug_unless_diagnostic_emitted(&self, msg: impl Into<DiagnosticMessage>) {
635635
if self.opts.unstable_opts.print_type_sizes
636636
|| self.opts.unstable_opts.query_dep_graph
637637
|| self.opts.unstable_opts.dump_mir.is_some()
@@ -642,7 +642,7 @@ impl Session {
642642
return;
643643
}
644644

645-
self.diagnostic().delay_good_path_bug(msg)
645+
self.diagnostic().delay_bug_unless_diagnostic_emitted(msg)
646646
}
647647

648648
#[rustc_lint_diagnostics]
@@ -892,7 +892,7 @@ impl Session {
892892
if fuel.remaining == 0 && !fuel.out_of_fuel {
893893
if self.diagnostic().can_emit_warnings() {
894894
// We only call `msg` in case we can actually emit warnings.
895-
// Otherwise, this could cause a `delay_good_path_bug` to
895+
// Otherwise, this could cause a `delay_bug_unless_diagnostic_emitted` to
896896
// trigger (issue #79546).
897897
self.emit_warning(errors::OptimisationFuelExhausted { msg: msg() });
898898
}

0 commit comments

Comments
 (0)