Skip to content

Commit 7b7f6f9

Browse files
Rollup merge of #76668 - pickfire:patch-9, r=jonas-schievink
Add visualization of rustc span in doc It took me quite some time to figure out what Span::to means. A picture is worth a thousand words.
2 parents 51cf121 + 5dc9790 commit 7b7f6f9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

compiler/rustc_span/src/lib.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@ impl Span {
544544
}
545545

546546
/// Returns a `Span` that would enclose both `self` and `end`.
547+
///
548+
/// ```text
549+
/// ____ ___
550+
/// self lorem ipsum end
551+
/// ^^^^^^^^^^^^^^^^^^^^
552+
/// ```
547553
pub fn to(self, end: Span) -> Span {
548554
let span_data = self.data();
549555
let end_data = end.data();
@@ -567,6 +573,12 @@ impl Span {
567573
}
568574

569575
/// Returns a `Span` between the end of `self` to the beginning of `end`.
576+
///
577+
/// ```text
578+
/// ____ ___
579+
/// self lorem ipsum end
580+
/// ^^^^^^^^^^^^^
581+
/// ```
570582
pub fn between(self, end: Span) -> Span {
571583
let span = self.data();
572584
let end = end.data();
@@ -577,7 +589,13 @@ impl Span {
577589
)
578590
}
579591

580-
/// Returns a `Span` between the beginning of `self` to the beginning of `end`.
592+
/// Returns a `Span` from the beginning of `self` until the beginning of `end`.
593+
///
594+
/// ```text
595+
/// ____ ___
596+
/// self lorem ipsum end
597+
/// ^^^^^^^^^^^^^^^^^
598+
/// ```
581599
pub fn until(self, end: Span) -> Span {
582600
let span = self.data();
583601
let end = end.data();

0 commit comments

Comments
 (0)