diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-01 20:45:48 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-01 20:45:48 +0100 |
commit | 8d02b24b259964d762dae45e6cce80d2fcdd6dd4 (patch) | |
tree | 45c4c9091e05ad944178b8a6f0f6a2cb7dd5a783 /crates | |
parent | 21588e15dfa8b117b503769119320e718bade351 (diff) | |
parent | ebff5762e9789ecd472564284994a9ac119b4166 (diff) |
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 <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/display/short_label.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide/src/hover.rs | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 4b081bf6c..d37260e96 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs | |||
@@ -33,7 +33,11 @@ impl ShortLabel for ast::EnumDef { | |||
33 | 33 | ||
34 | impl ShortLabel for ast::TraitDef { | 34 | impl ShortLabel for ast::TraitDef { |
35 | fn short_label(&self) -> Option<String> { | 35 | 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 | } | ||
37 | } | 41 | } |
38 | } | 42 | } |
39 | 43 | ||
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a62f598f0..54d318858 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -869,4 +869,15 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
869 | &[r#"pub(crate) async unsafe extern "C" fn foo()"#], | 869 | &[r#"pub(crate) async unsafe extern "C" fn foo()"#], |
870 | ); | 870 | ); |
871 | } | 871 | } |
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 | } | ||
872 | } | 883 | } |