about summary refs log tree commit diff
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2023-07-19 23:48:43 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2023-07-19 23:48:43 +0000
commit20a3b9a2152ff705af029cbb359bc09a4b43a9c7 (patch)
tree998c9484a5c54038362df80b617327ce95285e74
parent39f42ad9e8430a8abb06c262346e89593278c515 (diff)
downloadrust-20a3b9a2152ff705af029cbb359bc09a4b43a9c7.tar.gz
rust-20a3b9a2152ff705af029cbb359bc09a4b43a9c7.zip
Use the correct span for displaying the line following a derive suggestion
-rw-r--r--compiler/rustc_errors/src/emitter.rs2
-rw-r--r--tests/ui/modules/issue-107649.stderr2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 9d4d159fd96..a0fa4115c3e 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -1982,7 +1982,7 @@ impl EmitterWriter {
                 // We special case `#[derive(_)]\n` and other attribute suggestions, because those
                 // are the ones where context is most useful.
                 let file_lines = sm
-                    .span_to_lines(span.primary_span().unwrap().shrink_to_hi())
+                    .span_to_lines(parts[0].span.shrink_to_hi())
                     .expect("span_to_lines failed when emitting suggestion");
                 let line_num = sm.lookup_char_pos(parts[0].span.lo()).line;
                 if let Some(line) = file_lines.file.get_line(line_num - 1) {
diff --git a/tests/ui/modules/issue-107649.stderr b/tests/ui/modules/issue-107649.stderr
index 38a910b57b4..5705e84e0d9 100644
--- a/tests/ui/modules/issue-107649.stderr
+++ b/tests/ui/modules/issue-107649.stderr
@@ -11,7 +11,7 @@ help: consider annotating `Dummy` with `#[derive(Debug)]`
    --> $DIR/auxiliary/dummy_lib.rs:2:1
     |
 2   + #[derive(Debug)]
-3   | #[path = "auxiliary/dummy_lib.rs"]
+3   | pub struct Dummy;
     |
 
 error: aborting due to previous error