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

View file

@ -922,7 +922,7 @@ macro_rules! m {
fn bar() -> &'a Baz<u8> {}
fn bar() -> extern "Rust"fn() -> Ret {}
fn bar() -> extern "Rust" fn() -> Ret {}
"#]],
);
}
@ -1333,7 +1333,7 @@ macro_rules! matches {
}
fn main() {
match 0 {
0|1if true =>true , _=>false
0|1 if true =>true , _=>false
};
}
"#]],

View file

@ -73,7 +73,7 @@ fn main() {
macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); }
fn main() {
let a = 2let b = 5drop(b-a)println!("{}", a+b)
let a = 2 let b = 5 drop(b-a)println!("{}", a+b)
}
"#]],
)

View file

@ -297,55 +297,55 @@ macro_rules! impl_fn_for_zst {
#[derive(Clone)] struct CharEscapeDebugContinue;
impl Fn<(char, )> for CharEscapeDebugContinue {
#[inline] extern "rust-call"fn call(&self , (c, ): (char, )) -> char::EscapeDebug { {
#[inline] extern "rust-call" fn call(&self , (c, ): (char, )) -> char::EscapeDebug { {
c.escape_debug_ext(false )
}
}
}
impl FnMut<(char, )> for CharEscapeDebugContinue {
#[inline] extern "rust-call"fn call_mut(&mut self , (c, ): (char, )) -> char::EscapeDebug {
#[inline] extern "rust-call" fn call_mut(&mut self , (c, ): (char, )) -> char::EscapeDebug {
Fn::call(&*self , (c, ))
}
}
impl FnOnce<(char, )> for CharEscapeDebugContinue {
type Output = char::EscapeDebug;
#[inline] extern "rust-call"fn call_once(self , (c, ): (char, )) -> char::EscapeDebug {
#[inline] extern "rust-call" fn call_once(self , (c, ): (char, )) -> char::EscapeDebug {
Fn::call(&self , (c, ))
}
}
#[derive(Clone)] struct CharEscapeUnicode;
impl Fn<(char, )> for CharEscapeUnicode {
#[inline] extern "rust-call"fn call(&self , (c, ): (char, )) -> char::EscapeUnicode { {
#[inline] extern "rust-call" fn call(&self , (c, ): (char, )) -> char::EscapeUnicode { {
c.escape_unicode()
}
}
}
impl FnMut<(char, )> for CharEscapeUnicode {
#[inline] extern "rust-call"fn call_mut(&mut self , (c, ): (char, )) -> char::EscapeUnicode {
#[inline] extern "rust-call" fn call_mut(&mut self , (c, ): (char, )) -> char::EscapeUnicode {
Fn::call(&*self , (c, ))
}
}
impl FnOnce<(char, )> for CharEscapeUnicode {
type Output = char::EscapeUnicode;
#[inline] extern "rust-call"fn call_once(self , (c, ): (char, )) -> char::EscapeUnicode {
#[inline] extern "rust-call" fn call_once(self , (c, ): (char, )) -> char::EscapeUnicode {
Fn::call(&self , (c, ))
}
}
#[derive(Clone)] struct CharEscapeDefault;
impl Fn<(char, )> for CharEscapeDefault {
#[inline] extern "rust-call"fn call(&self , (c, ): (char, )) -> char::EscapeDefault { {
#[inline] extern "rust-call" fn call(&self , (c, ): (char, )) -> char::EscapeDefault { {
c.escape_default()
}
}
}
impl FnMut<(char, )> for CharEscapeDefault {
#[inline] extern "rust-call"fn call_mut(&mut self , (c, ): (char, )) -> char::EscapeDefault {
#[inline] extern "rust-call" fn call_mut(&mut self , (c, ): (char, )) -> char::EscapeDefault {
Fn::call(&*self , (c, ))
}
}
impl FnOnce<(char, )> for CharEscapeDefault {
type Output = char::EscapeDefault;
#[inline] extern "rust-call"fn call_once(self , (c, ): (char, )) -> char::EscapeDefault {
#[inline] extern "rust-call" fn call_once(self , (c, ): (char, )) -> char::EscapeDefault {
Fn::call(&self , (c, ))
}
}
@ -833,7 +833,7 @@ macro_rules! rgb_color {
/* parse error: expected SEMICOLON */
/* parse error: expected expression, item or let statement */
pub fn new() {
let _ = 0as u32<<(8+8);
let _ = 0 as u32<<(8+8);
}
// MACRO_ITEMS@0..31
// FN@0..31

View file

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

View file

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

View file

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