Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/macro_expansion_tests/proc_macros.rs')
| -rw-r--r-- | crates/hir-def/src/macro_expansion_tests/proc_macros.rs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs index 822bdcc122..060b8aa8c1 100644 --- a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs +++ b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs @@ -94,6 +94,41 @@ fn foo() { } #[test] +fn macro_rules_in_attr() { + // Regression test for https://github.com/rust-lang/rust-analyzer/issues/12211 + check( + r#" +//- proc_macros: identity +macro_rules! id { + ($($t:tt)*) => { + $($t)* + }; +} +id! { + #[proc_macros::identity] + impl Foo for WrapBj { + async fn foo(&self) { + self.id().await; + } + } +} +"#, + expect![[r#" +macro_rules! id { + ($($t:tt)*) => { + $($t)* + }; +} +#[proc_macros::identity] impl Foo for WrapBj { + async fn foo(&self ) { + self .id().await ; + } +} +"#]], + ); +} + +#[test] fn float_parsing_panic() { // Regression test for https://github.com/rust-lang/rust-analyzer/issues/12211 check( @@ -127,3 +162,27 @@ macro_rules! id { "#]], ); } + +#[test] +fn float_attribute_mapping() { + check( + r#" +//- proc_macros: identity +//+spans+syntaxctxt +#[proc_macros::identity] +fn foo(&self) { + self.0. 1; +} +"#, + expect![[r#" +//+spans+syntaxctxt +#[proc_macros::identity] +fn foo(&self) { + self.0. 1; +} + +fn#FileId(0):[email protected]\0# foo#FileId(0):[email protected]\0#(#FileId(0):[email protected]\0#&#FileId(0):[email protected]\0#self#FileId(0):[email protected]\0# )#FileId(0):[email protected]\0# {#FileId(0):[email protected]\0# + self#FileId(0):[email protected]\0# .#FileId(0):[email protected]\0#0#FileId(0):[email protected]\0#.#FileId(0):[email protected]\0#1#FileId(0):[email protected]\0#;#FileId(0):[email protected]\0# +}#FileId(0):[email protected]\0#"#]], + ); +} |