mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Fix visibilities
This commit is contained in:
parent
afe52d270d
commit
c4582f6d18
7 changed files with 27 additions and 32 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
@ -24,6 +24,8 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
env:
|
env:
|
||||||
CC: deny_c
|
CC: deny_c
|
||||||
|
# we want to build r-a on stable to check that it keeps building on stable,
|
||||||
|
# but we also want to test our proc-macro-srv which depends on nightly features
|
||||||
RUSTC_BOOTSTRAP: 1
|
RUSTC_BOOTSTRAP: 1
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
|
|
|
@ -13,8 +13,6 @@ use object::Object;
|
||||||
use paths::AbsPath;
|
use paths::AbsPath;
|
||||||
use proc_macro_api::{read_dylib_info, ProcMacroKind};
|
use proc_macro_api::{read_dylib_info, ProcMacroKind};
|
||||||
|
|
||||||
use crate::tt;
|
|
||||||
|
|
||||||
const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_";
|
const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_";
|
||||||
|
|
||||||
fn invalid_data_err(e: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> io::Error {
|
fn invalid_data_err(e: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> io::Error {
|
||||||
|
@ -152,9 +150,9 @@ impl Expander {
|
||||||
pub fn expand(
|
pub fn expand(
|
||||||
&self,
|
&self,
|
||||||
macro_name: &str,
|
macro_name: &str,
|
||||||
macro_body: &tt::Subtree,
|
macro_body: &crate::tt::Subtree,
|
||||||
attributes: Option<&tt::Subtree>,
|
attributes: Option<&crate::tt::Subtree>,
|
||||||
) -> Result<tt::Subtree, String> {
|
) -> Result<crate::tt::Subtree, String> {
|
||||||
let result = self.inner.proc_macros.expand(macro_name, macro_body, attributes);
|
let result = self.inner.proc_macros.expand(macro_name, macro_body, attributes);
|
||||||
result.map_err(|e| e.as_str().unwrap_or_else(|| "<unknown error>".to_string()))
|
result.map_err(|e| e.as_str().unwrap_or_else(|| "<unknown error>".to_string()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#![cfg(feature = "sysroot-abi")]
|
#![cfg(feature = "sysroot-abi")]
|
||||||
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)]
|
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)]
|
||||||
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
|
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
|
||||||
|
#![allow(unreachable_pub)]
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ impl ProcMacros {
|
||||||
/// *`info` - RustCInfo about the compiler that was used to compile the
|
/// *`info` - RustCInfo about the compiler that was used to compile the
|
||||||
/// macro crate. This is the information we use to figure out
|
/// macro crate. This is the information we use to figure out
|
||||||
/// which ABI to return
|
/// which ABI to return
|
||||||
pub fn from_lib(
|
pub(crate) fn from_lib(
|
||||||
lib: &Library,
|
lib: &Library,
|
||||||
symbol_name: String,
|
symbol_name: String,
|
||||||
info: RustCInfo,
|
info: RustCInfo,
|
||||||
|
@ -37,22 +37,10 @@ impl ProcMacros {
|
||||||
|
|
||||||
return Ok(Self { exported_macros: macros.to_vec() });
|
return Ok(Self { exported_macros: macros.to_vec() });
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we reached this point, versions didn't match. in testing, we
|
|
||||||
// want that to panic - this could mean that the format of `rustc
|
|
||||||
// --version` no longer matches the format of the version string
|
|
||||||
// stored in the `.rustc` section, and we want to catch that in-tree
|
|
||||||
// with `x.py test`
|
|
||||||
if cfg!(test) {
|
|
||||||
panic!(
|
|
||||||
"sysroot ABI mismatch: dylib rustc version (read from .rustc section): {:?} != proc-macro-srv version (read from 'rustc --version'): {:?}",
|
|
||||||
info.version_string, crate::RUSTC_VERSION_STRING
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Err(LoadProcMacroDylibError::AbiMismatch(info.version_string))
|
Err(LoadProcMacroDylibError::AbiMismatch(info.version_string))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expand(
|
pub(crate) fn expand(
|
||||||
&self,
|
&self,
|
||||||
macro_name: &str,
|
macro_name: &str,
|
||||||
macro_body: &tt::Subtree,
|
macro_body: &tt::Subtree,
|
||||||
|
@ -107,7 +95,7 @@ impl ProcMacros {
|
||||||
Err(proc_macro::bridge::PanicMessage::String("Nothing to expand".to_string()).into())
|
Err(proc_macro::bridge::PanicMessage::String("Nothing to expand".to_string()).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_macros(&self) -> Vec<(String, ProcMacroKind)> {
|
pub(crate) fn list_macros(&self) -> Vec<(String, ProcMacroKind)> {
|
||||||
self.exported_macros
|
self.exported_macros
|
||||||
.iter()
|
.iter()
|
||||||
.map(|proc_macro| match proc_macro {
|
.map(|proc_macro| match proc_macro {
|
||||||
|
@ -129,5 +117,11 @@ impl ProcMacros {
|
||||||
fn test_version_check() {
|
fn test_version_check() {
|
||||||
let path = paths::AbsPathBuf::assert(crate::proc_macro_test_dylib_path());
|
let path = paths::AbsPathBuf::assert(crate::proc_macro_test_dylib_path());
|
||||||
let info = proc_macro_api::read_dylib_info(&path).unwrap();
|
let info = proc_macro_api::read_dylib_info(&path).unwrap();
|
||||||
assert_eq!(info.version_string, crate::RUSTC_VERSION_STRING);
|
assert_eq!(
|
||||||
|
info.version_string,
|
||||||
|
crate::RUSTC_VERSION_STRING,
|
||||||
|
"sysroot ABI mismatch: dylib rustc version (read from .rustc section): {:?} != proc-macro-srv version (read from 'rustc --version'): {:?}",
|
||||||
|
info.version_string,
|
||||||
|
crate::RUSTC_VERSION_STRING,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use proc_macro::{
|
||||||
};
|
};
|
||||||
|
|
||||||
mod token_stream;
|
mod token_stream;
|
||||||
pub use token_stream::TokenStream;
|
pub(crate) use token_stream::TokenStream;
|
||||||
use token_stream::TokenStreamBuilder;
|
use token_stream::TokenStreamBuilder;
|
||||||
|
|
||||||
mod symbol;
|
mod symbol;
|
||||||
|
|
|
@ -12,11 +12,11 @@ thread_local! {
|
||||||
pub struct Symbol(u32);
|
pub struct Symbol(u32);
|
||||||
|
|
||||||
impl Symbol {
|
impl Symbol {
|
||||||
pub fn intern(data: &str) -> Symbol {
|
pub(super) fn intern(data: &str) -> Symbol {
|
||||||
SYMBOL_INTERNER.with(|i| i.borrow_mut().intern(data))
|
SYMBOL_INTERNER.with(|i| i.borrow_mut().intern(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text(&self) -> SmolStr {
|
pub(super) fn text(&self) -> SmolStr {
|
||||||
SYMBOL_INTERNER.with(|i| i.borrow().get(self).clone())
|
SYMBOL_INTERNER.with(|i| i.borrow().get(self).clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,15 @@ use crate::tt::{self, TokenTree};
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct TokenStream {
|
pub struct TokenStream {
|
||||||
pub token_trees: Vec<TokenTree>,
|
pub(super) token_trees: Vec<TokenTree>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TokenStream {
|
impl TokenStream {
|
||||||
pub fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
TokenStream::default()
|
TokenStream::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_subtree(subtree: tt::Subtree) -> Self {
|
pub(crate) fn with_subtree(subtree: tt::Subtree) -> Self {
|
||||||
if subtree.delimiter.kind != tt::DelimiterKind::Invisible {
|
if subtree.delimiter.kind != tt::DelimiterKind::Invisible {
|
||||||
TokenStream { token_trees: vec![TokenTree::Subtree(subtree)] }
|
TokenStream { token_trees: vec![TokenTree::Subtree(subtree)] }
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,11 +20,11 @@ impl TokenStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_subtree(self) -> tt::Subtree {
|
pub(crate) fn into_subtree(self) -> tt::Subtree {
|
||||||
tt::Subtree { delimiter: tt::Delimiter::UNSPECIFIED, token_trees: self.token_trees }
|
tt::Subtree { delimiter: tt::Delimiter::UNSPECIFIED, token_trees: self.token_trees }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub(super) fn is_empty(&self) -> bool {
|
||||||
self.token_trees.is_empty()
|
self.token_trees.is_empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,12 +78,12 @@ impl Extend<TokenStream> for TokenStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TokenStreamBuilder {
|
pub(super) struct TokenStreamBuilder {
|
||||||
acc: TokenStream,
|
acc: TokenStream,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Public implementation details for the `TokenStream` type, such as iterators.
|
/// pub(super)lic implementation details for the `TokenStream` type, such as iterators.
|
||||||
pub mod token_stream {
|
pub(super) mod token_stream {
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use super::{tt, TokenStream, TokenTree};
|
use super::{tt, TokenStream, TokenTree};
|
||||||
|
|
Loading…
Reference in a new issue