Properly handle doc attributes in doc-comment highlight injection

This commit is contained in:
Lukas Wirth 2021-03-16 21:05:07 +01:00
parent 3daa302cd3
commit c766492d26
5 changed files with 84 additions and 8 deletions

View file

@ -162,7 +162,6 @@ impl RawAttrs {
let attr = ast::Attr::parse(&format!("#[{}]", tree)).ok()?;
// FIXME hygiene
let hygiene = Hygiene::new_unhygienic();
// FIXME same index is assigned to multiple attributes
Attr::from_src(attr, &hygiene).map(|attr| Attr { index, ..attr })
});
@ -450,6 +449,13 @@ impl Attr {
_ => None,
}
}
pub fn string_value(&self) -> Option<&SmolStr> {
match self.input.as_ref()? {
AttrInput::Literal(it) => Some(it),
_ => None,
}
}
}
#[derive(Debug, Clone, Copy)]