Uh oh!
There was an error while loading. Please reload this page.
Use spans pointing at the inside of a rustdoc attribute - #51391
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
GuillaumeGomez
commented
Jun 6, 2018
Awesome! Once ci fixed, r=me |
kennytm
commented
Jun 6, 2018
@estebank Could you verify how this works for all kinds of doc comments: #![feature(external_doc)]/// Foo/// bar [BarA] bar/// bazpubfna(){}/** * Foo * bar [BarB] bar * baz */pubfnb(){}/** Foobar [BarC] barbaz let bar_c_1 = 0; let bar_c_2 = 0; let g = [bar_c_1]; let h = g[bar_c_2];*/pubfnc(){}#[doc = "Foo\nbar [BarD] bar\nbaz"]pubfnd(){}#[doc(include = "file.md")]pubfne(){}macro_rules! f {($f:expr) => {
#[doc = $f]pubfn f(){}}}f!("Foo\nbar [BarF] bar\nbaz");Here the content of Foo
bar [BarE] bar
bazFor reference, the existing output post-51111 |
estebank
commented
Jun 6, 2018
@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.
| // 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 😃
estebank
commented
Jun 7, 2018
@bors r=GuillaumeGomez |
bors
commented
Jun 7, 2018
📌 Commit 31bb50b has been approved by |
bors
commented
Jun 7, 2018
🌲 The tree is currently closed for pull requests below priority 10, this pull request will be tested once the tree is reopened |
bors
commented
Jun 8, 2018
⌛ Testing commit 31bb50b with merge bdc515addf0bed215a5581c6d2d5fe90aca612fd... |
bors
commented
Jun 8, 2018
💔 Test failed - status-appveyor |
kennytm
commented
Jun 8, 2018
@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