aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/hover.rs42
-rw-r--r--crates/ide/src/inlay_hints.rs2
-rw-r--r--crates/ide/src/join_lines.rs18
3 files changed, 59 insertions, 3 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 28e2e17dc..614433417 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -3897,4 +3897,46 @@ trait A where
3897 "#]], 3897 "#]],
3898 ); 3898 );
3899 } 3899 }
3900
3901 #[test]
3902 fn string_shadowed_with_inner_items() {
3903 check(
3904 r#"
3905//- /main.rs crate:main deps:alloc
3906
3907/// Custom `String` type.
3908struct String;
3909
3910fn f() {
3911 let _: String$0;
3912
3913 fn inner() {}
3914}
3915
3916//- /alloc.rs crate:alloc
3917#[prelude_import]
3918pub use string::*;
3919
3920mod string {
3921 /// This is `alloc::String`.
3922 pub struct String;
3923}
3924 "#,
3925 expect![[r#"
3926 *String*
3927
3928 ```rust
3929 main
3930 ```
3931
3932 ```rust
3933 struct String
3934 ```
3935
3936 ---
3937
3938 Custom `String` type.
3939 "#]],
3940 )
3941 }
3900} 3942}
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index f73edf8b6..d5ef054d8 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -234,7 +234,7 @@ fn hint_iterator(
234 hir::AssocItem::TypeAlias(alias) if alias.name(db) == known::Item => Some(alias), 234 hir::AssocItem::TypeAlias(alias) if alias.name(db) == known::Item => Some(alias),
235 _ => None, 235 _ => None,
236 })?; 236 })?;
237 if let Some(ty) = ty.normalize_trait_assoc_type(db, iter_trait, &[], assoc_type_item) { 237 if let Some(ty) = ty.normalize_trait_assoc_type(db, &[], assoc_type_item) {
238 const LABEL_START: &str = "impl Iterator<Item = "; 238 const LABEL_START: &str = "impl Iterator<Item = ";
239 const LABEL_END: &str = ">"; 239 const LABEL_END: &str = ">";
240 240
diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs
index d584190f7..fe2a349e6 100644
--- a/crates/ide/src/join_lines.rs
+++ b/crates/ide/src/join_lines.rs
@@ -88,8 +88,11 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS
88 } 88 }
89 89
90 // The node is between two other nodes 90 // The node is between two other nodes
91 let prev = token.prev_sibling_or_token().unwrap(); 91 let (prev, next) = match (token.prev_sibling_or_token(), token.next_sibling_or_token()) {
92 let next = token.next_sibling_or_token().unwrap(); 92 (Some(prev), Some(next)) => (prev, next),
93 _ => return,
94 };
95
93 if is_trailing_comma(prev.kind(), next.kind()) { 96 if is_trailing_comma(prev.kind(), next.kind()) {
94 // Removes: trailing comma, newline (incl. surrounding whitespace) 97 // Removes: trailing comma, newline (incl. surrounding whitespace)
95 edit.delete(TextRange::new(prev.text_range().start(), token.text_range().end())); 98 edit.delete(TextRange::new(prev.text_range().start(), token.text_range().end()));
@@ -829,4 +832,15 @@ $0hello world
829"#, 832"#,
830 ); 833 );
831 } 834 }
835 #[test]
836 fn join_last_line_empty() {
837 check_join_lines(
838 r#"
839fn main() {$0}
840"#,
841 r#"
842fn main() {$0}
843"#,
844 );
845 }
832} 846}