4244: Show unsafe trait in hover r=matklad a=DianaNites

Following on #2450 and #4210, for traits.
`unsafe` is the only qualifier they can have, though.

Co-authored-by: Diana <5275194+DianaNites@users.noreply.github.com>
This commit is contained in:
bors[bot] 2020-05-01 19:45:48 +00:00 committed by GitHub
commit 8d02b24b25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -33,7 +33,11 @@ impl ShortLabel for ast::EnumDef {
impl ShortLabel for ast::TraitDef {
fn short_label(&self) -> Option<String> {
short_label_from_node(self, "trait ")
if self.unsafe_token().is_some() {
short_label_from_node(self, "unsafe trait ")
} else {
short_label_from_node(self, "trait ")
}
}
}

View file

@ -869,4 +869,15 @@ fn func(foo: i32) { if true { <|>foo; }; }
&[r#"pub(crate) async unsafe extern "C" fn foo()"#],
);
}
#[test]
fn test_hover_trait_show_qualifiers() {
check_hover_result(
"
//- /lib.rs
unsafe trait foo<|>() {}
",
&["unsafe trait foo"],
);
}
}