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
4 changes: 4 additions & 0 deletions src/librustdoc/html/span_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ impl<'tcx> SpanMapVisitor<'tcx> {
let span = path.segments.last().map_or(path.span, |seg| seg.ident.span);
// In case the path ends with generics, we remove them from the span.
let span = if only_use_last_segment {
if path.span.from_expansion() {
// For now we don't handle span from macro expansions so nothing to do here.
return;
}
span
} else {
// In `use` statements, the included item is not in the path segments. However,
Expand Down
21 changes: 21 additions & 0 deletions tests/rustdoc-html/jump-to-def/item-with-derive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This test ensures that the item name will link to its item's page even if there
// is a `#[derive(...)]`.
// This is a regression test for <https://github.com/rust-lang/rust/issues/158050>.

//@ compile-flags: -Zunstable-options --generate-link-to-definition

#![crate_name = "foo"]

//@ has 'src/foo/item-with-derive.rs.html'
//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar'
#[derive(Debug)]
pub struct Bar {
x: u8,
}

// Same test with an enum just in case...
//@ has - '//a[@href="../../foo/enum.Blob.html"]' 'Blob'
#[derive(Debug)]
pub enum Blob {
X,
}
Loading