1
Fork 0

Address some comments

This commit is contained in:
mejrs 2022-10-24 20:52:51 +02:00
parent 406e1dc8eb
commit 854b3166a0
9 changed files with 42 additions and 6 deletions

View file

@ -559,7 +559,7 @@ impl Emitter for EmitterWriter {
&primary_span, &primary_span,
&children, &children,
&suggestions, &suggestions,
Some(&diag.emitted_at), self.track_diagnostics.then_some(&diag.emitted_at),
); );
} }
@ -1661,7 +1661,7 @@ impl EmitterWriter {
} }
} }
if self.track_diagnostics && let Some(tracked) = emitted_at { if let Some(tracked) = emitted_at {
let track = format!("-Ztrack-diagnostics: created at {tracked}"); let track = format!("-Ztrack-diagnostics: created at {tracked}");
let len = buffer.num_lines(); let len = buffer.num_lines();
buffer.append(len, &track, Style::NoStyle); buffer.append(len, &track, Style::NoStyle);

View file

@ -689,6 +689,7 @@ fn test_unstable_options_tracking_hash() {
untracked!(time_llvm_passes, true); untracked!(time_llvm_passes, true);
untracked!(time_passes, true); untracked!(time_passes, true);
untracked!(trace_macros, true); untracked!(trace_macros, true);
untracked!(track_diagnostics, false);
untracked!(trim_diagnostic_paths, false); untracked!(trim_diagnostic_paths, false);
untracked!(ui_testing, true); untracked!(ui_testing, true);
untracked!(unpretty, Some("expanded".to_string())); untracked!(unpretty, Some("expanded".to_string()));

View file

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

View file

@ -172,7 +172,7 @@ pub(crate) fn new_handler(
unstable_opts.teach, unstable_opts.teach,
diagnostic_width, diagnostic_width,
false, false,
false, unstable_opts.track_diagnostics,
) )
.ui_testing(unstable_opts.ui_testing), .ui_testing(unstable_opts.ui_testing),
) )
@ -191,7 +191,7 @@ pub(crate) fn new_handler(
json_rendered, json_rendered,
diagnostic_width, diagnostic_width,
false, false,
false, unstable_opts.track_diagnostics,
) )
.ui_testing(unstable_opts.ui_testing), .ui_testing(unstable_opts.ui_testing),
) )

View file

@ -0,0 +1,6 @@
// compile-flags: -Z track-diagnostics
// error-pattern: created at
struct A;
struct B;
const S: A = B;

View file

@ -0,0 +1,10 @@
error[E0308]: mismatched types
--> $DIR/track-diagnostics.rs:6:14
|
LL | const S: A = B;
| ^ expected struct `A`, found struct `B`
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -170,6 +170,7 @@
-Z time-passes=val -- measure time of each rustc pass (default: no) -Z time-passes=val -- measure time of each rustc pass (default: no)
-Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details) -Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details)
-Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no) -Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no)
-Z track-diagnostics=val -- Tracks where in rustc a diagnostic was emitted
-Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation) -Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation)
-Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics -Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics
-Z translate-lang=val -- language identifier for diagnostic output -Z translate-lang=val -- language identifier for diagnostic output

View file

@ -0,0 +1,8 @@
// compile-flags: -Z track-diagnostics
// error-pattern: created at
struct A;
struct B;
const S: A = B;
fn main() {}

View file

@ -0,0 +1,10 @@
error[E0308]: mismatched types
--> $DIR/track-diagnostics.rs:6:14
|
LL | const S: A = B;
| ^ expected struct `A`, found struct `B`
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.