Unnamed repository; edit this file 'description' to name the repository.
add test
bit-aloo 2025-02-28
parent 09315ef · commit dcb25b1
-rw-r--r--crates/ide-completion/src/render.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs
index d9f3fe1326..4f6c4cb663 100644
--- a/crates/ide-completion/src/render.rs
+++ b/crates/ide-completion/src/render.rs
@@ -2006,6 +2006,30 @@ fn f() {
}
#[test]
+ fn test_avoid_redundant_suggestion() {
+ check_relevance(
+ r#"
+struct aa([u8]);
+
+impl aa {
+ fn from_bytes(bytes: &[u8]) -> &Self {
+ unsafe { &*(bytes as *const [u8] as *const aa) }
+ }
+}
+
+fn bb()-> &'static aa {
+ let bytes = b"hello";
+ aa::$0
+}
+"#,
+ expect![[r#"
+ ex bb() [type]
+ fn from_bytes(…) fn(&[u8]) -> &aa [type_could_unify]
+ "#]],
+ );
+ }
+
+ #[test]
fn suggest_ref_mut() {
cov_mark::check!(suggest_ref);
check_relevance(