Skip to content

Commit

Permalink
Adjust some pubs.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Apr 25, 2024
1 parent 8dc84fa commit 7cbc3ef
Show file tree
Hide file tree
Showing 33 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/alloc_error_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};

pub fn expand(
pub(crate) fn expand(
ecx: &mut ExtCtxt<'_>,
_span: Span,
meta_item: &ast::MetaItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use thin_vec::thin_vec;

pub fn expand_assert<'cx>(
pub(crate) fn expand_assert<'cx>(
cx: &'cx mut ExtCtxt<'_>,
span: Span,
tts: TokenStream,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_errors::PResult;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_span::Span;

pub fn expand_cfg(
pub(crate) fn expand_cfg(
cx: &mut ExtCtxt<'_>,
sp: Span,
tts: TokenStream,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_ast::tokenstream::TokenStream;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_span::Span;

pub fn expand_compile_error<'cx>(
pub(crate) fn expand_compile_error<'cx>(
cx: &'cx mut ExtCtxt<'_>,
sp: Span,
tts: TokenStream,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpa
use rustc_session::errors::report_lit_error;
use rustc_span::symbol::Symbol;

pub fn expand_concat(
pub(crate) fn expand_concat(
cx: &mut ExtCtxt<'_>,
sp: rustc_span::Span,
tts: TokenStream,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/concat_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn handle_array_element(
None
}

pub fn expand_concat_bytes(
pub(crate) fn expand_concat_bytes(
cx: &mut ExtCtxt<'_>,
sp: Span,
tts: TokenStream,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/concat_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_span::Span;

use crate::errors;

pub fn expand_concat_idents<'cx>(
pub(crate) fn expand_concat_idents<'cx>(
cx: &'cx mut ExtCtxt<'_>,
sp: Span,
tts: TokenStream,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_ast::MetaItem;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::Span;

pub fn expand_deriving_copy(
pub(crate) fn expand_deriving_copy(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand All @@ -28,7 +28,7 @@ pub fn expand_deriving_copy(
trait_def.expand(cx, mitem, item, push);
}

pub fn expand_deriving_const_param_ty(
pub(crate) fn expand_deriving_const_param_ty(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};

pub fn expand_deriving_clone(
pub(crate) fn expand_deriving_clone(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_span::symbol::sym;
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};

pub fn expand_deriving_eq(
pub(crate) fn expand_deriving_eq(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use thin_vec::thin_vec;

pub fn expand_deriving_ord(
pub(crate) fn expand_deriving_ord(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down Expand Up @@ -39,7 +39,7 @@ pub fn expand_deriving_ord(
trait_def.expand(cx, mitem, item, push)
}

pub fn cs_cmp(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
pub(crate) fn cs_cmp(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
let test_id = Ident::new(sym::cmp, span);
let equal_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
let cmp_path = cx.std_path(&[sym::cmp, sym::Ord, sym::cmp]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_span::symbol::sym;
use rustc_span::Span;
use thin_vec::thin_vec;

pub fn expand_deriving_partial_eq(
pub(crate) fn expand_deriving_partial_eq(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use thin_vec::thin_vec;

pub fn expand_deriving_partial_ord(
pub(crate) fn expand_deriving_partial_ord(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};

pub fn expand_deriving_debug(
pub(crate) fn expand_deriving_debug(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};

pub fn expand_deriving_rustc_decodable(
pub(crate) fn expand_deriving_rustc_decodable(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_span::{ErrorGuaranteed, Span};
use smallvec::SmallVec;
use thin_vec::{thin_vec, ThinVec};

pub fn expand_deriving_default(
pub(crate) fn expand_deriving_default(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &ast::MetaItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};

pub fn expand_deriving_rustc_encodable(
pub(crate) fn expand_deriving_rustc_encodable(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
32 changes: 16 additions & 16 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
//! )
//! ```
pub use StaticFields::*;
pub use SubstructureFields::*;
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;

use crate::{deriving, errors};
use rustc_ast::ptr::P;
Expand All @@ -195,9 +195,9 @@ use std::vec;
use thin_vec::{thin_vec, ThinVec};
use ty::{Bounds, Path, Ref, Self_, Ty};

pub mod ty;
pub(crate) mod ty;

pub struct TraitDef<'a> {
pub(crate) struct TraitDef<'a> {
/// The span for the current #[derive(Foo)] header.
pub span: Span,

Expand All @@ -224,7 +224,7 @@ pub struct TraitDef<'a> {
pub is_const: bool,
}

pub struct MethodDef<'a> {
pub(crate) struct MethodDef<'a> {
/// name of the method
pub name: Symbol,
/// List of generics, e.g., `R: rand::Rng`
Expand All @@ -248,7 +248,7 @@ pub struct MethodDef<'a> {

/// How to handle fieldless enum variants.
#[derive(PartialEq)]
pub enum FieldlessVariantsStrategy {
pub(crate) enum FieldlessVariantsStrategy {
/// Combine fieldless variants into a single match arm.
/// This assumes that relevant information has been handled
/// by looking at the enum's discriminant.
Expand All @@ -263,7 +263,7 @@ pub enum FieldlessVariantsStrategy {
}

/// All the data about the data structure/method being derived upon.
pub struct Substructure<'a> {
pub(crate) struct Substructure<'a> {
/// ident of self
pub type_ident: Ident,
/// Verbatim access to any non-selflike arguments, i.e. arguments that
Expand All @@ -273,7 +273,7 @@ pub struct Substructure<'a> {
}

/// Summary of the relevant parts of a struct/enum field.
pub struct FieldInfo {
pub(crate) struct FieldInfo {
pub span: Span,
/// None for tuple structs/normal enum variants, Some for normal
/// structs/struct enum variants.
Expand All @@ -287,21 +287,21 @@ pub struct FieldInfo {
}

#[derive(Copy, Clone)]
pub enum IsTuple {
pub(crate) enum IsTuple {
No,
Yes,
}

/// Fields for a static method
pub enum StaticFields {
pub(crate) enum StaticFields {
/// Tuple and unit structs/enum variants like this.
Unnamed(Vec<Span>, IsTuple),
/// Normal structs/struct variants.
Named(Vec<(Ident, Span)>),
}

/// A summary of the possible sets of fields.
pub enum SubstructureFields<'a> {
pub(crate) enum SubstructureFields<'a> {
/// A non-static method where `Self` is a struct.
Struct(&'a ast::VariantData, Vec<FieldInfo>),

Expand Down Expand Up @@ -329,10 +329,10 @@ pub enum SubstructureFields<'a> {

/// Combine the values of all the fields together. The last argument is
/// all the fields of all the structures.
pub type CombineSubstructureFunc<'a> =
pub(crate) type CombineSubstructureFunc<'a> =
Box<dyn FnMut(&ExtCtxt<'_>, Span, &Substructure<'_>) -> BlockOrExpr + 'a>;

pub fn combine_substructure(
pub(crate) fn combine_substructure(
f: CombineSubstructureFunc<'_>,
) -> RefCell<CombineSubstructureFunc<'_>> {
RefCell::new(f)
Expand All @@ -349,7 +349,7 @@ struct TypeParameter {
/// avoiding the insertion of any unnecessary blocks.
///
/// The statements come before the expression.
pub struct BlockOrExpr(ThinVec<ast::Stmt>, Option<P<Expr>>);
pub(crate) struct BlockOrExpr(ThinVec<ast::Stmt>, Option<P<Expr>>);

impl BlockOrExpr {
pub fn new_stmts(stmts: ThinVec<ast::Stmt>) -> BlockOrExpr {
Expand Down Expand Up @@ -1647,7 +1647,7 @@ impl<'a> TraitDef<'a> {
/// The function passed to `cs_fold` is called repeatedly with a value of this
/// type. It describes one part of the code generation. The result is always an
/// expression.
pub enum CsFold<'a> {
pub(crate) enum CsFold<'a> {
/// The basic case: a field expression for one or more selflike args. E.g.
/// for `PartialEq::eq` this is something like `self.x == other.x`.
Single(&'a FieldInfo),
Expand All @@ -1662,7 +1662,7 @@ pub enum CsFold<'a> {

/// Folds over fields, combining the expressions for each field in a sequence.
/// Statics may not be folded over.
pub fn cs_fold<F>(
pub(crate) fn cs_fold<F>(
use_foldl: bool,
cx: &ExtCtxt<'_>,
trait_span: Span,
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_builtin_macros/src/deriving/generic/ty.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use
//! when specifying impls to be derived.
pub use Ty::*;
pub(crate) use Ty::*;

use rustc_ast::ptr::P;
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
Expand All @@ -14,14 +14,14 @@ use thin_vec::ThinVec;
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
/// for type parameters.
#[derive(Clone)]
pub struct Path {
pub(crate) struct Path {
path: Vec<Symbol>,
params: Vec<Box<Ty>>,
kind: PathKind,
}

#[derive(Clone)]
pub enum PathKind {
pub(crate) enum PathKind {
Local,
Global,
Std,
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Path {

/// A type. Supports pointers, Self, and literals.
#[derive(Clone)]
pub enum Ty {
pub(crate) enum Ty {
Self_,
/// A reference.
Ref(Box<Ty>, ast::Mutability),
Expand All @@ -83,7 +83,7 @@ pub enum Ty {
Unit,
}

pub fn self_ref() -> Ty {
pub(crate) fn self_ref() -> Ty {
Ref(Box::new(Self_), ast::Mutability::Not)
}

Expand Down Expand Up @@ -163,7 +163,7 @@ fn mk_ty_param(

/// Bounds on type parameters.
#[derive(Clone)]
pub struct Bounds {
pub(crate) struct Bounds {
pub bounds: Vec<(Symbol, Vec<Path>)>,
}

Expand Down Expand Up @@ -196,7 +196,7 @@ impl Bounds {
}
}

pub fn get_explicit_self(cx: &ExtCtxt<'_>, span: Span) -> (P<Expr>, ast::ExplicitSelf) {
pub(crate) fn get_explicit_self(cx: &ExtCtxt<'_>, span: Span) -> (P<Expr>, ast::ExplicitSelf) {
// This constructs a fresh `self` path.
let self_path = cx.expr_self(span);
let self_ty = respan(span, SelfKind::Region(None, ast::Mutability::Not));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_span::symbol::sym;
use rustc_span::Span;
use thin_vec::thin_vec;

pub fn expand_deriving_hash(
pub(crate) fn expand_deriving_hash(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
Expand Down
Loading

0 comments on commit 7cbc3ef

Please sign in to comment.