mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Merge #3494
3494: Implement include macro r=matklad a=edwin0cheng This PR implement builtin `include` macro. * It does not support include as expression yet. * It doesn't consider `env!("OUT_DIR")` yet. Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
aa82b5915d
4 changed files with 107 additions and 19 deletions
|
@ -438,6 +438,51 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_builtin_macros_include() {
|
||||
let (db, pos) = TestDB::with_position(
|
||||
r#"
|
||||
//- /main.rs
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! include {() => {}}
|
||||
|
||||
include!("foo.rs");
|
||||
|
||||
fn main() {
|
||||
bar()<|>;
|
||||
}
|
||||
|
||||
//- /foo.rs
|
||||
fn bar() -> u32 {0}
|
||||
"#,
|
||||
);
|
||||
assert_eq!("u32", type_at_pos(&db, pos));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_builtin_macros_include_concat() {
|
||||
let (db, pos) = TestDB::with_position(
|
||||
r#"
|
||||
//- /main.rs
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! include {() => {}}
|
||||
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! concat {() => {}}
|
||||
|
||||
include!(concat!("f", "oo.rs"));
|
||||
|
||||
fn main() {
|
||||
bar()<|>;
|
||||
}
|
||||
|
||||
//- /foo.rs
|
||||
fn bar() -> u32 {0}
|
||||
"#,
|
||||
);
|
||||
assert_eq!("u32", type_at_pos(&db, pos));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_builtin_macros_concat_with_lazy() {
|
||||
assert_snapshot!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue