Skip to content

Commit 8d02b24

Browse files
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>
2 parents 21588e1 + ebff576 commit 8d02b24

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crates/ra_ide/src/display/short_label.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ impl ShortLabel for ast::EnumDef {
3333

3434
impl ShortLabel for ast::TraitDef {
3535
fn short_label(&self) -> Option<String> {
36-
short_label_from_node(self, "trait ")
36+
if self.unsafe_token().is_some() {
37+
short_label_from_node(self, "unsafe trait ")
38+
} else {
39+
short_label_from_node(self, "trait ")
40+
}
3741
}
3842
}
3943

crates/ra_ide/src/hover.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,4 +869,15 @@ fn func(foo: i32) { if true { <|>foo; }; }
869869
&[r#"pub(crate) async unsafe extern "C" fn foo()"#],
870870
);
871871
}
872+
873+
#[test]
874+
fn test_hover_trait_show_qualifiers() {
875+
check_hover_result(
876+
"
877+
//- /lib.rs
878+
unsafe trait foo<|>() {}
879+
",
880+
&["unsafe trait foo"],
881+
);
882+
}
872883
}

0 commit comments

Comments
 (0)