diff --git a/src/fallback.rs b/src/fallback.rs index 8e85d2a..61b7b91 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -889,7 +889,7 @@ impl Display for Ident { if self.raw { f.write_str("r#")?; } - Display::fmt(&self.sym, f) + f.write_str(&self.sym) } } diff --git a/tests/test.rs b/tests/test.rs index 968c127..39a75b5 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -705,6 +705,17 @@ fn raw_identifier() { assert!(tts.next().is_none()); } +#[test] +fn test_display_ident() { + let ident = Ident::new("proc_macro", Span::call_site()); + assert_eq!(format!("{ident}"), "proc_macro"); + assert_eq!(format!("{ident:-^14}"), "proc_macro"); + + let ident = Ident::new_raw("proc_macro", Span::call_site()); + assert_eq!(format!("{ident}"), "r#proc_macro"); + assert_eq!(format!("{ident:-^14}"), "r#proc_macro"); +} + #[test] fn test_debug_ident() { let ident = Ident::new("proc_macro", Span::call_site());