Skip to content

Commit 781b514

Browse files
author
Jonas Schievink
committed
Add test for macro generated items
1 parent a70a0ca commit 781b514

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

crates/ra_assists/src/handlers/auto_import.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ fn main() {
865865

866866
#[test]
867867
fn whole_segment() {
868+
// Tests that only imports whose last segment matches the identifier get suggested.
868869
check_assist(
869870
auto_import,
870871
r"
@@ -883,6 +884,36 @@ fn main() {
883884
884885
struct S;
885886
impl fmt::Display for S {}
887+
",
888+
);
889+
}
890+
891+
#[test]
892+
fn macro_generated() {
893+
// Tests that macro-generated items are suggested from external crates.
894+
check_assist(
895+
auto_import,
896+
r"
897+
//- /lib.rs crate:dep
898+
899+
macro_rules! mac {
900+
() => {
901+
pub struct Cheese;
902+
};
903+
}
904+
905+
mac!();
906+
907+
//- /main.rs crate:main deps:dep
908+
909+
fn main() {
910+
Cheese<|>;
911+
}",
912+
r"use dep::Cheese;
913+
914+
fn main() {
915+
Cheese;
916+
}
886917
",
887918
);
888919
}

0 commit comments

Comments
 (0)