Skip to content

Commit 6f4dc99

Browse files
authored
Merge pull request #318 from dtolnay/literalrepr
Rename text -> repr in implementation of Literal
2 parents 0360b2a + 2f2dfcf commit 6f4dc99

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/fallback.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl TokenStream {
7474
#[cfg(not(wrap_proc_macro))]
7575
inner: literal,
7676
..
77-
}) if literal.text.starts_with('-') => {
77+
}) if literal.repr.starts_with('-') => {
7878
push_negative_literal(self, literal);
7979
}
8080
#[cfg(no_bind_by_move_pattern_guard)]
@@ -85,7 +85,7 @@ impl TokenStream {
8585
inner: literal,
8686
..
8787
}) => {
88-
if literal.text.starts_with('-') {
88+
if literal.repr.starts_with('-') {
8989
push_negative_literal(self, literal);
9090
} else {
9191
self.inner
@@ -97,7 +97,7 @@ impl TokenStream {
9797

9898
#[cold]
9999
fn push_negative_literal(stream: &mut TokenStream, mut literal: Literal) {
100-
literal.text.remove(0);
100+
literal.repr.remove(0);
101101
let mut punct = crate::Punct::new('-', Spacing::Alone);
102102
punct.set_span(crate::Span::_new_stable(literal.span));
103103
stream.inner.push(TokenTree::Punct(punct));
@@ -756,7 +756,7 @@ impl Debug for Ident {
756756

757757
#[derive(Clone)]
758758
pub(crate) struct Literal {
759-
text: String,
759+
repr: String,
760760
span: Span,
761761
}
762762

@@ -777,9 +777,9 @@ macro_rules! unsuffixed_numbers {
777777
}
778778

779779
impl Literal {
780-
pub(crate) fn _new(text: String) -> Self {
780+
pub(crate) fn _new(repr: String) -> Self {
781781
Literal {
782-
text,
782+
repr,
783783
span: Span::call_site(),
784784
}
785785
}
@@ -838,31 +838,31 @@ impl Literal {
838838
}
839839

840840
pub fn string(t: &str) -> Literal {
841-
let mut text = String::with_capacity(t.len() + 2);
842-
text.push('"');
841+
let mut repr = String::with_capacity(t.len() + 2);
842+
repr.push('"');
843843
for c in t.chars() {
844844
if c == '\'' {
845845
// escape_debug turns this into "\'" which is unnecessary.
846-
text.push(c);
846+
repr.push(c);
847847
} else {
848-
text.extend(c.escape_debug());
848+
repr.extend(c.escape_debug());
849849
}
850850
}
851-
text.push('"');
852-
Literal::_new(text)
851+
repr.push('"');
852+
Literal::_new(repr)
853853
}
854854

855855
pub fn character(t: char) -> Literal {
856-
let mut text = String::new();
857-
text.push('\'');
856+
let mut repr = String::new();
857+
repr.push('\'');
858858
if t == '"' {
859859
// escape_debug turns this into '\"' which is unnecessary.
860-
text.push(t);
860+
repr.push(t);
861861
} else {
862-
text.extend(t.escape_debug());
862+
repr.extend(t.escape_debug());
863863
}
864-
text.push('\'');
865-
Literal::_new(text)
864+
repr.push('\'');
865+
Literal::_new(repr)
866866
}
867867

868868
pub fn byte_string(bytes: &[u8]) -> Literal {
@@ -910,9 +910,9 @@ impl FromStr for Literal {
910910
}
911911
let cursor = get_cursor(repr);
912912
if let Ok((_rest, mut literal)) = parse::literal(cursor) {
913-
if literal.text.len() == repr.len() {
913+
if literal.repr.len() == repr.len() {
914914
if negative {
915-
literal.text.insert(0, '-');
915+
literal.repr.insert(0, '-');
916916
}
917917
return Ok(literal);
918918
}
@@ -923,14 +923,14 @@ impl FromStr for Literal {
923923

924924
impl Display for Literal {
925925
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
926-
Display::fmt(&self.text, f)
926+
Display::fmt(&self.repr, f)
927927
}
928928
}
929929

930930
impl Debug for Literal {
931931
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
932932
let mut debug = fmt.debug_struct("Literal");
933-
debug.field("lit", &format_args!("{}", self.text));
933+
debug.field("lit", &format_args!("{}", self.repr));
934934
debug_span_field_if_nontrivial(&mut debug, self.span);
935935
debug.finish()
936936
}

0 commit comments

Comments
 (0)