diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-09-13 20:21:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-13 20:21:22 +0200 |
| commit | 7b7f6f919df54fda2655ac228b836e3c9701e7f7 (patch) | |
| tree | 81ac1fa2d07c4f5957ef7b2547dd5e3b482a7c00 | |
| parent | 51cf121e6d5c633c819e37c6eea591bc8f2c8475 (diff) | |
| parent | 5dc9790e10b6f57a9f92a2210bb2375cb735c228 (diff) | |
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.
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index b478a1d15c5..e38cd516b91 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -544,6 +544,12 @@ impl Span { } /// Returns a `Span` that would enclose both `self` and `end`. + /// + /// ```text + /// ____ ___ + /// self lorem ipsum end + /// ^^^^^^^^^^^^^^^^^^^^ + /// ``` pub fn to(self, end: Span) -> Span { let span_data = self.data(); let end_data = end.data(); @@ -567,6 +573,12 @@ impl Span { } /// Returns a `Span` between the end of `self` to the beginning of `end`. + /// + /// ```text + /// ____ ___ + /// self lorem ipsum end + /// ^^^^^^^^^^^^^ + /// ``` pub fn between(self, end: Span) -> Span { let span = self.data(); let end = end.data(); @@ -577,7 +589,13 @@ impl Span { ) } - /// Returns a `Span` between the beginning of `self` to the beginning of `end`. + /// Returns a `Span` from the beginning of `self` until the beginning of `end`. + /// + /// ```text + /// ____ ___ + /// self lorem ipsum end + /// ^^^^^^^^^^^^^^^^^ + /// ``` pub fn until(self, end: Span) -> Span { let span = self.data(); let end = end.data(); |
