Skip to content

Commit

Permalink
Fill in pub(crate) visibilities on all nonpublic items
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 21, 2024
1 parent a244808 commit 8e2056e
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 113 deletions.
94 changes: 47 additions & 47 deletions src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ impl LexError {
}

impl TokenStream {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
TokenStream {
inner: RcVecBuilder::new().build(),
}
}

pub fn is_empty(&self) -> bool {
pub(crate) fn is_empty(&self) -> bool {
self.inner.len() == 0
}

Expand Down Expand Up @@ -125,23 +125,23 @@ pub(crate) struct TokenStreamBuilder {
}

impl TokenStreamBuilder {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
TokenStreamBuilder {
inner: RcVecBuilder::new(),
}
}

pub fn with_capacity(cap: usize) -> Self {
pub(crate) fn with_capacity(cap: usize) -> Self {
TokenStreamBuilder {
inner: RcVecBuilder::with_capacity(cap),
}
}

pub fn push_token_from_parser(&mut self, tt: TokenTree) {
pub(crate) fn push_token_from_parser(&mut self, tt: TokenTree) {
self.inner.push(tt);
}

pub fn build(self) -> TokenStream {
pub(crate) fn build(self) -> TokenStream {
TokenStream {
inner: self.inner.build(),
}
Expand Down Expand Up @@ -303,11 +303,11 @@ pub(crate) struct SourceFile {
#[cfg(procmacro2_semver_exempt)]
impl SourceFile {
/// Get the path to this source file as a string.
pub fn path(&self) -> PathBuf {
pub(crate) fn path(&self) -> PathBuf {
self.path.clone()
}

pub fn is_real(&self) -> bool {
pub(crate) fn is_real(&self) -> bool {
false
}
}
Expand Down Expand Up @@ -509,37 +509,37 @@ pub(crate) struct Span {

impl Span {
#[cfg(not(span_locations))]
pub fn call_site() -> Self {
pub(crate) fn call_site() -> Self {
Span {}
}

#[cfg(span_locations)]
pub fn call_site() -> Self {
pub(crate) fn call_site() -> Self {
Span { lo: 0, hi: 0 }
}

pub fn mixed_site() -> Self {
pub(crate) fn mixed_site() -> Self {
Span::call_site()
}

#[cfg(procmacro2_semver_exempt)]
pub fn def_site() -> Self {
pub(crate) fn def_site() -> Self {
Span::call_site()
}

pub fn resolved_at(&self, _other: Span) -> Span {
pub(crate) fn resolved_at(&self, _other: Span) -> Span {
// Stable spans consist only of line/column information, so
// `resolved_at` and `located_at` only select which span the
// caller wants line/column information from.
*self
}

pub fn located_at(&self, other: Span) -> Span {
pub(crate) fn located_at(&self, other: Span) -> Span {
other
}

#[cfg(procmacro2_semver_exempt)]
pub fn source_file(&self) -> SourceFile {
pub(crate) fn source_file(&self) -> SourceFile {
#[cfg(fuzzing)]
return SourceFile {
path: PathBuf::from("<unspecified>"),
Expand All @@ -554,7 +554,7 @@ impl Span {
}

#[cfg(span_locations)]
pub fn byte_range(&self) -> Range<usize> {
pub(crate) fn byte_range(&self) -> Range<usize> {
#[cfg(fuzzing)]
return 0..0;

Expand All @@ -569,7 +569,7 @@ impl Span {
}

#[cfg(span_locations)]
pub fn start(&self) -> LineColumn {
pub(crate) fn start(&self) -> LineColumn {
#[cfg(fuzzing)]
return LineColumn { line: 0, column: 0 };

Expand All @@ -582,7 +582,7 @@ impl Span {
}

#[cfg(span_locations)]
pub fn end(&self) -> LineColumn {
pub(crate) fn end(&self) -> LineColumn {
#[cfg(fuzzing)]
return LineColumn { line: 0, column: 0 };

Expand All @@ -595,12 +595,12 @@ impl Span {
}

#[cfg(not(span_locations))]
pub fn join(&self, _other: Span) -> Option<Span> {
pub(crate) fn join(&self, _other: Span) -> Option<Span> {
Some(Span {})
}

#[cfg(span_locations)]
pub fn join(&self, other: Span) -> Option<Span> {
pub(crate) fn join(&self, other: Span) -> Option<Span> {
#[cfg(fuzzing)]
return {
let _ = other;
Expand All @@ -622,12 +622,12 @@ impl Span {
}

#[cfg(not(span_locations))]
pub fn source_text(&self) -> Option<String> {
pub(crate) fn source_text(&self) -> Option<String> {
None
}

#[cfg(span_locations)]
pub fn source_text(&self) -> Option<String> {
pub(crate) fn source_text(&self) -> Option<String> {
#[cfg(fuzzing)]
return None;

Expand Down Expand Up @@ -704,35 +704,35 @@ pub(crate) struct Group {
}

impl Group {
pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self {
pub(crate) fn new(delimiter: Delimiter, stream: TokenStream) -> Self {
Group {
delimiter,
stream,
span: Span::call_site(),
}
}

pub fn delimiter(&self) -> Delimiter {
pub(crate) fn delimiter(&self) -> Delimiter {
self.delimiter
}

pub fn stream(&self) -> TokenStream {
pub(crate) fn stream(&self) -> TokenStream {
self.stream.clone()
}

pub fn span(&self) -> Span {
pub(crate) fn span(&self) -> Span {
self.span
}

pub fn span_open(&self) -> Span {
pub(crate) fn span_open(&self) -> Span {
self.span.first_byte()
}

pub fn span_close(&self) -> Span {
pub(crate) fn span_close(&self) -> Span {
self.span.last_byte()
}

pub fn set_span(&mut self, span: Span) {
pub(crate) fn set_span(&mut self, span: Span) {
self.span = span;
}
}
Expand Down Expand Up @@ -783,12 +783,12 @@ pub(crate) struct Ident {

impl Ident {
#[track_caller]
pub fn new_checked(string: &str, span: Span) -> Self {
pub(crate) fn new_checked(string: &str, span: Span) -> Self {
validate_ident(string);
Ident::new_unchecked(string, span)
}

pub fn new_unchecked(string: &str, span: Span) -> Self {
pub(crate) fn new_unchecked(string: &str, span: Span) -> Self {
Ident {
sym: Box::from(string),
span,
Expand All @@ -797,24 +797,24 @@ impl Ident {
}

#[track_caller]
pub fn new_raw_checked(string: &str, span: Span) -> Self {
pub(crate) fn new_raw_checked(string: &str, span: Span) -> Self {
validate_ident_raw(string);
Ident::new_raw_unchecked(string, span)
}

pub fn new_raw_unchecked(string: &str, span: Span) -> Self {
pub(crate) fn new_raw_unchecked(string: &str, span: Span) -> Self {
Ident {
sym: Box::from(string),
span,
raw: true,
}
}

pub fn span(&self) -> Span {
pub(crate) fn span(&self) -> Span {
self.span
}

pub fn set_span(&mut self, span: Span) {
pub(crate) fn set_span(&mut self, span: Span) {
self.span = span;
}
}
Expand Down Expand Up @@ -928,15 +928,15 @@ pub(crate) struct Literal {

macro_rules! suffixed_numbers {
($($name:ident => $kind:ident,)*) => ($(
pub fn $name(n: $kind) -> Literal {
pub(crate) fn $name(n: $kind) -> Literal {
Literal::_new(format!(concat!("{}", stringify!($kind)), n))
}
)*)
}

macro_rules! unsuffixed_numbers {
($($name:ident => $kind:ident,)*) => ($(
pub fn $name(n: $kind) -> Literal {
pub(crate) fn $name(n: $kind) -> Literal {
Literal::_new(n.to_string())
}
)*)
Expand Down Expand Up @@ -987,31 +987,31 @@ impl Literal {
isize_unsuffixed => isize,
}

pub fn f32_unsuffixed(f: f32) -> Literal {
pub(crate) fn f32_unsuffixed(f: f32) -> Literal {
let mut s = f.to_string();
if !s.contains('.') {
s.push_str(".0");
}
Literal::_new(s)
}

pub fn f64_unsuffixed(f: f64) -> Literal {
pub(crate) fn f64_unsuffixed(f: f64) -> Literal {
let mut s = f.to_string();
if !s.contains('.') {
s.push_str(".0");
}
Literal::_new(s)
}

pub fn string(string: &str) -> Literal {
pub(crate) fn string(string: &str) -> Literal {
let mut repr = String::with_capacity(string.len() + 2);
repr.push('"');
escape_utf8(string, &mut repr);
repr.push('"');
Literal::_new(repr)
}

pub fn character(ch: char) -> Literal {
pub(crate) fn character(ch: char) -> Literal {
let mut repr = String::new();
repr.push('\'');
if ch == '"' {
Expand All @@ -1024,7 +1024,7 @@ impl Literal {
Literal::_new(repr)
}

pub fn byte_character(byte: u8) -> Literal {
pub(crate) fn byte_character(byte: u8) -> Literal {
let mut repr = "b'".to_string();
#[allow(clippy::match_overlapping_arm)]
match byte {
Expand All @@ -1043,7 +1043,7 @@ impl Literal {
Literal::_new(repr)
}

pub fn byte_string(bytes: &[u8]) -> Literal {
pub(crate) fn byte_string(bytes: &[u8]) -> Literal {
let mut repr = "b\"".to_string();
let mut bytes = bytes.iter();
while let Some(&b) = bytes.next() {
Expand All @@ -1069,7 +1069,7 @@ impl Literal {
Literal::_new(repr)
}

pub fn c_string(string: &CStr) -> Literal {
pub(crate) fn c_string(string: &CStr) -> Literal {
let mut repr = "c\"".to_string();
let mut bytes = string.to_bytes();
while !bytes.is_empty() {
Expand Down Expand Up @@ -1097,15 +1097,15 @@ impl Literal {
Literal::_new(repr)
}

pub fn span(&self) -> Span {
pub(crate) fn span(&self) -> Span {
self.span
}

pub fn set_span(&mut self, span: Span) {
pub(crate) fn set_span(&mut self, span: Span) {
self.span = span;
}

pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> {
pub(crate) fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> {
#[cfg(not(span_locations))]
{
let _ = range;
Expand Down
14 changes: 7 additions & 7 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use core::str::{Bytes, CharIndices, Chars};

#[derive(Copy, Clone, Eq, PartialEq)]
pub(crate) struct Cursor<'a> {
pub rest: &'a str,
pub(crate) rest: &'a str,
#[cfg(span_locations)]
pub off: u32,
pub(crate) off: u32,
}

impl<'a> Cursor<'a> {
pub fn advance(&self, bytes: usize) -> Cursor<'a> {
pub(crate) fn advance(&self, bytes: usize) -> Cursor<'a> {
let (_front, rest) = self.rest.split_at(bytes);
Cursor {
rest,
Expand All @@ -23,22 +23,22 @@ impl<'a> Cursor<'a> {
}
}

pub fn starts_with(&self, s: &str) -> bool {
pub(crate) fn starts_with(&self, s: &str) -> bool {
self.rest.starts_with(s)
}

pub fn starts_with_char(&self, ch: char) -> bool {
pub(crate) fn starts_with_char(&self, ch: char) -> bool {
self.rest.starts_with(ch)
}

pub fn starts_with_fn<Pattern>(&self, f: Pattern) -> bool
pub(crate) fn starts_with_fn<Pattern>(&self, f: Pattern) -> bool
where
Pattern: FnMut(char) -> bool,
{
self.rest.starts_with(f)
}

pub fn is_empty(&self) -> bool {
pub(crate) fn is_empty(&self) -> bool {
self.rest.is_empty()
}

Expand Down
Loading

0 comments on commit 8e2056e

Please sign in to comment.