mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Add tests for #12669
This commit is contained in:
parent
994f3cf74d
commit
e71519572c
2 changed files with 81 additions and 0 deletions
|
@ -1274,3 +1274,65 @@ impl S {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_in_unexpandable_attr_proc_macro_1() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:mac
|
||||
#[mac::attr_macro]
|
||||
fn foo() {
|
||||
let xxx = 1;
|
||||
//^^^ i32
|
||||
}
|
||||
|
||||
//- /mac.rs crate:mac
|
||||
#![crate_type="proc-macro"]
|
||||
#[proc_macro_attribute]
|
||||
pub fn attr_macro() {}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_in_unexpandable_attr_proc_macro_in_impl() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:mac
|
||||
struct Foo;
|
||||
impl Foo {
|
||||
#[mac::attr_macro]
|
||||
fn foo() {
|
||||
let xxx = 1;
|
||||
//^^^ i32
|
||||
}
|
||||
}
|
||||
|
||||
//- /mac.rs crate:mac
|
||||
#![crate_type="proc-macro"]
|
||||
#[proc_macro_attribute]
|
||||
pub fn attr_macro() {}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_in_unexpandable_attr_proc_macro_in_trait() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:mac
|
||||
trait Foo {
|
||||
#[mac::attr_macro]
|
||||
fn foo() {
|
||||
let xxx = 1;
|
||||
//^^^ i32
|
||||
}
|
||||
}
|
||||
|
||||
//- /mac.rs crate:mac
|
||||
#![crate_type="proc-macro"]
|
||||
#[proc_macro_attribute]
|
||||
pub fn attr_macro() {}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -104,6 +104,25 @@ fn f() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inactive_assoc_item() {
|
||||
// FIXME these currently don't work, hence the *
|
||||
check(
|
||||
r#"
|
||||
struct Foo;
|
||||
impl Foo {
|
||||
#[cfg(any())] pub fn f() {}
|
||||
//*************************** weak: code is inactive due to #[cfg] directives
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
#[cfg(any())] pub fn f() {}
|
||||
//*************************** weak: code is inactive due to #[cfg] directives
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
/// Tests that `cfg` attributes behind `cfg_attr` is handled properly.
|
||||
#[test]
|
||||
fn inactive_via_cfg_attr() {
|
||||
|
|
Loading…
Reference in a new issue