Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/proc-macro-srv/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand All @@ -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]
"#]],
);
}
Expand Down
16 changes: 6 additions & 10 deletions crates/proc-macro-srv/src/token_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
}
}