Skip to content

Commit ed6fc44

Browse files
authored
Merge pull request #263 from dtolnay/op
Replace ancient `op` naming
2 parents 4e42b88 + 31084b4 commit ed6fc44

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl Debug for Group {
696696
/// `Punct` with different forms of `Spacing` returned.
697697
#[derive(Clone)]
698698
pub struct Punct {
699-
op: char,
699+
ch: char,
700700
spacing: Spacing,
701701
span: Span,
702702
}
@@ -722,17 +722,17 @@ impl Punct {
722722
///
723723
/// The returned `Punct` will have the default span of `Span::call_site()`
724724
/// which can be further configured with the `set_span` method below.
725-
pub fn new(op: char, spacing: Spacing) -> Punct {
725+
pub fn new(ch: char, spacing: Spacing) -> Punct {
726726
Punct {
727-
op,
727+
ch,
728728
spacing,
729729
span: Span::call_site(),
730730
}
731731
}
732732

733733
/// Returns the value of this punctuation character as `char`.
734734
pub fn as_char(&self) -> char {
735-
self.op
735+
self.ch
736736
}
737737

738738
/// Returns the spacing of this punctuation character, indicating whether
@@ -759,14 +759,14 @@ impl Punct {
759759
/// convertible back into the same character.
760760
impl Display for Punct {
761761
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
762-
Display::fmt(&self.op, f)
762+
Display::fmt(&self.ch, f)
763763
}
764764
}
765765

766766
impl Debug for Punct {
767767
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
768768
let mut debug = fmt.debug_struct("Punct");
769-
debug.field("op", &self.op);
769+
debug.field("char", &self.ch);
770770
debug.field("spacing", &self.spacing);
771771
imp::debug_span_field_if_nontrivial(&mut debug, self.span.inner);
772772
debug.finish()

src/parse.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fn leaf_token(input: Cursor) -> PResult<TokenTree> {
228228
if let Ok((input, l)) = literal(input) {
229229
// must be parsed before ident
230230
Ok((input, TokenTree::Literal(crate::Literal::_new_stable(l))))
231-
} else if let Ok((input, p)) = op(input) {
231+
} else if let Ok((input, p)) = punct(input) {
232232
Ok((input, TokenTree::Punct(p)))
233233
} else if let Ok((input, i)) = ident(input) {
234234
Ok((input, TokenTree::Ident(i)))
@@ -729,8 +729,8 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
729729
}
730730
}
731731

732-
fn op(input: Cursor) -> PResult<Punct> {
733-
match op_char(input) {
732+
fn punct(input: Cursor) -> PResult<Punct> {
733+
match punct_char(input) {
734734
Ok((rest, '\'')) => {
735735
if ident_any(rest)?.0.starts_with("'") {
736736
Err(LexError)
@@ -739,7 +739,7 @@ fn op(input: Cursor) -> PResult<Punct> {
739739
}
740740
}
741741
Ok((rest, ch)) => {
742-
let kind = match op_char(rest) {
742+
let kind = match punct_char(rest) {
743743
Ok(_) => Spacing::Joint,
744744
Err(LexError) => Spacing::Alone,
745745
};
@@ -749,9 +749,9 @@ fn op(input: Cursor) -> PResult<Punct> {
749749
}
750750
}
751751

752-
fn op_char(input: Cursor) -> PResult<char> {
752+
fn punct_char(input: Cursor) -> PResult<char> {
753753
if input.starts_with("//") || input.starts_with("/*") {
754-
// Do not accept `/` of a comment as an op.
754+
// Do not accept `/` of a comment as a punct.
755755
return Err(LexError);
756756
}
757757

src/wrapper.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ fn into_compiler_token(token: TokenTree) -> proc_macro::TokenTree {
150150
Spacing::Joint => proc_macro::Spacing::Joint,
151151
Spacing::Alone => proc_macro::Spacing::Alone,
152152
};
153-
let mut op = proc_macro::Punct::new(tt.as_char(), spacing);
154-
op.set_span(tt.span().inner.unwrap_nightly());
155-
op.into()
153+
let mut punct = proc_macro::Punct::new(tt.as_char(), spacing);
154+
punct.set_span(tt.span().inner.unwrap_nightly());
155+
punct.into()
156156
}
157157
TokenTree::Ident(tt) => tt.inner.unwrap_nightly().into(),
158158
TokenTree::Literal(tt) => tt.inner.unwrap_nightly().into(),

tests/test.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ fn no_panic() {
293293
}
294294

295295
#[test]
296-
fn op_before_comment() {
296+
fn punct_before_comment() {
297297
let mut tts = TokenStream::from_str("~// comment").unwrap().into_iter();
298298
match tts.next().unwrap() {
299299
TokenTree::Punct(tt) => {
@@ -341,7 +341,7 @@ TokenStream [
341341
sym: a,
342342
},
343343
Punct {
344-
op: '+',
344+
char: '+',
345345
spacing: Alone,
346346
},
347347
Literal {
@@ -362,7 +362,7 @@ TokenStream [
362362
sym: a
363363
},
364364
Punct {
365-
op: '+',
365+
char: '+',
366366
spacing: Alone
367367
},
368368
Literal {
@@ -384,7 +384,7 @@ TokenStream [
384384
span: bytes(2..3),
385385
},
386386
Punct {
387-
op: '+',
387+
char: '+',
388388
spacing: Alone,
389389
span: bytes(4..5),
390390
},
@@ -409,7 +409,7 @@ TokenStream [
409409
span: bytes(2..3)
410410
},
411411
Punct {
412-
op: '+',
412+
char: '+',
413413
spacing: Alone,
414414
span: bytes(4..5)
415415
},

0 commit comments

Comments
 (0)