Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1967,18 +1967,23 @@ impl Clean<Span> for rustc_span::Span {
return Span::empty();
}

// Get the macro invocation instead of the definition,
// in case the span is result of a macro expansion.
// (See rust-lang/rust#39726)
let span = self.source_callsite();

let sm = cx.sess().source_map();
let filename = sm.span_to_filename(*self);
let lo = sm.lookup_char_pos(self.lo());
let hi = sm.lookup_char_pos(self.hi());
let filename = sm.span_to_filename(span);
let lo = sm.lookup_char_pos(span.lo());
let hi = sm.lookup_char_pos(span.hi());
Span {
filename,
cnum: lo.file.cnum,
loline: lo.line,
locol: lo.col.to_usize(),
hiline: hi.line,
hicol: hi.col.to_usize(),
original: *self,
original: span,
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/test/rustdoc/external-macro-src.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// aux-build:external-macro-src.rs
// ignore-tidy-linelength

#![crate_name = "foo"]

#[macro_use]
extern crate external_macro_src;

// @has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#4-15"]' '[src]'
// @has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#3-12"]' '[src]'

// @has foo/struct.Foo.html
// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#8"]' '[src]'
// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#9-13"]' '[src]'
// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#10-12"]' '[src]'
// @has - '//a[@href="../src/foo/external-macro-src.rs.html#12"]' '[src]'
make_foo!();
2 changes: 1 addition & 1 deletion src/test/rustdoc/issue-26606.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
extern crate issue_26606_macro;

// @has issue_26606/constant.FOO.html
// @has - '//a/@href' '../src/issue_26606_macro/issue-26606-macro.rs.html#3'
// @has - '//a[@href="../src/issue_26606/issue-26606.rs.html#11"]' '[src]'
make_item!(FOO);
2 changes: 1 addition & 1 deletion src/test/rustdoc/thread-local-src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

// @has foo/index.html '//a[@href="../src/foo/thread-local-src.rs.html#1-6"]' '[src]'

// @has foo/constant.FOO.html '//a/@href' 'https://doc.rust-lang.org/nightly/src/std/'
// @has foo/constant.FOO.html '//a[@href="../src/foo/thread-local-src.rs.html#6"]' '[src]'
thread_local!(pub static FOO: bool = false);