-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
annotate-snippet emitter: Add UI test where annotated_files
count is > 1
#64205
Comments
Under the assumption, that we do have an existing UI test with annotations from multiple files, I'm happy to help out anyone who wants to take on this issue. Otherwise we'll have to write a test case ourselves. @rustbot modify labels to +A-diagnostics, +E-mentor, +E-help-wanted |
annotate-snippet emitter: Update an issue number The tracking issue has been replaced by one with mentoring instructions (rust-lang#64205).
annotate-snippet emitter: Update an issue number The tracking issue has been replaced by one with mentoring instructions (rust-lang#64205).
Hey @phansch I'd like to pick this issue up. |
@bIgBV sure, it's all yours! Let me know if you have any questions. The |
@phansch I made the change suggested in the issue and ran all the ui tests (over 9000!). None of them failed, meaning a new test needs to be written for this specific usecase, correct? |
Thanks! Unfortunately I just realized I made a mistake in the instructions :/ Instead, you'll want to include the snippet below this line in rust/src/librustc_errors/emitter.rs Line 1172 in 7eb65df
If you could give that a try too, that would be great! |
Will do! EDIT: @phansch re-ran it with the new changes, still no failures. I'm guessing that we need to add a new test. |
@phansch looks like edits on github don't generate notifications, apologies. But I retried the tests with the second change you suggested. Still no failing tests. |
@bIgBV Sorry, been out sick the past couple of days. Thanks for testing again! It's weird that you don't get failing tests 🤔 Could you try to apply this specific patch? diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 0ce69eecc6..8a3fbb6e09 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -1185,6 +1185,10 @@ impl EmitterWriter {
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
return Ok(());
};
+ if annotated_files.len() > 1 {
+ let filename = primary_lo.file.name.to_string();
+ panic!("annotated_files > 1 in {}", filename);
+ }
if let Ok(pos) =
annotated_files.binary_search_by(|x| x.file.name.cmp(&primary_lo.file.name)) {
annotated_files.swap(0, pos); When you run |
Okay, something is weird, after pulling in the latest master and making the exact changes in the patch you provided, there are over 8000 failing tests. I want to check if there is something obviously wrong going on, but I might not get back until tomorrow, as each test run takes close to an hour on my laptop. |
@phansch sorry for the late reply, I got a little caught up but finally got around to making the changes and doing a fresh build and test. there are 18 failing tests on the latest stable rustc build.
I'm guessing I need to move on to the next step as you detailed in the issue right? Could you give me some context into what an annotated snippet is and why it matters that it spans multiple files? |
Same here 😅
Yup, at least one of those tests should fail with our panic message. I think
In general, a snippet is a piece of code that can span multiple lines and Aside: Note that rustc has a We care about the fact that a snippet can span more than one file, because the Let me know if you have more questions or need help (You can also ask on Zulip in |
ping from triage @bIgBV, any updates on this? Thanks for your work! |
@hdhoang sorry about the delay, I got a bit busy with work recently, but I'm going to pick this up again. |
PR with fix: #114018 |
Part of #59346
It would be nice to have a UI test for the annotate-snippet emitter, that includes annotations that span multiple files. The goal of this issue is to find and add such a test.
Instructions
A simple way to look for this, would be to add this code:
to the top of
fn slices_for_files
and then check the failing UI tests.If there are failing UI tests, it means that those UI tests include a diagnostic that probably spans multiple files.
The next step, is to copy that file (and possible auxiliary files) over into
src/test/ui/annotate-snippet/
and add// compile-flags: --error-format human-annotate-rs
to the top of the UI test.Once that's done, be sure to run the added test and open a PR including the blessed stderr files.
The text was updated successfully, but these errors were encountered: