mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
proc-macro-srv: Fix <TokenStream as Display>::fmt impl rendering puncts as u8
This commit is contained in:
@@ -228,7 +228,7 @@ fn test_derive_error() {
|
||||
IDENT 1 compile_error
|
||||
PUNCT 1 ! [joint]
|
||||
GROUP () 1 1 1
|
||||
LITER 1 Str #[derive(DeriveError)] struct S {field 58 u32}
|
||||
LITER 1 Str #[derive(DeriveError)] struct S {field : u32}
|
||||
PUNCT 1 ; [alone]
|
||||
"#]],
|
||||
expect![[r#"
|
||||
@@ -242,9 +242,9 @@ fn test_derive_error() {
|
||||
|
||||
IDENT 42:Root[0000, 0]@0..13#ROOT2024 compile_error
|
||||
PUNCT 42:Root[0000, 0]@13..14#ROOT2024 ! [joint]
|
||||
GROUP () 42:Root[0000, 0]@14..15#ROOT2024 42:Root[0000, 0]@63..64#ROOT2024 42:Root[0000, 0]@14..64#ROOT2024
|
||||
LITER 42:Root[0000, 0]@15..63#ROOT2024 Str #[derive(DeriveError)] struct S {field 58 u32}
|
||||
PUNCT 42:Root[0000, 0]@64..65#ROOT2024 ; [alone]
|
||||
GROUP () 42:Root[0000, 0]@14..15#ROOT2024 42:Root[0000, 0]@62..63#ROOT2024 42:Root[0000, 0]@14..63#ROOT2024
|
||||
LITER 42:Root[0000, 0]@15..62#ROOT2024 Str #[derive(DeriveError)] struct S {field : u32}
|
||||
PUNCT 42:Root[0000, 0]@63..64#ROOT2024 ; [alone]
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ fn display_token_tree<S>(
|
||||
}
|
||||
TokenTree::Punct(Punct { ch, joint, span: _ }) => {
|
||||
*emit_whitespace = !*joint;
|
||||
write!(f, "{ch}")?;
|
||||
write!(f, "{}", *ch as char)?;
|
||||
}
|
||||
TokenTree::Ident(Ident { sym, is_raw, span: _ }) => {
|
||||
if *is_raw {
|
||||
@@ -745,14 +745,10 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn roundtrip() {
|
||||
let token_stream = TokenStream::from_str("struct T {\"string\"}", ()).unwrap();
|
||||
assert_eq!(token_stream.to_string(), "struct T {\"string\"}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ident_ts_no_trailing_whitespace_to_string() {
|
||||
let token_stream = TokenStream::from_str("this_is_an_ident", ()).unwrap();
|
||||
assert_eq!(token_stream.to_string(), "this_is_an_ident");
|
||||
fn ts_to_string() {
|
||||
let token_stream =
|
||||
TokenStream::from_str("{} () [] <> ;/., \"gfhdgfuiofghd\" 0f32 r#\"dff\"# 'r#lt", ())
|
||||
.unwrap();
|
||||
assert_eq!(token_stream.to_string(), "{}()[]<> ;/., \"gfhdgfuiofghd\"0f32 r#\"dff\"#'r#lt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user