fix: column!() and line!() built-in macros return u32

This commit is contained in:
Ryo Yoshida 2023-05-11 18:15:28 +09:00
parent a0a7860141
commit 34a9129333
No known key found for this signature in database
GPG Key ID: E25698A930586171
7 changed files with 26 additions and 25 deletions

View File

@ -13,12 +13,12 @@ macro_rules! column {() => {}}
fn main() { column!(); } fn main() { column!(); }
"#, "#,
expect![[r##" expect![[r#"
#[rustc_builtin_macro] #[rustc_builtin_macro]
macro_rules! column {() => {}} macro_rules! column {() => {}}
fn main() { 0; } fn main() { 0 as u32; }
"##]], "#]],
); );
} }
@ -31,12 +31,12 @@ macro_rules! line {() => {}}
fn main() { line!() } fn main() { line!() }
"#, "#,
expect![[r##" expect![[r#"
#[rustc_builtin_macro] #[rustc_builtin_macro]
macro_rules! line {() => {}} macro_rules! line {() => {}}
fn main() { 0 } fn main() { 0 as u32 }
"##]], "#]],
); );
} }

View File

@ -280,6 +280,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode, map: Option<&TokenMap>) -> Str
let curr_kind = token.kind(); let curr_kind = token.kind();
let space = match (prev_kind, curr_kind) { let space = match (prev_kind, curr_kind) {
_ if prev_kind.is_trivia() || curr_kind.is_trivia() => "", _ if prev_kind.is_trivia() || curr_kind.is_trivia() => "",
_ if prev_kind.is_literal() && !curr_kind.is_punct() => " ",
(T!['{'], T!['}']) => "", (T!['{'], T!['}']) => "",
(T![=], _) | (_, T![=]) => " ", (T![=], _) | (_, T![=]) => " ",
(_, T!['{']) => " ", (_, T!['{']) => " ",

View File

@ -135,9 +135,8 @@ fn line_expand(
_tt: &tt::Subtree, _tt: &tt::Subtree,
) -> ExpandResult<tt::Subtree> { ) -> ExpandResult<tt::Subtree> {
// dummy implementation for type-checking purposes // dummy implementation for type-checking purposes
let line_num = 0;
let expanded = quote! { let expanded = quote! {
#line_num 0 as u32
}; };
ExpandResult::ok(expanded) ExpandResult::ok(expanded)
@ -179,9 +178,8 @@ fn column_expand(
_tt: &tt::Subtree, _tt: &tt::Subtree,
) -> ExpandResult<tt::Subtree> { ) -> ExpandResult<tt::Subtree> {
// dummy implementation for type-checking purposes // dummy implementation for type-checking purposes
let col_num = 0;
let expanded = quote! { let expanded = quote! {
#col_num 0 as u32
}; };
ExpandResult::ok(expanded) ExpandResult::ok(expanded)

View File

@ -661,8 +661,9 @@ fn main() {
"#, "#,
expect![[r#" expect![[r#"
!0..1 '0': i32 !0..1 '0': i32
!0..6 '0asu32': u32
63..87 '{ ...!(); }': () 63..87 '{ ...!(); }': ()
73..74 'x': i32 73..74 'x': u32
"#]], "#]],
); );
} }
@ -699,8 +700,9 @@ fn main() {
"#, "#,
expect![[r#" expect![[r#"
!0..1 '0': i32 !0..1 '0': i32
!0..6 '0asu32': u32
65..91 '{ ...!(); }': () 65..91 '{ ...!(); }': ()
75..76 'x': i32 75..76 'x': u32
"#]], "#]],
); );
} }