mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 17:44:28 +00:00
Fix link title attribute value when field of enum variants
This commit is contained in:
@@ -674,11 +674,15 @@ pub(crate) fn link_tooltip(
|
||||
fqp
|
||||
};
|
||||
if let &Some(UrlFragment::Item(id)) = fragment {
|
||||
write!(f, "{} ", cx.tcx().def_descr(id))?;
|
||||
let tcx = cx.tcx();
|
||||
write!(f, "{} ", tcx.def_descr(id))?;
|
||||
for component in fqp {
|
||||
write!(f, "{component}::")?;
|
||||
}
|
||||
write!(f, "{}", cx.tcx().item_name(id))?;
|
||||
if *shortty == ItemType::Enum && tcx.def_kind(id) == DefKind::Field {
|
||||
write!(f, "{}::", tcx.item_name(tcx.parent(id)))?;
|
||||
}
|
||||
write!(f, "{}", tcx.item_name(id))?;
|
||||
} else if !fqp.is_empty() {
|
||||
write!(f, "{shortty} ")?;
|
||||
write!(f, "{}", join_path_syms(fqp))?;
|
||||
|
||||
13
tests/rustdoc-html/intra-doc/enum-variant-field-title.rs
Normal file
13
tests/rustdoc-html/intra-doc/enum-variant-field-title.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
// This test ensures that the generated "title" attribute for field of enum variant
|
||||
// is correctly generated and includes the variant's name.
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/161028>.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
//@ has 'foo/enum.Enum.html'
|
||||
//@ has - '//*[@class="docblock"]//a[@title="field foo::Enum::Variant::field"]' 'Enum::Variant::field'
|
||||
|
||||
/// [Enum::Variant::field]
|
||||
pub enum Enum {
|
||||
Variant { field: i32 }
|
||||
}
|
||||
Reference in New Issue
Block a user