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:
bors[bot] 2020-03-06 15:08:41 +00:00 committed by GitHub
commit aa82b5915d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 107 additions and 19 deletions

View file

@ -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!(