Skip to content

Commit 3744dc8

Browse files
committed
Remove space after negative sign in Literal to_string
1 parent d5fd37f commit 3744dc8

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

+3
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,9 @@ impl server::Literal for Rustc<'_> {
582582

583583
Ok(Literal { lit, span: self.call_site })
584584
}
585+
fn to_string(&mut self, literal: &Self::Literal) -> String {
586+
literal.lit.to_string()
587+
}
585588
fn debug_kind(&mut self, literal: &Self::Literal) -> String {
586589
format!("{:?}", literal.lit.kind)
587590
}

library/proc_macro/src/bridge/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ macro_rules! with_api {
109109
fn drop($self: $S::Literal);
110110
fn clone($self: &$S::Literal) -> $S::Literal;
111111
fn from_str(s: &str) -> Result<$S::Literal, ()>;
112+
fn to_string($self: &$S::Literal) -> String;
112113
fn debug_kind($self: &$S::Literal) -> String;
113114
fn symbol($self: &$S::Literal) -> String;
114115
fn suffix($self: &$S::Literal) -> Option<String>;

library/proc_macro/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ impl FromStr for Literal {
11951195
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
11961196
impl ToString for Literal {
11971197
fn to_string(&self) -> String {
1198-
TokenStream::from(TokenTree::from(self.clone())).to_string()
1198+
self.0.to_string()
11991199
}
12001200
}
12011201

src/test/ui/proc-macro/auxiliary/api/parse.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ pub fn test() {
66
}
77

88
fn test_display_literal() {
9-
assert_eq!(Literal::isize_unsuffixed(-10).to_string(), "- 10");
10-
assert_eq!(Literal::isize_suffixed(-10).to_string(), "- 10isize");
9+
assert_eq!(Literal::isize_unsuffixed(-10).to_string(), "-10");
10+
assert_eq!(Literal::isize_suffixed(-10).to_string(), "-10isize");
1111
}
1212

1313
fn test_parse_literal() {
@@ -18,7 +18,7 @@ fn test_parse_literal() {
1818
assert_eq!("b\"\"".parse::<Literal>().unwrap().to_string(), "b\"\"");
1919
assert_eq!("r##\"\"##".parse::<Literal>().unwrap().to_string(), "r##\"\"##");
2020
assert_eq!("10ulong".parse::<Literal>().unwrap().to_string(), "10ulong");
21-
assert_eq!("-10ulong".parse::<Literal>().unwrap().to_string(), "- 10ulong");
21+
assert_eq!("-10ulong".parse::<Literal>().unwrap().to_string(), "-10ulong");
2222

2323
assert!("true".parse::<Literal>().is_err());
2424
assert!(".8".parse::<Literal>().is_err());

0 commit comments

Comments
 (0)