diff --git a/src/fallback.rs b/src/fallback.rs index 3a0e760..d562a6a 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -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 } @@ -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(), } @@ -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 } } @@ -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(""), @@ -554,7 +554,7 @@ impl Span { } #[cfg(span_locations)] - pub fn byte_range(&self) -> Range { + pub(crate) fn byte_range(&self) -> Range { #[cfg(fuzzing)] return 0..0; @@ -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 }; @@ -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 }; @@ -595,12 +595,12 @@ impl Span { } #[cfg(not(span_locations))] - pub fn join(&self, _other: Span) -> Option { + pub(crate) fn join(&self, _other: Span) -> Option { Some(Span {}) } #[cfg(span_locations)] - pub fn join(&self, other: Span) -> Option { + pub(crate) fn join(&self, other: Span) -> Option { #[cfg(fuzzing)] return { let _ = other; @@ -622,12 +622,12 @@ impl Span { } #[cfg(not(span_locations))] - pub fn source_text(&self) -> Option { + pub(crate) fn source_text(&self) -> Option { None } #[cfg(span_locations)] - pub fn source_text(&self) -> Option { + pub(crate) fn source_text(&self) -> Option { #[cfg(fuzzing)] return None; @@ -704,7 +704,7 @@ 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, @@ -712,27 +712,27 @@ impl Group { } } - 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; } } @@ -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, @@ -797,12 +797,12 @@ 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, @@ -810,11 +810,11 @@ impl Ident { } } - 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; } } @@ -928,7 +928,7 @@ 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)) } )*) @@ -936,7 +936,7 @@ macro_rules! suffixed_numbers { 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()) } )*) @@ -987,7 +987,7 @@ 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"); @@ -995,7 +995,7 @@ impl Literal { 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"); @@ -1003,7 +1003,7 @@ impl Literal { 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); @@ -1011,7 +1011,7 @@ impl Literal { 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 == '"' { @@ -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 { @@ -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() { @@ -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() { @@ -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>(&self, range: R) -> Option { + pub(crate) fn subspan>(&self, range: R) -> Option { #[cfg(not(span_locations))] { let _ = range; diff --git a/src/parse.rs b/src/parse.rs index 07239bc..6b6fa76 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -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, @@ -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(&self, f: Pattern) -> bool + pub(crate) fn starts_with_fn(&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() } diff --git a/src/rcvec.rs b/src/rcvec.rs index 37955af..cde9f25 100644 --- a/src/rcvec.rs +++ b/src/rcvec.rs @@ -22,19 +22,19 @@ pub(crate) struct RcVecIntoIter { } impl RcVec { - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { self.inner.is_empty() } - pub fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { self.inner.len() } - pub fn iter(&self) -> slice::Iter { + pub(crate) fn iter(&self) -> slice::Iter { self.inner.iter() } - pub fn make_mut(&mut self) -> RcVecMut + pub(crate) fn make_mut(&mut self) -> RcVecMut where T: Clone, { @@ -43,12 +43,12 @@ impl RcVec { } } - pub fn get_mut(&mut self) -> Option> { + pub(crate) fn get_mut(&mut self) -> Option> { let inner = Rc::get_mut(&mut self.inner)?; Some(RcVecMut { inner }) } - pub fn make_owned(mut self) -> RcVecBuilder + pub(crate) fn make_owned(mut self) -> RcVecBuilder where T: Clone, { @@ -62,31 +62,31 @@ impl RcVec { } impl RcVecBuilder { - pub fn new() -> Self { + pub(crate) fn new() -> Self { RcVecBuilder { inner: Vec::new() } } - pub fn with_capacity(cap: usize) -> Self { + pub(crate) fn with_capacity(cap: usize) -> Self { RcVecBuilder { inner: Vec::with_capacity(cap), } } - pub fn push(&mut self, element: T) { + pub(crate) fn push(&mut self, element: T) { self.inner.push(element); } - pub fn extend(&mut self, iter: impl IntoIterator) { + pub(crate) fn extend(&mut self, iter: impl IntoIterator) { self.inner.extend(iter); } - pub fn as_mut(&mut self) -> RcVecMut { + pub(crate) fn as_mut(&mut self) -> RcVecMut { RcVecMut { inner: &mut self.inner, } } - pub fn build(self) -> RcVec { + pub(crate) fn build(self) -> RcVec { RcVec { inner: Rc::new(self.inner), } @@ -94,19 +94,19 @@ impl RcVecBuilder { } impl<'a, T> RcVecMut<'a, T> { - pub fn push(&mut self, element: T) { + pub(crate) fn push(&mut self, element: T) { self.inner.push(element); } - pub fn extend(&mut self, iter: impl IntoIterator) { + pub(crate) fn extend(&mut self, iter: impl IntoIterator) { self.inner.extend(iter); } - pub fn pop(&mut self) -> Option { + pub(crate) fn pop(&mut self) -> Option { self.inner.pop() } - pub fn as_mut(&mut self) -> RcVecMut { + pub(crate) fn as_mut(&mut self) -> RcVecMut { RcVecMut { inner: self.inner } } } diff --git a/src/wrapper.rs b/src/wrapper.rs index b30934f..3ad38c4 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -78,7 +78,7 @@ impl DeferredTokenStream { } impl TokenStream { - pub fn new() -> Self { + pub(crate) fn new() -> Self { if inside_proc_macro() { TokenStream::Compiler(DeferredTokenStream::new(proc_macro::TokenStream::new())) } else { @@ -86,7 +86,7 @@ impl TokenStream { } } - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { match self { TokenStream::Compiler(tts) => tts.is_empty(), TokenStream::Fallback(tts) => tts.is_empty(), @@ -385,14 +385,14 @@ impl SourceFile { } /// Get the path to this source file as a string. - pub fn path(&self) -> PathBuf { + pub(crate) fn path(&self) -> PathBuf { match self { SourceFile::Compiler(a) => a.path(), SourceFile::Fallback(a) => a.path(), } } - pub fn is_real(&self) -> bool { + pub(crate) fn is_real(&self) -> bool { match self { SourceFile::Compiler(a) => a.is_real(), SourceFile::Fallback(a) => a.is_real(), @@ -417,7 +417,7 @@ pub(crate) enum Span { } impl Span { - pub fn call_site() -> Self { + pub(crate) fn call_site() -> Self { if inside_proc_macro() { Span::Compiler(proc_macro::Span::call_site()) } else { @@ -425,7 +425,7 @@ impl Span { } } - pub fn mixed_site() -> Self { + pub(crate) fn mixed_site() -> Self { if inside_proc_macro() { Span::Compiler(proc_macro::Span::mixed_site()) } else { @@ -434,7 +434,7 @@ impl Span { } #[cfg(super_unstable)] - pub fn def_site() -> Self { + pub(crate) fn def_site() -> Self { if inside_proc_macro() { Span::Compiler(proc_macro::Span::def_site()) } else { @@ -442,7 +442,7 @@ impl Span { } } - pub fn resolved_at(&self, other: Span) -> Span { + pub(crate) fn resolved_at(&self, other: Span) -> Span { match (self, other) { (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)), (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.resolved_at(b)), @@ -451,7 +451,7 @@ impl Span { } } - pub fn located_at(&self, other: Span) -> Span { + pub(crate) fn located_at(&self, other: Span) -> Span { match (self, other) { (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)), (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.located_at(b)), @@ -460,7 +460,7 @@ impl Span { } } - pub fn unwrap(self) -> proc_macro::Span { + pub(crate) fn unwrap(self) -> proc_macro::Span { match self { Span::Compiler(s) => s, Span::Fallback(_) => panic!("proc_macro::Span is only available in procedural macros"), @@ -468,7 +468,7 @@ impl Span { } #[cfg(super_unstable)] - pub fn source_file(&self) -> SourceFile { + pub(crate) fn source_file(&self) -> SourceFile { match self { Span::Compiler(s) => SourceFile::nightly(s.source_file()), Span::Fallback(s) => SourceFile::Fallback(s.source_file()), @@ -476,7 +476,7 @@ impl Span { } #[cfg(span_locations)] - pub fn byte_range(&self) -> Range { + pub(crate) fn byte_range(&self) -> Range { match self { #[cfg(proc_macro_span)] Span::Compiler(s) => s.byte_range(), @@ -487,7 +487,7 @@ impl Span { } #[cfg(span_locations)] - pub fn start(&self) -> LineColumn { + pub(crate) fn start(&self) -> LineColumn { match self { #[cfg(proc_macro_span)] Span::Compiler(s) => LineColumn { @@ -501,7 +501,7 @@ impl Span { } #[cfg(span_locations)] - pub fn end(&self) -> LineColumn { + pub(crate) fn end(&self) -> LineColumn { match self { #[cfg(proc_macro_span)] Span::Compiler(s) => { @@ -517,7 +517,7 @@ impl Span { } } - pub fn join(&self, other: Span) -> Option { + pub(crate) fn join(&self, other: Span) -> Option { let ret = match (self, other) { #[cfg(proc_macro_span)] (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.join(b)?), @@ -528,7 +528,7 @@ impl Span { } #[cfg(super_unstable)] - pub fn eq(&self, other: &Span) -> bool { + pub(crate) fn eq(&self, other: &Span) -> bool { match (self, other) { (Span::Compiler(a), Span::Compiler(b)) => a.eq(b), (Span::Fallback(a), Span::Fallback(b)) => a.eq(b), @@ -536,7 +536,7 @@ impl Span { } } - pub fn source_text(&self) -> Option { + pub(crate) fn source_text(&self) -> Option { match self { #[cfg(not(no_source_text))] Span::Compiler(s) => s.source_text(), @@ -591,7 +591,7 @@ pub(crate) enum Group { } impl Group { - pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self { + pub(crate) fn new(delimiter: Delimiter, stream: TokenStream) -> Self { match stream { TokenStream::Compiler(tts) => { let delimiter = match delimiter { @@ -608,7 +608,7 @@ impl Group { } } - pub fn delimiter(&self) -> Delimiter { + pub(crate) fn delimiter(&self) -> Delimiter { match self { Group::Compiler(g) => match g.delimiter() { proc_macro::Delimiter::Parenthesis => Delimiter::Parenthesis, @@ -620,35 +620,35 @@ impl Group { } } - pub fn stream(&self) -> TokenStream { + pub(crate) fn stream(&self) -> TokenStream { match self { Group::Compiler(g) => TokenStream::Compiler(DeferredTokenStream::new(g.stream())), Group::Fallback(g) => TokenStream::Fallback(g.stream()), } } - pub fn span(&self) -> Span { + pub(crate) fn span(&self) -> Span { match self { Group::Compiler(g) => Span::Compiler(g.span()), Group::Fallback(g) => Span::Fallback(g.span()), } } - pub fn span_open(&self) -> Span { + pub(crate) fn span_open(&self) -> Span { match self { Group::Compiler(g) => Span::Compiler(g.span_open()), Group::Fallback(g) => Span::Fallback(g.span_open()), } } - pub fn span_close(&self) -> Span { + pub(crate) fn span_close(&self) -> Span { match self { Group::Compiler(g) => Span::Compiler(g.span_close()), Group::Fallback(g) => Span::Fallback(g.span_close()), } } - pub fn set_span(&mut self, span: Span) { + pub(crate) fn set_span(&mut self, span: Span) { match (self, span) { (Group::Compiler(g), Span::Compiler(s)) => g.set_span(s), (Group::Fallback(g), Span::Fallback(s)) => g.set_span(s), @@ -697,37 +697,37 @@ pub(crate) enum Ident { impl Ident { #[track_caller] - pub fn new_checked(string: &str, span: Span) -> Self { + pub(crate) fn new_checked(string: &str, span: Span) -> Self { match span { Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)), Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_checked(string, s)), } } - pub fn new_unchecked(string: &str, span: fallback::Span) -> Self { + pub(crate) fn new_unchecked(string: &str, span: fallback::Span) -> Self { Ident::Fallback(fallback::Ident::new_unchecked(string, span)) } #[track_caller] - pub fn new_raw_checked(string: &str, span: Span) -> Self { + pub(crate) fn new_raw_checked(string: &str, span: Span) -> Self { match span { Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new_raw(string, s)), Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw_checked(string, s)), } } - pub fn new_raw_unchecked(string: &str, span: fallback::Span) -> Self { + pub(crate) fn new_raw_unchecked(string: &str, span: fallback::Span) -> Self { Ident::Fallback(fallback::Ident::new_raw_unchecked(string, span)) } - pub fn span(&self) -> Span { + pub(crate) fn span(&self) -> Span { match self { Ident::Compiler(t) => Span::Compiler(t.span()), Ident::Fallback(t) => Span::Fallback(t.span()), } } - pub fn set_span(&mut self, span: Span) { + pub(crate) fn set_span(&mut self, span: Span) { match (self, span) { (Ident::Compiler(t), Span::Compiler(s)) => t.set_span(s), (Ident::Fallback(t), Span::Fallback(s)) => t.set_span(s), @@ -794,7 +794,7 @@ pub(crate) enum Literal { macro_rules! suffixed_numbers { ($($name:ident => $kind:ident,)*) => ($( - pub fn $name(n: $kind) -> Literal { + pub(crate) fn $name(n: $kind) -> Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::$name(n)) } else { @@ -806,7 +806,7 @@ macro_rules! suffixed_numbers { macro_rules! unsuffixed_integers { ($($name:ident => $kind:ident,)*) => ($( - pub fn $name(n: $kind) -> Literal { + pub(crate) fn $name(n: $kind) -> Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::$name(n)) } else { @@ -817,7 +817,7 @@ macro_rules! unsuffixed_integers { } impl Literal { - pub unsafe fn from_str_unchecked(repr: &str) -> Self { + pub(crate) unsafe fn from_str_unchecked(repr: &str) -> Self { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::from_str(repr).expect("invalid literal")) } else { @@ -858,7 +858,7 @@ impl Literal { isize_unsuffixed => isize, } - pub fn f32_unsuffixed(f: f32) -> Literal { + pub(crate) fn f32_unsuffixed(f: f32) -> Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::f32_unsuffixed(f)) } else { @@ -866,7 +866,7 @@ impl Literal { } } - pub fn f64_unsuffixed(f: f64) -> Literal { + pub(crate) fn f64_unsuffixed(f: f64) -> Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::f64_unsuffixed(f)) } else { @@ -874,7 +874,7 @@ impl Literal { } } - pub fn string(string: &str) -> Literal { + pub(crate) fn string(string: &str) -> Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::string(string)) } else { @@ -882,7 +882,7 @@ impl Literal { } } - pub fn character(ch: char) -> Literal { + pub(crate) fn character(ch: char) -> Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::character(ch)) } else { @@ -890,7 +890,7 @@ impl Literal { } } - pub fn byte_character(byte: u8) -> Literal { + pub(crate) fn byte_character(byte: u8) -> Literal { if inside_proc_macro() { Literal::Compiler({ #[cfg(not(no_literal_byte_character))] @@ -909,7 +909,7 @@ impl Literal { } } - pub fn byte_string(bytes: &[u8]) -> Literal { + pub(crate) fn byte_string(bytes: &[u8]) -> Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::byte_string(bytes)) } else { @@ -917,7 +917,7 @@ impl Literal { } } - pub fn c_string(string: &CStr) -> Literal { + pub(crate) fn c_string(string: &CStr) -> Literal { if inside_proc_macro() { Literal::Compiler({ #[cfg(not(no_literal_c_string))] @@ -936,14 +936,14 @@ impl Literal { } } - pub fn span(&self) -> Span { + pub(crate) fn span(&self) -> Span { match self { Literal::Compiler(lit) => Span::Compiler(lit.span()), Literal::Fallback(lit) => Span::Fallback(lit.span()), } } - pub fn set_span(&mut self, span: Span) { + pub(crate) fn set_span(&mut self, span: Span) { match (self, span) { (Literal::Compiler(lit), Span::Compiler(s)) => lit.set_span(s), (Literal::Fallback(lit), Span::Fallback(s)) => lit.set_span(s), @@ -952,7 +952,7 @@ impl Literal { } } - pub fn subspan>(&self, range: R) -> Option { + pub(crate) fn subspan>(&self, range: R) -> Option { match self { #[cfg(proc_macro_span)] Literal::Compiler(lit) => lit.subspan(range).map(Span::Compiler),