Fix builtin line! expansion

This commit is contained in:
Lukas Wirth 2023-11-15 12:41:14 +01:00
parent 57ef70cc08
commit e8c4007cfc
5 changed files with 46 additions and 26 deletions

View file

@ -78,7 +78,7 @@ pub fn find_builtin_macro(
register_builtin! {
LAZY:
(column, Column) => column_expand,
(column, Column) => line_expand,
(file, File) => file_expand,
(line, Line) => line_expand,
(module_path, ModulePath) => module_path_expand,
@ -127,11 +127,13 @@ fn line_expand(
_tt: &tt::Subtree,
) -> ExpandResult<tt::Subtree> {
// dummy implementation for type-checking purposes
let expanded = quote! {
0 as u32
};
ExpandResult::ok(expanded)
ExpandResult::ok(tt::Subtree {
delimiter: tt::Delimiter::unspecified(),
token_trees: vec![tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
text: "0u32".into(),
span: tt::Span::UNSPECIFIED,
}))],
})
}
fn log_syntax_expand(
@ -164,19 +166,6 @@ fn stringify_expand(
ExpandResult::ok(expanded)
}
fn column_expand(
_db: &dyn ExpandDatabase,
_id: MacroCallId,
_tt: &tt::Subtree,
) -> ExpandResult<tt::Subtree> {
// dummy implementation for type-checking purposes
let expanded = quote! {
0 as u32
};
ExpandResult::ok(expanded)
}
fn assert_expand(
_db: &dyn ExpandDatabase,
_id: MacroCallId,