mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Merge #4244
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:
commit
8d02b24b25
2 changed files with 16 additions and 1 deletions
|
@ -33,7 +33,11 @@ impl ShortLabel for ast::EnumDef {
|
||||||
|
|
||||||
impl ShortLabel for ast::TraitDef {
|
impl ShortLabel for ast::TraitDef {
|
||||||
fn short_label(&self) -> Option<String> {
|
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 ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -869,4 +869,15 @@ fn func(foo: i32) { if true { <|>foo; }; }
|
||||||
&[r#"pub(crate) async unsafe extern "C" fn 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"],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue