fix: column!()
and line!()
built-in macros return u32
This commit is contained in:
parent
a0a7860141
commit
34a9129333
@ -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 }
|
||||||
"##]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,7 +922,7 @@ macro_rules! m {
|
|||||||
|
|
||||||
fn bar() -> &'a Baz<u8> {}
|
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() {
|
fn main() {
|
||||||
match 0 {
|
match 0 {
|
||||||
0|1if true =>true , _=>false
|
0|1 if true =>true , _=>false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
"#]],
|
"#]],
|
||||||
|
@ -73,7 +73,7 @@ fn main() {
|
|||||||
macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); }
|
macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = 2let b = 5drop(b-a)println!("{}", a+b)
|
let a = 2 let b = 5 drop(b-a)println!("{}", a+b)
|
||||||
}
|
}
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
|
@ -297,55 +297,55 @@ extern "rust-call" fn call_once(self, ($( $arg, )*): ($( $ArgTy, )*)) -> $Return
|
|||||||
|
|
||||||
#[derive(Clone)] struct CharEscapeDebugContinue;
|
#[derive(Clone)] struct CharEscapeDebugContinue;
|
||||||
impl Fn<(char, )> for 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 )
|
c.escape_debug_ext(false )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FnMut<(char, )> for CharEscapeDebugContinue {
|
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, ))
|
Fn::call(&*self , (c, ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FnOnce<(char, )> for CharEscapeDebugContinue {
|
impl FnOnce<(char, )> for CharEscapeDebugContinue {
|
||||||
type Output = char::EscapeDebug;
|
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, ))
|
Fn::call(&self , (c, ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Clone)] struct CharEscapeUnicode;
|
#[derive(Clone)] struct CharEscapeUnicode;
|
||||||
impl Fn<(char, )> for 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()
|
c.escape_unicode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FnMut<(char, )> for CharEscapeUnicode {
|
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, ))
|
Fn::call(&*self , (c, ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FnOnce<(char, )> for CharEscapeUnicode {
|
impl FnOnce<(char, )> for CharEscapeUnicode {
|
||||||
type Output = char::EscapeUnicode;
|
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, ))
|
Fn::call(&self , (c, ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Clone)] struct CharEscapeDefault;
|
#[derive(Clone)] struct CharEscapeDefault;
|
||||||
impl Fn<(char, )> for 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()
|
c.escape_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FnMut<(char, )> for CharEscapeDefault {
|
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, ))
|
Fn::call(&*self , (c, ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FnOnce<(char, )> for CharEscapeDefault {
|
impl FnOnce<(char, )> for CharEscapeDefault {
|
||||||
type Output = char::EscapeDefault;
|
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, ))
|
Fn::call(&self , (c, ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -833,7 +833,7 @@ pub fn new() {
|
|||||||
/* parse error: expected SEMICOLON */
|
/* parse error: expected SEMICOLON */
|
||||||
/* parse error: expected expression, item or let statement */
|
/* parse error: expected expression, item or let statement */
|
||||||
pub fn new() {
|
pub fn new() {
|
||||||
let _ = 0as u32<<(8+8);
|
let _ = 0 as u32<<(8+8);
|
||||||
}
|
}
|
||||||
// MACRO_ITEMS@0..31
|
// MACRO_ITEMS@0..31
|
||||||
// FN@0..31
|
// FN@0..31
|
||||||
|
@ -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!['{']) => " ",
|
||||||
|
@ -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)
|
||||||
|
@ -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
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user