about summary refs log tree commit diff
path: root/compiler/rustc_span/src/source_map
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2022-10-25 20:47:19 +0800
committeryukang <moorekang@gmail.com>2022-10-25 21:16:12 +0800
commit6d455296fde6ff0d5154d39513259a60eb73f302 (patch)
treec98bd02f725f23c0b983f1673ea0dc6d9d5fd4aa /compiler/rustc_span/src/source_map
parent9be2f35a4c1ed1b04aa4a6945b64763f599259ff (diff)
downloadrust-6d455296fde6ff0d5154d39513259a60eb73f302.tar.gz
rust-6d455296fde6ff0d5154d39513259a60eb73f302.zip
Fix #103451, find_width_of_character_at_span return width with 1 when reaching end
Diffstat (limited to 'compiler/rustc_span/src/source_map')
-rw-r--r--compiler/rustc_span/src/source_map/tests.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs
index 1fd81018fa0..3cab59e8dbe 100644
--- a/compiler/rustc_span/src/source_map/tests.rs
+++ b/compiler/rustc_span/src/source_map/tests.rs
@@ -511,16 +511,17 @@ fn test_next_point() {
     assert_eq!(span.lo().0, 4);
     assert_eq!(span.hi().0, 5);
 
-    // A non-empty span at the last byte should advance to create an empty
-    // span pointing at the end of the file.
+    // Reaching to the end of file, return a span that will get error with `span_to_snippet`
     let span = Span::with_root_ctxt(BytePos(4), BytePos(5));
     let span = sm.next_point(span);
     assert_eq!(span.lo().0, 5);
-    assert_eq!(span.hi().0, 5);
+    assert_eq!(span.hi().0, 6);
+    assert!(sm.span_to_snippet(span).is_err());
 
-    // Empty span pointing just past the last byte.
+    // Reaching to the end of file, return a span that will get error with `span_to_snippet`
     let span = Span::with_root_ctxt(BytePos(5), BytePos(5));
     let span = sm.next_point(span);
     assert_eq!(span.lo().0, 5);
-    assert_eq!(span.hi().0, 5);
+    assert_eq!(span.hi().0, 6);
+    assert!(sm.span_to_snippet(span).is_err());
 }