From 09a78caca403f1b4be8711d00519094896928e58 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sun, 11 Apr 2021 11:12:02 -0700 Subject: Add macro test --- .../ide_assists/src/handlers/extract_function.rs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'crates') diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index 8e295098f..719f22053 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs @@ -3384,4 +3384,36 @@ fn foo() -> Result<(), i64> { }"##, ); } + + #[test] + fn param_usage_in_macro() { + check_assist( + extract_function, + r" +macro_rules! m { + ($val:expr) => { $val }; +} + +fn foo() { + let n = 1; + $0let k = n * m!(n);$0 + let m = k + 1; +}", + r" +macro_rules! m { + ($val:expr) => { $val }; +} + +fn foo() { + let n = 1; + let k = fun_name(n); + let m = k + 1; +} + +fn $0fun_name(n: i32) -> i32 { + let k = n * m!(n); + k +}", + ); + } } -- cgit v1.2.3