Skip to content

Commit c434b64

Browse files
committed
Change nonpublic items from pub to pub(crate)
This verifies that they don't end up exported in the public API by mistake.
1 parent eed1e2f commit c434b64

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

src/fallback.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use crate::{Delimiter, Punct, Spacing, TokenTree};
1616
use unicode_xid::UnicodeXID;
1717

1818
#[derive(Clone)]
19-
pub struct TokenStream {
19+
pub(crate) struct TokenStream {
2020
inner: Vec<TokenTree>,
2121
}
2222

2323
#[derive(Debug)]
24-
pub struct LexError;
24+
pub(crate) struct LexError;
2525

2626
impl TokenStream {
2727
pub fn new() -> TokenStream {
@@ -180,7 +180,7 @@ impl Extend<TokenStream> for TokenStream {
180180
}
181181
}
182182

183-
pub type TokenTreeIter = vec::IntoIter<TokenTree>;
183+
pub(crate) type TokenTreeIter = vec::IntoIter<TokenTree>;
184184

185185
impl IntoIterator for TokenStream {
186186
type Item = TokenTree;
@@ -192,7 +192,7 @@ impl IntoIterator for TokenStream {
192192
}
193193

194194
#[derive(Clone, PartialEq, Eq)]
195-
pub struct SourceFile {
195+
pub(crate) struct SourceFile {
196196
path: PathBuf,
197197
}
198198

@@ -218,7 +218,7 @@ impl fmt::Debug for SourceFile {
218218
}
219219

220220
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
221-
pub struct LineColumn {
221+
pub(crate) struct LineColumn {
222222
pub line: usize,
223223
pub column: usize,
224224
}
@@ -343,7 +343,7 @@ impl SourceMap {
343343
}
344344

345345
#[derive(Clone, Copy, PartialEq, Eq)]
346-
pub struct Span {
346+
pub(crate) struct Span {
347347
#[cfg(span_locations)]
348348
lo: u32,
349349
#[cfg(span_locations)]
@@ -465,14 +465,14 @@ impl fmt::Debug for Span {
465465
}
466466
}
467467

468-
pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
468+
pub(crate) fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
469469
if cfg!(procmacro2_semver_exempt) {
470470
debug.field("span", &span);
471471
}
472472
}
473473

474474
#[derive(Clone)]
475-
pub struct Group {
475+
pub(crate) struct Group {
476476
delimiter: Delimiter,
477477
stream: TokenStream,
478478
span: Span,
@@ -541,7 +541,7 @@ impl fmt::Debug for Group {
541541
}
542542

543543
#[derive(Clone)]
544-
pub struct Ident {
544+
pub(crate) struct Ident {
545545
sym: String,
546546
span: Span,
547547
raw: bool,
@@ -671,7 +671,7 @@ impl fmt::Debug for Ident {
671671
}
672672

673673
#[derive(Clone)]
674-
pub struct Literal {
674+
pub(crate) struct Literal {
675675
text: String,
676676
span: Span,
677677
}

src/strnom.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::str::{Bytes, CharIndices, Chars};
55
use unicode_xid::UnicodeXID;
66

77
#[derive(Copy, Clone, Eq, PartialEq)]
8-
pub struct Cursor<'a> {
8+
pub(crate) struct Cursor<'a> {
99
pub rest: &'a str,
1010
#[cfg(span_locations)]
1111
pub off: u32,
@@ -59,9 +59,9 @@ impl<'a> Cursor<'a> {
5959
}
6060
}
6161

62-
pub type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>;
62+
pub(crate) type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>;
6363

64-
pub fn whitespace(input: Cursor) -> PResult<()> {
64+
pub(crate) fn whitespace(input: Cursor) -> PResult<()> {
6565
if input.is_empty() {
6666
return Err(LexError);
6767
}
@@ -111,7 +111,7 @@ pub fn whitespace(input: Cursor) -> PResult<()> {
111111
Ok((input.advance(input.len()), ()))
112112
}
113113

114-
pub fn block_comment(input: Cursor) -> PResult<&str> {
114+
pub(crate) fn block_comment(input: Cursor) -> PResult<&str> {
115115
if !input.starts_with("/*") {
116116
return Err(LexError);
117117
}
@@ -136,7 +136,7 @@ pub fn block_comment(input: Cursor) -> PResult<&str> {
136136
Err(LexError)
137137
}
138138

139-
pub fn skip_whitespace(input: Cursor) -> Cursor {
139+
pub(crate) fn skip_whitespace(input: Cursor) -> Cursor {
140140
match whitespace(input) {
141141
Ok((rest, _)) => rest,
142142
Err(LexError) => input,
@@ -148,7 +148,7 @@ fn is_whitespace(ch: char) -> bool {
148148
ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}'
149149
}
150150

151-
pub fn word_break(input: Cursor) -> PResult<()> {
151+
pub(crate) fn word_break(input: Cursor) -> PResult<()> {
152152
match input.chars().next() {
153153
Some(ch) if UnicodeXID::is_xid_continue(ch) => Err(LexError),
154154
Some(_) | None => Ok((input, ())),
@@ -346,7 +346,7 @@ macro_rules! punct {
346346
}
347347

348348
/// Do not use directly. Use `punct!`.
349-
pub fn punct<'a>(input: Cursor<'a>, token: &'static str) -> PResult<'a, &'a str> {
349+
pub(crate) fn punct<'a>(input: Cursor<'a>, token: &'static str) -> PResult<'a, &'a str> {
350350
let input = skip_whitespace(input);
351351
if input.starts_with(token) {
352352
Ok((input.advance(token.len()), token))

src/wrapper.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::str::FromStr;
99
use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
1010

1111
#[derive(Clone)]
12-
pub enum TokenStream {
12+
pub(crate) enum TokenStream {
1313
Compiler(DeferredTokenStream),
1414
Fallback(fallback::TokenStream),
1515
}
@@ -19,12 +19,12 @@ pub enum TokenStream {
1919
// we hold on to the appended tokens and do proc_macro::TokenStream::extend as
2020
// late as possible to batch together consecutive uses of the Extend impl.
2121
#[derive(Clone)]
22-
pub struct DeferredTokenStream {
22+
pub(crate) struct DeferredTokenStream {
2323
stream: proc_macro::TokenStream,
2424
extra: Vec<proc_macro::TokenTree>,
2525
}
2626

27-
pub enum LexError {
27+
pub(crate) enum LexError {
2828
Compiler(proc_macro::LexError),
2929
Fallback(fallback::LexError),
3030
}
@@ -316,7 +316,7 @@ impl fmt::Debug for LexError {
316316
}
317317

318318
#[derive(Clone)]
319-
pub enum TokenTreeIter {
319+
pub(crate) enum TokenTreeIter {
320320
Compiler(proc_macro::token_stream::IntoIter),
321321
Fallback(fallback::TokenTreeIter),
322322
}
@@ -375,7 +375,7 @@ impl fmt::Debug for TokenTreeIter {
375375

376376
#[derive(Clone, PartialEq, Eq)]
377377
#[cfg(super_unstable)]
378-
pub enum SourceFile {
378+
pub(crate) enum SourceFile {
379379
Compiler(proc_macro::SourceFile),
380380
Fallback(fallback::SourceFile),
381381
}
@@ -413,13 +413,13 @@ impl fmt::Debug for SourceFile {
413413
}
414414

415415
#[cfg(any(super_unstable, feature = "span-locations"))]
416-
pub struct LineColumn {
416+
pub(crate) struct LineColumn {
417417
pub line: usize,
418418
pub column: usize,
419419
}
420420

421421
#[derive(Copy, Clone)]
422-
pub enum Span {
422+
pub(crate) enum Span {
423423
Compiler(proc_macro::Span),
424424
Fallback(fallback::Span),
425425
}
@@ -557,7 +557,7 @@ impl fmt::Debug for Span {
557557
}
558558
}
559559

560-
pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
560+
pub(crate) fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
561561
match span {
562562
Span::Compiler(s) => {
563563
debug.field("span", &s);
@@ -567,7 +567,7 @@ pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span)
567567
}
568568

569569
#[derive(Clone)]
570-
pub enum Group {
570+
pub(crate) enum Group {
571571
Compiler(proc_macro::Group),
572572
Fallback(fallback::Group),
573573
}
@@ -677,7 +677,7 @@ impl fmt::Debug for Group {
677677
}
678678

679679
#[derive(Clone)]
680-
pub enum Ident {
680+
pub(crate) enum Ident {
681681
Compiler(proc_macro::Ident),
682682
Fallback(fallback::Ident),
683683
}
@@ -772,7 +772,7 @@ impl fmt::Debug for Ident {
772772
}
773773

774774
#[derive(Clone)]
775-
pub enum Literal {
775+
pub(crate) enum Literal {
776776
Compiler(proc_macro::Literal),
777777
Fallback(fallback::Literal),
778778
}

0 commit comments

Comments
 (0)