mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Merge #6763
6763: Add test for `$crate` in builtin macros r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
b01981e636
2 changed files with 37 additions and 2 deletions
|
@ -134,3 +134,31 @@ fn f() {
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dollar_crate_in_builtin_macro() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
#[macro_export]
|
||||||
|
#[rustc_builtin_macro]
|
||||||
|
macro_rules! format_args {}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! arg {
|
||||||
|
() => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! outer {
|
||||||
|
() => {
|
||||||
|
$crate::format_args!( "", $crate::arg!(1) )
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
outer!();
|
||||||
|
//^^^^^^^^ leftover tokens
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -157,9 +157,16 @@ impl TestDB {
|
||||||
db.diagnostics(|d| {
|
db.diagnostics(|d| {
|
||||||
let src = d.display_source();
|
let src = d.display_source();
|
||||||
let root = db.parse_or_expand(src.file_id).unwrap();
|
let root = db.parse_or_expand(src.file_id).unwrap();
|
||||||
// FIXME: macros...
|
|
||||||
|
// Place all diagnostics emitted in macro files on the original caller.
|
||||||
|
// Note that this does *not* match IDE behavior.
|
||||||
|
let mut src = src.map(|ptr| ptr.to_node(&root));
|
||||||
|
while let Some(exp) = src.file_id.call_node(db) {
|
||||||
|
src = exp;
|
||||||
|
}
|
||||||
|
|
||||||
let file_id = src.file_id.original_file(db);
|
let file_id = src.file_id.original_file(db);
|
||||||
let range = src.value.to_node(&root).text_range();
|
let range = src.value.text_range();
|
||||||
let message = d.message().to_owned();
|
let message = d.message().to_owned();
|
||||||
actual.entry(file_id).or_default().push((range, message));
|
actual.entry(file_id).or_default().push((range, message));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue