mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
style: rename crates to kebab case
This commit is contained in:
parent
e025b37df6
commit
1f011fa4a3
462 changed files with 158 additions and 158 deletions
94
crates/hir-def/src/macro_expansion_tests/proc_macros.rs
Normal file
94
crates/hir-def/src/macro_expansion_tests/proc_macros.rs
Normal file
|
@ -0,0 +1,94 @@
|
|||
//! Tests for user-defined procedural macros.
|
||||
//!
|
||||
//! Note `//- proc_macros: identity` fixture metas in tests -- we don't use real
|
||||
//! proc-macros here, as that would be slow. Instead, we use several hard-coded
|
||||
//! in-memory macros.
|
||||
use expect_test::expect;
|
||||
|
||||
use crate::macro_expansion_tests::check;
|
||||
|
||||
#[test]
|
||||
fn attribute_macro_attr_censoring() {
|
||||
cov_mark::check!(attribute_macro_attr_censoring);
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: identity
|
||||
#[attr1] #[proc_macros::identity] #[attr2]
|
||||
struct S;
|
||||
"#,
|
||||
expect![[r##"
|
||||
#[attr1] #[proc_macros::identity] #[attr2]
|
||||
struct S;
|
||||
|
||||
#[attr1]
|
||||
#[attr2] struct S;"##]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn derive_censoring() {
|
||||
cov_mark::check!(derive_censoring);
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: derive_identity
|
||||
//- minicore:derive
|
||||
#[attr1]
|
||||
#[derive(Foo)]
|
||||
#[derive(proc_macros::DeriveIdentity)]
|
||||
#[derive(Bar)]
|
||||
#[attr2]
|
||||
struct S;
|
||||
"#,
|
||||
expect![[r##"
|
||||
#[attr1]
|
||||
#[derive(Foo)]
|
||||
#[derive(proc_macros::DeriveIdentity)]
|
||||
#[derive(Bar)]
|
||||
#[attr2]
|
||||
struct S;
|
||||
|
||||
#[attr1]
|
||||
#[derive(Bar)]
|
||||
#[attr2] struct S;"##]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn attribute_macro_syntax_completion_1() {
|
||||
// this is just the case where the input is actually valid
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: identity_when_valid
|
||||
#[proc_macros::identity_when_valid]
|
||||
fn foo() { bar.baz(); blub }
|
||||
"#,
|
||||
expect![[r##"
|
||||
#[proc_macros::identity_when_valid]
|
||||
fn foo() { bar.baz(); blub }
|
||||
|
||||
fn foo() {
|
||||
bar.baz();
|
||||
blub
|
||||
}"##]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn attribute_macro_syntax_completion_2() {
|
||||
// common case of dot completion while typing
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: identity_when_valid
|
||||
#[proc_macros::identity_when_valid]
|
||||
fn foo() { bar.; blub }
|
||||
"#,
|
||||
expect![[r##"
|
||||
#[proc_macros::identity_when_valid]
|
||||
fn foo() { bar.; blub }
|
||||
|
||||
fn foo() {
|
||||
bar. ;
|
||||
blub
|
||||
}"##]],
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue