Skip to content

Commit 854b316

Browse files
author
mejrs
committed
Address some comments
1 parent 406e1dc commit 854b316

File tree

9 files changed

+42
-6
lines changed

9 files changed

+42
-6
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ impl Emitter for EmitterWriter {
559559
&primary_span,
560560
&children,
561561
&suggestions,
562-
Some(&diag.emitted_at),
562+
self.track_diagnostics.then_some(&diag.emitted_at),
563563
);
564564
}
565565

@@ -1661,7 +1661,7 @@ impl EmitterWriter {
16611661
}
16621662
}
16631663

1664-
if self.track_diagnostics && let Some(tracked) = emitted_at {
1664+
if let Some(tracked) = emitted_at {
16651665
let track = format!("-Ztrack-diagnostics: created at {tracked}");
16661666
let len = buffer.num_lines();
16671667
buffer.append(len, &track, Style::NoStyle);

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ fn test_unstable_options_tracking_hash() {
689689
untracked!(time_llvm_passes, true);
690690
untracked!(time_passes, true);
691691
untracked!(trace_macros, true);
692+
untracked!(track_diagnostics, false);
692693
untracked!(trim_diagnostic_paths, false);
693694
untracked!(ui_testing, true);
694695
untracked!(unpretty, Some("expanded".to_string()));

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,8 +1585,8 @@ options! {
15851585
"choose the TLS model to use (`rustc --print tls-models` for details)"),
15861586
trace_macros: bool = (false, parse_bool, [UNTRACKED],
15871587
"for every macro invocation, print its name and arguments (default: no)"),
1588-
track_diagnostics: bool = (false, parse_bool, [TRACKED],
1589-
"Tracks where in rustc a diagnostic was emitted"),
1588+
track_diagnostics: bool = (false, parse_bool, [UNTRACKED],
1589+
"tracks where in rustc a diagnostic was emitted"),
15901590
// Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved
15911591
// alongside query results and changes to translation options can affect diagnostics - so
15921592
// translation options should be tracked.

src/librustdoc/core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub(crate) fn new_handler(
172172
unstable_opts.teach,
173173
diagnostic_width,
174174
false,
175-
false,
175+
unstable_opts.track_diagnostics,
176176
)
177177
.ui_testing(unstable_opts.ui_testing),
178178
)
@@ -191,7 +191,7 @@ pub(crate) fn new_handler(
191191
json_rendered,
192192
diagnostic_width,
193193
false,
194-
false,
194+
unstable_opts.track_diagnostics,
195195
)
196196
.ui_testing(unstable_opts.ui_testing),
197197
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// compile-flags: -Z track-diagnostics
2+
// error-pattern: created at
3+
4+
struct A;
5+
struct B;
6+
const S: A = B;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/track-diagnostics.rs:6:14
3+
|
4+
LL | const S: A = B;
5+
| ^ expected struct `A`, found struct `B`
6+
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31
7+
8+
error: aborting due to previous error
9+
10+
For more information about this error, try `rustc --explain E0308`.

src/test/rustdoc-ui/z-help.stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
-Z time-passes=val -- measure time of each rustc pass (default: no)
171171
-Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details)
172172
-Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no)
173+
-Z track-diagnostics=val -- Tracks where in rustc a diagnostic was emitted
173174
-Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation)
174175
-Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics
175176
-Z translate-lang=val -- language identifier for diagnostic output
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// compile-flags: -Z track-diagnostics
2+
// error-pattern: created at
3+
4+
struct A;
5+
struct B;
6+
const S: A = B;
7+
8+
fn main() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/track-diagnostics.rs:6:14
3+
|
4+
LL | const S: A = B;
5+
| ^ expected struct `A`, found struct `B`
6+
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31
7+
8+
error: aborting due to previous error
9+
10+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)