Skip to content

Commit 4fd07a0

Browse files
committed
ra_ide: remove dead code in HoverResult
1 parent bf0c3ec commit 4fd07a0

File tree

1 file changed

+5
-41
lines changed

1 file changed

+5
-41
lines changed

crates/ra_ide/src/hover.rs

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! FIXME: write short doc here
1+
//! Logic for computing info that is displayed when the user hovers over any
2+
//! source code items (e.g. function call, struct field, variable symbol...)
23
34
use hir::{
45
Adt, AsAssocItem, AssocItemContainer, FieldSource, HasSource, HirDisplay, ModuleDef,
@@ -24,35 +25,20 @@ use itertools::Itertools;
2425
use std::iter::once;
2526

2627
/// Contains the results when hovering over an item
27-
#[derive(Debug, Clone)]
28+
#[derive(Debug, Default)]
2829
pub struct HoverResult {
2930
results: Vec<String>,
30-
exact: bool,
31-
}
32-
33-
impl Default for HoverResult {
34-
fn default() -> Self {
35-
HoverResult::new()
36-
}
3731
}
3832

3933
impl HoverResult {
4034
pub fn new() -> HoverResult {
41-
HoverResult {
42-
results: Vec::new(),
43-
// We assume exact by default
44-
exact: true,
45-
}
35+
Self::default()
4636
}
4737

4838
pub fn extend(&mut self, item: Option<String>) {
4939
self.results.extend(item);
5040
}
5141

52-
pub fn is_exact(&self) -> bool {
53-
self.exact
54-
}
55-
5642
pub fn is_empty(&self) -> bool {
5743
self.results.is_empty()
5844
}
@@ -72,20 +58,7 @@ impl HoverResult {
7258
/// Returns the results converted into markup
7359
/// for displaying in a UI
7460
pub fn to_markup(&self) -> String {
75-
let mut markup = if !self.exact {
76-
let mut msg = String::from("Failed to exactly resolve the symbol. This is probably because rust_analyzer does not yet support traits.");
77-
if !self.results.is_empty() {
78-
msg.push_str(" \nThese items were found instead:");
79-
}
80-
msg.push_str("\n\n---\n");
81-
msg
82-
} else {
83-
String::new()
84-
};
85-
86-
markup.push_str(&self.results.join("\n\n---\n"));
87-
88-
markup
61+
self.results.join("\n\n---\n")
8962
}
9063
}
9164

@@ -595,7 +568,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
595568
);
596569
let hover = analysis.hover(position).unwrap().unwrap();
597570
assert_eq!(trim_markup_opt(hover.info.first()), Some("wrapper::Thing\nfn new() -> Thing"));
598-
assert_eq!(hover.info.is_exact(), true);
599571
}
600572

601573
#[test]
@@ -618,7 +590,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
618590
);
619591
let hover = analysis.hover(position).unwrap().unwrap();
620592
assert_eq!(trim_markup_opt(hover.info.first()), Some("const C: u32"));
621-
assert_eq!(hover.info.is_exact(), true);
622593
}
623594

624595
#[test]
@@ -635,7 +606,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
635606
);
636607
let hover = analysis.hover(position).unwrap().unwrap();
637608
assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing"));
638-
assert_eq!(hover.info.is_exact(), true);
639609

640610
/* FIXME: revive these tests
641611
let (analysis, position) = single_file_with_position(
@@ -651,7 +621,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
651621
652622
let hover = analysis.hover(position).unwrap().unwrap();
653623
assert_eq!(trim_markup_opt(hover.info.first()), Some("Thing"));
654-
assert_eq!(hover.info.is_exact(), true);
655624
656625
let (analysis, position) = single_file_with_position(
657626
"
@@ -665,7 +634,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
665634
);
666635
let hover = analysis.hover(position).unwrap().unwrap();
667636
assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing"));
668-
assert_eq!(hover.info.is_exact(), true);
669637
670638
let (analysis, position) = single_file_with_position(
671639
"
@@ -678,7 +646,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
678646
);
679647
let hover = analysis.hover(position).unwrap().unwrap();
680648
assert_eq!(trim_markup_opt(hover.info.first()), Some("enum Thing"));
681-
assert_eq!(hover.info.is_exact(), true);
682649
*/
683650
}
684651

@@ -696,7 +663,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
696663
);
697664
let hover = analysis.hover(position).unwrap().unwrap();
698665
assert_eq!(trim_markup_opt(hover.info.first()), Some("i32"));
699-
assert_eq!(hover.info.is_exact(), true);
700666
}
701667

702668
#[test]
@@ -714,7 +680,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
714680
);
715681
let hover = analysis.hover(position).unwrap().unwrap();
716682
assert_eq!(trim_markup_opt(hover.info.first()), Some("macro_rules! foo"));
717-
assert_eq!(hover.info.is_exact(), true);
718683
}
719684

720685
#[test]
@@ -726,7 +691,6 @@ fn func(foo: i32) { if true { <|>foo; }; }
726691
);
727692
let hover = analysis.hover(position).unwrap().unwrap();
728693
assert_eq!(trim_markup_opt(hover.info.first()), Some("i32"));
729-
assert_eq!(hover.info.is_exact(), true);
730694
}
731695

732696
#[test]

0 commit comments

Comments
 (0)