mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Make the UTF-8 statement more explicit and explicitly test for it
This commit is contained in:
parent
5d7b6595ce
commit
7d20789c02
@ -432,8 +432,8 @@ pub struct LineColumn {
|
||||
/// The 1-indexed line in the source file on which the span starts or ends (inclusive).
|
||||
#[unstable(feature = "proc_macro_span", issue = "54725")]
|
||||
pub line: usize,
|
||||
/// The 1-indexed column (in UTF-8 characters) in the source file on which
|
||||
/// the span starts or ends (inclusive).
|
||||
/// The 1-indexed column (number of bytes in UTF-8 encoding) in the source
|
||||
/// file on which the span starts or ends (inclusive).
|
||||
#[unstable(feature = "proc_macro_span", issue = "54725")]
|
||||
pub column: usize,
|
||||
}
|
||||
|
@ -9,8 +9,16 @@ assert_span_pos::assert_span_pos!(5, 35);
|
||||
// Test tab indentation
|
||||
assert_span_pos::assert_span_pos!(10, 36);
|
||||
|
||||
// Two tests to ensure the promise of the docs that the column is the number
|
||||
// of UTF-8 bytes instead of some other number like number of code points.
|
||||
|
||||
// Test that multi byte UTF-8 characters indeed count as multiple bytes
|
||||
/*🌈*/assert_span_pos::assert_span_pos!(16, 40);
|
||||
// Test with a complete grapheme cluster
|
||||
/*🏳️🌈*/assert_span_pos::assert_span_pos!(18, 43);
|
||||
|
||||
// Test that the macro actually emits an error on a mismatch:
|
||||
assert_span_pos::assert_span_pos!(0, 35); //~ ERROR line/column mismatch: (0, 35) != (13, 35)
|
||||
assert_span_pos::assert_span_pos!(14, 0); //~ ERROR line/column mismatch: (14, 0) != (14, 35)
|
||||
assert_span_pos::assert_span_pos!(0, 35); //~ ERROR line/column mismatch: (0, 35) != (21, 35)
|
||||
assert_span_pos::assert_span_pos!(22, 0); //~ ERROR line/column mismatch: (22, 0) != (22, 35)
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: line/column mismatch: (0, 35) != (13, 35)
|
||||
--> $DIR/span-absolute-posititions.rs:13:35
|
||||
error: line/column mismatch: (0, 35) != (21, 35)
|
||||
--> $DIR/span-absolute-posititions.rs:21:35
|
||||
|
|
||||
LL | assert_span_pos::assert_span_pos!(0, 35);
|
||||
| ^
|
||||
|
||||
error: line/column mismatch: (14, 0) != (14, 35)
|
||||
--> $DIR/span-absolute-posititions.rs:14:35
|
||||
error: line/column mismatch: (22, 0) != (22, 35)
|
||||
--> $DIR/span-absolute-posititions.rs:22:35
|
||||
|
|
||||
LL | assert_span_pos::assert_span_pos!(14, 0);
|
||||
LL | assert_span_pos::assert_span_pos!(22, 0);
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user