Skip to content

Commit 2071cc2

Browse files
committed
add test
1 parent 7348844 commit 2071cc2

File tree

1 file changed

+24
-0
lines changed
  • src/tools/rust-analyzer/crates/ide-completion/src

1 file changed

+24
-0
lines changed

src/tools/rust-analyzer/crates/ide-completion/src/render.rs

+24
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,30 @@ fn f() {
20052005
);
20062006
}
20072007

2008+
#[test]
2009+
fn test_avoid_redundant_suggestion() {
2010+
check_relevance(
2011+
r#"
2012+
struct aa([u8]);
2013+
2014+
impl aa {
2015+
fn from_bytes(bytes: &[u8]) -> &Self {
2016+
unsafe { &*(bytes as *const [u8] as *const aa) }
2017+
}
2018+
}
2019+
2020+
fn bb()-> &'static aa {
2021+
let bytes = b"hello";
2022+
aa::$0
2023+
}
2024+
"#,
2025+
expect![[r#"
2026+
ex bb() [type]
2027+
fn from_bytes(…) fn(&[u8]) -> &aa [type_could_unify]
2028+
"#]],
2029+
);
2030+
}
2031+
20082032
#[test]
20092033
fn suggest_ref_mut() {
20102034
cov_mark::check!(suggest_ref);

0 commit comments

Comments
 (0)