about summary refs log tree commit diff
path: root/src/tools/rust-analyzer
diff options
context:
space:
mode:
authorbit-aloo <sshourya17@gmail.com>2025-02-26 22:19:22 +0530
committerbit-aloo <sshourya17@gmail.com>2025-02-28 10:03:03 +0530
commit2071cc27f23aa0134e2a1f8bf3328f371ee559be (patch)
tree113f669e6bec01cff06583d0b3deef7028c5ac3c /src/tools/rust-analyzer
parent73488449c53821a8f4860f67e8580fc9eeb65e26 (diff)
downloadrust-2071cc27f23aa0134e2a1f8bf3328f371ee559be.tar.gz
rust-2071cc27f23aa0134e2a1f8bf3328f371ee559be.zip
add test
Diffstat (limited to 'src/tools/rust-analyzer')
-rw-r--r--src/tools/rust-analyzer/crates/ide-completion/src/render.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/render.rs b/src/tools/rust-analyzer/crates/ide-completion/src/render.rs
index d9f3fe13267..4f6c4cb6639 100644
--- a/src/tools/rust-analyzer/crates/ide-completion/src/render.rs
+++ b/src/tools/rust-analyzer/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(