Skip to content

Commit c4582f6

Browse files
committed
Fix visibilities
1 parent afe52d2 commit c4582f6

File tree

7 files changed

+27
-32
lines changed

7 files changed

+27
-32
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
runs-on: ${{ matrix.os }}
2525
env:
2626
CC: deny_c
27+
# we want to build r-a on stable to check that it keeps building on stable,
28+
# but we also want to test our proc-macro-srv which depends on nightly features
2729
RUSTC_BOOTSTRAP: 1
2830

2931
strategy:

crates/proc-macro-srv/src/dylib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use object::Object;
1313
use paths::AbsPath;
1414
use proc_macro_api::{read_dylib_info, ProcMacroKind};
1515

16-
use crate::tt;
17-
1816
const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_";
1917

2018
fn invalid_data_err(e: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> io::Error {
@@ -152,9 +150,9 @@ impl Expander {
152150
pub fn expand(
153151
&self,
154152
macro_name: &str,
155-
macro_body: &tt::Subtree,
156-
attributes: Option<&tt::Subtree>,
157-
) -> Result<tt::Subtree, String> {
153+
macro_body: &crate::tt::Subtree,
154+
attributes: Option<&crate::tt::Subtree>,
155+
) -> Result<crate::tt::Subtree, String> {
158156
let result = self.inner.proc_macros.expand(macro_name, macro_body, attributes);
159157
result.map_err(|e| e.as_str().unwrap_or_else(|| "<unknown error>".to_string()))
160158
}

crates/proc-macro-srv/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![cfg(feature = "sysroot-abi")]
1414
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)]
1515
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
16+
#![allow(unreachable_pub)]
1617

1718
extern crate proc_macro;
1819

crates/proc-macro-srv/src/proc_macros.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl ProcMacros {
2525
/// *`info` - RustCInfo about the compiler that was used to compile the
2626
/// macro crate. This is the information we use to figure out
2727
/// which ABI to return
28-
pub fn from_lib(
28+
pub(crate) fn from_lib(
2929
lib: &Library,
3030
symbol_name: String,
3131
info: RustCInfo,
@@ -37,22 +37,10 @@ impl ProcMacros {
3737

3838
return Ok(Self { exported_macros: macros.to_vec() });
3939
}
40-
41-
// if we reached this point, versions didn't match. in testing, we
42-
// want that to panic - this could mean that the format of `rustc
43-
// --version` no longer matches the format of the version string
44-
// stored in the `.rustc` section, and we want to catch that in-tree
45-
// with `x.py test`
46-
if cfg!(test) {
47-
panic!(
48-
"sysroot ABI mismatch: dylib rustc version (read from .rustc section): {:?} != proc-macro-srv version (read from 'rustc --version'): {:?}",
49-
info.version_string, crate::RUSTC_VERSION_STRING
50-
);
51-
}
5240
Err(LoadProcMacroDylibError::AbiMismatch(info.version_string))
5341
}
5442

55-
pub fn expand(
43+
pub(crate) fn expand(
5644
&self,
5745
macro_name: &str,
5846
macro_body: &tt::Subtree,
@@ -107,7 +95,7 @@ impl ProcMacros {
10795
Err(proc_macro::bridge::PanicMessage::String("Nothing to expand".to_string()).into())
10896
}
10997

110-
pub fn list_macros(&self) -> Vec<(String, ProcMacroKind)> {
98+
pub(crate) fn list_macros(&self) -> Vec<(String, ProcMacroKind)> {
11199
self.exported_macros
112100
.iter()
113101
.map(|proc_macro| match proc_macro {
@@ -129,5 +117,11 @@ impl ProcMacros {
129117
fn test_version_check() {
130118
let path = paths::AbsPathBuf::assert(crate::proc_macro_test_dylib_path());
131119
let info = proc_macro_api::read_dylib_info(&path).unwrap();
132-
assert_eq!(info.version_string, crate::RUSTC_VERSION_STRING);
120+
assert_eq!(
121+
info.version_string,
122+
crate::RUSTC_VERSION_STRING,
123+
"sysroot ABI mismatch: dylib rustc version (read from .rustc section): {:?} != proc-macro-srv version (read from 'rustc --version'): {:?}",
124+
info.version_string,
125+
crate::RUSTC_VERSION_STRING,
126+
);
133127
}

crates/proc-macro-srv/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use proc_macro::{
1414
};
1515

1616
mod token_stream;
17-
pub use token_stream::TokenStream;
17+
pub(crate) use token_stream::TokenStream;
1818
use token_stream::TokenStreamBuilder;
1919

2020
mod symbol;

crates/proc-macro-srv/src/server/symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ thread_local! {
1212
pub struct Symbol(u32);
1313

1414
impl Symbol {
15-
pub fn intern(data: &str) -> Symbol {
15+
pub(super) fn intern(data: &str) -> Symbol {
1616
SYMBOL_INTERNER.with(|i| i.borrow_mut().intern(data))
1717
}
1818

19-
pub fn text(&self) -> SmolStr {
19+
pub(super) fn text(&self) -> SmolStr {
2020
SYMBOL_INTERNER.with(|i| i.borrow().get(self).clone())
2121
}
2222
}

crates/proc-macro-srv/src/server/token_stream.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ use crate::tt::{self, TokenTree};
44

55
#[derive(Debug, Default, Clone)]
66
pub struct TokenStream {
7-
pub token_trees: Vec<TokenTree>,
7+
pub(super) token_trees: Vec<TokenTree>,
88
}
99

1010
impl TokenStream {
11-
pub fn new() -> Self {
11+
pub(crate) fn new() -> Self {
1212
TokenStream::default()
1313
}
1414

15-
pub fn with_subtree(subtree: tt::Subtree) -> Self {
15+
pub(crate) fn with_subtree(subtree: tt::Subtree) -> Self {
1616
if subtree.delimiter.kind != tt::DelimiterKind::Invisible {
1717
TokenStream { token_trees: vec![TokenTree::Subtree(subtree)] }
1818
} else {
1919
TokenStream { token_trees: subtree.token_trees }
2020
}
2121
}
2222

23-
pub fn into_subtree(self) -> tt::Subtree {
23+
pub(crate) fn into_subtree(self) -> tt::Subtree {
2424
tt::Subtree { delimiter: tt::Delimiter::UNSPECIFIED, token_trees: self.token_trees }
2525
}
2626

27-
pub fn is_empty(&self) -> bool {
27+
pub(super) fn is_empty(&self) -> bool {
2828
self.token_trees.is_empty()
2929
}
3030
}
@@ -78,12 +78,12 @@ impl Extend<TokenStream> for TokenStream {
7878
}
7979
}
8080

81-
pub struct TokenStreamBuilder {
81+
pub(super) struct TokenStreamBuilder {
8282
acc: TokenStream,
8383
}
8484

85-
/// Public implementation details for the `TokenStream` type, such as iterators.
86-
pub mod token_stream {
85+
/// pub(super)lic implementation details for the `TokenStream` type, such as iterators.
86+
pub(super) mod token_stream {
8787
use std::str::FromStr;
8888

8989
use super::{tt, TokenStream, TokenTree};

0 commit comments

Comments
 (0)