Use spans pointing at the inside of a rustdoc attribute#51391
Use spans pointing at the inside of a rustdoc attribute#51391bors merged 3 commits intorust-lang:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Awesome! Once ci fixed, r=me |
|
@estebank Could you verify how this works for all kinds of doc comments: #![feature(external_doc)]
/// Foo
/// bar [BarA] bar
/// baz
pub fn a() {}
/**
* Foo
* bar [BarB] bar
* baz
*/
pub fn b() {}
/** Foo
bar [BarC] bar
baz
let bar_c_1 = 0;
let bar_c_2 = 0;
let g = [bar_c_1];
let h = g[bar_c_2];
*/
pub fn c() {}
#[doc = "Foo\nbar [BarD] bar\nbaz"]
pub fn d() {}
#[doc(include = "file.md")]
pub fn e() {}
macro_rules! f {
($f:expr) => {
#[doc = $f]
pub fn f() {}
}
}
f!("Foo\nbar [BarF] bar\nbaz");Here the content of Foo
bar [BarE] bar
bazFor reference, the existing output post-51111 |
|
@kennytm modified the code to fallback to the current behavior if the line count of the docs don't match the line count of the code. This uses the new spans for the |
This comment has been minimized.
This comment has been minimized.
src/librustdoc/clean/mod.rs
Outdated
| // Extract the specific span | ||
| let lo = sp.lo() + syntax_pos::BytePos((link_range.start + code_dox_len) as u32); | ||
| let hi = lo + syntax_pos::BytePos(link_range.len() as u32); | ||
| let sp = sp.with_lo(lo).with_hi(hi); |
There was a problem hiding this comment.
You could use
let sp = sp.from_inner_byte_pos(
link_range.start + code_dox_len,
link_range.end + code_dox_len,
);here 😃
|
@bors r=GuillaumeGomez |
|
📌 Commit 31bb50b has been approved by |
|
🌲 The tree is currently closed for pull requests below priority 10, this pull request will be tested once the tree is reopened |
|
⌛ Testing commit 31bb50b with merge bdc515addf0bed215a5581c6d2d5fe90aca612fd... |
|
💔 Test failed - status-appveyor |
|
@bors retry Why closing the tree would cancel the existing PR? 😕 |
Use spans pointing at the inside of a rustdoc attribute Follow up to rust-lang#51111. Point to the link in a rustdoc attribute where intralink resolution failed, instead of the full rustdoc attribute's span. r? @GuillaumeGomez cc @kennytm
Rollup of 13 pull requests Successful merges: - #50143 (Add deprecation lint for duplicated `macro_export`s) - #51099 (Fix Issue 38777) - #51276 (Dedup auto traits in trait objects.) - #51298 (Stabilize unit tests with non-`()` return type) - #51360 (Suggest parentheses when a struct literal needs them) - #51391 (Use spans pointing at the inside of a rustdoc attribute) - #51394 (Use scope tree depths to speed up `nearest_common_ancestor`.) - #51396 (Make the size of Option<NonZero*> a documented guarantee.) - #51401 (Warn on `repr` without hints) - #51412 (Avoid useless Vec clones in pending_obligations().) - #51427 (compiletest: autoremove duplicate .nll.* files (#51204)) - #51436 (Do not require stage 2 compiler for rustdoc) - #51437 (rustbuild: generate full list of dependencies for metadata) Failed merges:
Follow up to #51111.
Point to the link in a rustdoc attribute where intralink resolution failed, instead of the full rustdoc attribute's span.
r? @GuillaumeGomez cc @kennytm