mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 05:03:47 +00:00
Merge #8719
8719: Fix block comment intra doc link injection ranges r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
d9f1b5fc7c
@ -484,10 +484,10 @@ impl AttrsWithOwner {
|
||||
let mut buf = String::new();
|
||||
let mut mapping = Vec::new();
|
||||
for (doc, idx) in docs {
|
||||
// str::lines doesn't yield anything for the empty string
|
||||
if !doc.is_empty() {
|
||||
for line in doc.split('\n') {
|
||||
let line = line.trim_end();
|
||||
let mut base_offset = 0;
|
||||
for raw_line in doc.split('\n') {
|
||||
let line = raw_line.trim_end();
|
||||
let line_len = line.len();
|
||||
let (offset, line) = match line.char_indices().nth(indent) {
|
||||
Some((offset, _)) => (offset, &line[offset..]),
|
||||
@ -498,9 +498,13 @@ impl AttrsWithOwner {
|
||||
mapping.push((
|
||||
TextRange::new(buf_offset.try_into().ok()?, buf.len().try_into().ok()?),
|
||||
idx,
|
||||
TextRange::new(offset.try_into().ok()?, line_len.try_into().ok()?),
|
||||
TextRange::at(
|
||||
(base_offset + offset).try_into().ok()?,
|
||||
line_len.try_into().ok()?,
|
||||
),
|
||||
));
|
||||
buf.push('\n');
|
||||
base_offset += raw_line.len() + 1;
|
||||
}
|
||||
} else {
|
||||
buf.push('\n');
|
||||
|
@ -142,6 +142,7 @@ It is beyond me why you'd use these when you got ///
|
||||
```rust
|
||||
</span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="function injected">example</span><span class="parenthesis injected">(</span><span class="operator injected">&</span><span class="bracket injected">[</span><span class="numeric_literal injected">1</span><span class="comma injected">,</span><span class="none injected"> </span><span class="numeric_literal injected">2</span><span class="comma injected">,</span><span class="none injected"> </span><span class="numeric_literal injected">3</span><span class="bracket injected">]</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span><span class="comment documentation">
|
||||
```
|
||||
</span><span class="function documentation injected intra_doc_link">[`block_comments2`]</span><span class="comment documentation"> tests these with indentation
|
||||
*/</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">block_comments</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
||||
@ -150,5 +151,6 @@ It is beyond me why you'd use these when you got ///
|
||||
```rust
|
||||
</span><span class="comment documentation"> </span><span class="none injected"> </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="function injected">example</span><span class="parenthesis injected">(</span><span class="operator injected">&</span><span class="bracket injected">[</span><span class="numeric_literal injected">1</span><span class="comma injected">,</span><span class="none injected"> </span><span class="numeric_literal injected">2</span><span class="comma injected">,</span><span class="none injected"> </span><span class="numeric_literal injected">3</span><span class="bracket injected">]</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span><span class="comment documentation">
|
||||
```
|
||||
</span><span class="function documentation injected intra_doc_link">[`block_comments`]</span><span class="comment documentation"> tests these without indentation
|
||||
*/</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">block_comments2</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span></code></pre>
|
@ -618,6 +618,7 @@ It is beyond me why you'd use these when you got ///
|
||||
```rust
|
||||
let _ = example(&[1, 2, 3]);
|
||||
```
|
||||
[`block_comments2`] tests these with indentation
|
||||
*/
|
||||
pub fn block_comments() {}
|
||||
|
||||
@ -626,6 +627,7 @@ pub fn block_comments() {}
|
||||
```rust
|
||||
let _ = example(&[1, 2, 3]);
|
||||
```
|
||||
[`block_comments`] tests these without indentation
|
||||
*/
|
||||
pub fn block_comments2() {}
|
||||
"#
|
||||
|
Loading…
Reference in New Issue
Block a user