Skip to content

Commit 571a965

Browse files
authored
Rollup merge of #62985 - phansch:support_ui_testing_flag, r=estebank
librustc_errors: Support ui-testing flag in annotate-snippet emitter This adds support for the `-Z ui-testing` flag to the new annotate-snippet diagnostic emitter. Support for the flag was added to `annotate-snippet-rs` in these PRs: * rust-lang/annotate-snippets-rs#3 * rust-lang/annotate-snippets-rs#5 r? @estebank Closes #61811
2 parents 0614a94 + dd0f2ac commit 571a965

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

Diff for: Cargo.lock

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ dependencies = [
4444
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
4545
]
4646

47+
[[package]]
48+
name = "annotate-snippets"
49+
version = "0.6.1"
50+
source = "registry+https://github.com/rust-lang/crates.io-index"
51+
4752
[[package]]
4853
name = "ansi_term"
4954
version = "0.11.0"
@@ -2891,7 +2896,7 @@ dependencies = [
28912896
name = "rustc_errors"
28922897
version = "0.0.0"
28932898
dependencies = [
2894-
"annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
2899+
"annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
28952900
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
28962901
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
28972902
"rustc_data_structures 0.0.0",
@@ -4280,6 +4285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
42804285
"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c"
42814286
"checksum ammonia 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "384d704f242a0a9faf793fff775a0be6ab9aa27edabffa097331d73779142520"
42824287
"checksum annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e8bcdcd5b291ce85a78f2b9d082a8de9676c12b1840d386d67bc5eea6f9d2b4e"
4288+
"checksum annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7021ce4924a3f25f802b2cccd1af585e39ea1a363a1aa2e72afe54b67a3a7a7"
42834289
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
42844290
"checksum arc-swap 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1025aeae2b664ca0ea726a89d574fe8f4e77dd712d443236ad1de00379450cf6"
42854291
"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392"

Diff for: src/librustc_errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
1717
unicode-width = "0.1.4"
1818
atty = "0.2"
1919
termcolor = "1.0"
20-
annotate-snippets = "0.5.0"
20+
annotate-snippets = "0.6.1"

Diff for: src/librustc_errors/annotate_snippet_emitter_writer.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct AnnotateSnippetEmitterWriter {
2323
source_map: Option<Lrc<SourceMapperDyn>>,
2424
/// If true, hides the longer explanation text
2525
short_message: bool,
26-
/// If true, will normalize line numbers with LL to prevent noise in UI test diffs.
26+
/// If true, will normalize line numbers with `LL` to prevent noise in UI test diffs.
2727
ui_testing: bool,
2828
}
2929

@@ -173,10 +173,6 @@ impl AnnotateSnippetEmitterWriter {
173173
/// Allows to modify `Self` to enable or disable the `ui_testing` flag.
174174
///
175175
/// If this is set to true, line numbers will be normalized as `LL` in the output.
176-
// FIXME(#59346): This method is used via the public interface, but setting the `ui_testing`
177-
// flag currently does not anonymize line numbers. We would have to add the `maybe_anonymized`
178-
// method from `emitter.rs` and implement rust-lang/annotate-snippets-rs#2 in order to
179-
// anonymize line numbers.
180176
pub fn ui_testing(mut self, ui_testing: bool) -> Self {
181177
self.ui_testing = ui_testing;
182178
self
@@ -202,7 +198,7 @@ impl AnnotateSnippetEmitterWriter {
202198
};
203199
if let Some(snippet) = converter.to_annotation_snippet() {
204200
let dl = DisplayList::from(snippet);
205-
let dlf = DisplayListFormatter::new(true);
201+
let dlf = DisplayListFormatter::new(true, self.ui_testing);
206202
// FIXME(#59346): Figure out if we can _always_ print to stderr or not.
207203
// `emitter.rs` has the `Destination` enum that lists various possible output
208204
// destinations.

Diff for: src/test/ui/annotate-snippet/missing-type.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
error[E0412]: cannot find type `Iter` in this scope
2-
--> $DIR/missing-type.rs:4:11
3-
|
4-
4 | let x: Iter;
5-
| ^^^^ not found in this scope
6-
|
2+
--> $DIR/missing-type.rs:4:11
3+
|
4+
LL | let x: Iter;
5+
| ^^^^ not found in this scope
6+
|

0 commit comments

Comments
 (0)