Skip to content

Commit d9443f7

Browse files
committed
Remove or downgrade unnecessary pub visibility markers.
1 parent 33cee0b commit d9443f7

File tree

5 files changed

+44
-50
lines changed

5 files changed

+44
-50
lines changed

compiler/rustc_ast_pretty/src/pp.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,20 @@ enum IndentStyle {
165165
}
166166

167167
#[derive(Clone, Copy, Default, PartialEq)]
168-
pub struct BreakToken {
168+
pub(crate) struct BreakToken {
169169
offset: isize,
170170
blank_space: isize,
171171
pre_break: Option<char>,
172172
}
173173

174174
#[derive(Clone, Copy, PartialEq)]
175-
pub struct BeginToken {
175+
pub(crate) struct BeginToken {
176176
indent: IndentStyle,
177177
breaks: Breaks,
178178
}
179179

180180
#[derive(PartialEq)]
181-
pub enum Token {
181+
pub(crate) enum Token {
182182
// In practice a string token contains either a `&'static str` or a
183183
// `String`. `Cow` is overkill for this because we never modify the data,
184184
// but it's more convenient than rolling our own more specialized type.
@@ -250,16 +250,16 @@ impl Printer {
250250
}
251251
}
252252

253-
pub fn last_token(&self) -> Option<&Token> {
253+
pub(crate) fn last_token(&self) -> Option<&Token> {
254254
self.last_token_still_buffered().or_else(|| self.last_printed.as_ref())
255255
}
256256

257-
pub fn last_token_still_buffered(&self) -> Option<&Token> {
257+
pub(crate) fn last_token_still_buffered(&self) -> Option<&Token> {
258258
self.buf.last().map(|last| &last.token)
259259
}
260260

261261
/// Be very careful with this!
262-
pub fn replace_last_token_still_buffered(&mut self, token: Token) {
262+
pub(crate) fn replace_last_token_still_buffered(&mut self, token: Token) {
263263
self.buf.last_mut().unwrap().token = token;
264264
}
265265

@@ -313,7 +313,7 @@ impl Printer {
313313
}
314314
}
315315

316-
pub fn offset(&mut self, offset: isize) {
316+
pub(crate) fn offset(&mut self, offset: isize) {
317317
if let Some(BufEntry { token: Token::Break(token), .. }) = &mut self.buf.last_mut() {
318318
token.offset += offset;
319319
}

compiler/rustc_ast_pretty/src/pp/convenience.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Printer {
6666
}
6767
}
6868

69-
pub fn hardbreak_tok_offset(off: isize) -> Token {
69+
pub(crate) fn hardbreak_tok_offset(off: isize) -> Token {
7070
Token::Break(BreakToken {
7171
offset: off,
7272
blank_space: SIZE_INFINITY,

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ pub trait PpAnn {
4343
fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
4444
}
4545

46-
#[derive(Copy, Clone)]
47-
pub struct NoAnn;
46+
struct NoAnn;
4847

4948
impl PpAnn for NoAnn {}
5049

@@ -61,11 +60,11 @@ impl<'a> Comments<'a> {
6160
}
6261

6362
// FIXME: This shouldn't probably clone lmao
64-
pub fn next(&self) -> Option<Comment> {
63+
fn next(&self) -> Option<Comment> {
6564
self.comments.get(self.current).cloned()
6665
}
6766

68-
pub fn trailing_comment(
67+
fn trailing_comment(
6968
&self,
7069
span: rustc_span::Span,
7170
next_pos: Option<BytePos>,
@@ -92,7 +91,7 @@ pub struct State<'a> {
9291
ann: &'a (dyn PpAnn + 'a),
9392
}
9493

95-
pub(crate) const INDENT_UNIT: isize = 4;
94+
const INDENT_UNIT: isize = 4;
9695

9796
/// Requires you to pass an input filename and reader so that
9897
/// it can scan the input text for comments to copy forward.
@@ -217,7 +216,7 @@ fn doc_comment_to_string(
217216
}
218217
}
219218

220-
pub fn literal_to_string(lit: token::Lit) -> String {
219+
fn literal_to_string(lit: token::Lit) -> String {
221220
let token::Lit { kind, symbol, suffix } = lit;
222221
let mut out = match kind {
223222
token::Byte => format!("b'{symbol}'"),
@@ -976,13 +975,8 @@ impl<'a> State<'a> {
976975
State { s: pp::Printer::new(), comments: None, ann: &NoAnn }
977976
}
978977

979-
pub(crate) fn commasep_cmnt<T, F, G>(
980-
&mut self,
981-
b: Breaks,
982-
elts: &[T],
983-
mut op: F,
984-
mut get_span: G,
985-
) where
978+
fn commasep_cmnt<T, F, G>(&mut self, b: Breaks, elts: &[T], mut op: F, mut get_span: G)
979+
where
986980
F: FnMut(&mut State<'_>, &T),
987981
G: FnMut(&T) -> rustc_span::Span,
988982
{
@@ -1002,7 +996,7 @@ impl<'a> State<'a> {
1002996
self.end();
1003997
}
1004998

1005-
pub(crate) fn commasep_exprs(&mut self, b: Breaks, exprs: &[P<ast::Expr>]) {
999+
fn commasep_exprs(&mut self, b: Breaks, exprs: &[P<ast::Expr>]) {
10061000
self.commasep_cmnt(b, exprs, |s, e| s.print_expr(e), |e| e.span)
10071001
}
10081002

@@ -1153,7 +1147,7 @@ impl<'a> State<'a> {
11531147
self.print_trait_ref(&t.trait_ref)
11541148
}
11551149

1156-
pub(crate) fn print_stmt(&mut self, st: &ast::Stmt) {
1150+
fn print_stmt(&mut self, st: &ast::Stmt) {
11571151
self.maybe_print_comment(st.span.lo());
11581152
match &st.kind {
11591153
ast::StmtKind::Local(loc) => {
@@ -1208,19 +1202,19 @@ impl<'a> State<'a> {
12081202
self.maybe_print_trailing_comment(st.span, None)
12091203
}
12101204

1211-
pub(crate) fn print_block(&mut self, blk: &ast::Block) {
1205+
fn print_block(&mut self, blk: &ast::Block) {
12121206
self.print_block_with_attrs(blk, &[])
12131207
}
12141208

1215-
pub(crate) fn print_block_unclosed_indent(&mut self, blk: &ast::Block) {
1209+
fn print_block_unclosed_indent(&mut self, blk: &ast::Block) {
12161210
self.print_block_maybe_unclosed(blk, &[], false)
12171211
}
12181212

1219-
pub(crate) fn print_block_with_attrs(&mut self, blk: &ast::Block, attrs: &[ast::Attribute]) {
1213+
fn print_block_with_attrs(&mut self, blk: &ast::Block, attrs: &[ast::Attribute]) {
12201214
self.print_block_maybe_unclosed(blk, attrs, true)
12211215
}
12221216

1223-
pub(crate) fn print_block_maybe_unclosed(
1217+
fn print_block_maybe_unclosed(
12241218
&mut self,
12251219
blk: &ast::Block,
12261220
attrs: &[ast::Attribute],
@@ -1254,7 +1248,7 @@ impl<'a> State<'a> {
12541248
}
12551249

12561250
/// Print a `let pat = expr` expression.
1257-
pub(crate) fn print_let(&mut self, pat: &ast::Pat, expr: &ast::Expr) {
1251+
fn print_let(&mut self, pat: &ast::Pat, expr: &ast::Expr) {
12581252
self.word("let ");
12591253
self.print_pat(pat);
12601254
self.space();
@@ -1263,7 +1257,7 @@ impl<'a> State<'a> {
12631257
self.print_expr_cond_paren(expr, Self::cond_needs_par(expr) || npals())
12641258
}
12651259

1266-
pub(crate) fn print_mac(&mut self, m: &ast::MacCall) {
1260+
fn print_mac(&mut self, m: &ast::MacCall) {
12671261
self.print_mac_common(
12681262
Some(MacHeader::Path(&m.path)),
12691263
true,
@@ -1404,15 +1398,15 @@ impl<'a> State<'a> {
14041398
self.pclose();
14051399
}
14061400

1407-
pub(crate) fn print_local_decl(&mut self, loc: &ast::Local) {
1401+
fn print_local_decl(&mut self, loc: &ast::Local) {
14081402
self.print_pat(&loc.pat);
14091403
if let Some(ty) = &loc.ty {
14101404
self.word_space(":");
14111405
self.print_type(ty);
14121406
}
14131407
}
14141408

1415-
pub(crate) fn print_name(&mut self, name: Symbol) {
1409+
fn print_name(&mut self, name: Symbol) {
14161410
self.word(name.to_string());
14171411
self.ann.post(self, AnnNode::Name(&name))
14181412
}
@@ -1436,7 +1430,7 @@ impl<'a> State<'a> {
14361430
}
14371431
}
14381432

1439-
pub(crate) fn print_pat(&mut self, pat: &ast::Pat) {
1433+
fn print_pat(&mut self, pat: &ast::Pat) {
14401434
self.maybe_print_comment(pat.span.lo());
14411435
self.ann.pre(self, AnnNode::Pat(pat));
14421436
/* Pat isn't normalized, but the beauty of it
@@ -1589,7 +1583,7 @@ impl<'a> State<'a> {
15891583
}
15901584
}
15911585

1592-
pub(crate) fn print_asyncness(&mut self, asyncness: ast::Async) {
1586+
fn print_asyncness(&mut self, asyncness: ast::Async) {
15931587
if asyncness.is_async() {
15941588
self.word_nbsp("async");
15951589
}
@@ -1634,11 +1628,11 @@ impl<'a> State<'a> {
16341628
}
16351629
}
16361630

1637-
pub(crate) fn print_lifetime(&mut self, lifetime: ast::Lifetime) {
1631+
fn print_lifetime(&mut self, lifetime: ast::Lifetime) {
16381632
self.print_name(lifetime.ident.name)
16391633
}
16401634

1641-
pub(crate) fn print_lifetime_bounds(&mut self, bounds: &ast::GenericBounds) {
1635+
fn print_lifetime_bounds(&mut self, bounds: &ast::GenericBounds) {
16421636
for (i, bound) in bounds.iter().enumerate() {
16431637
if i != 0 {
16441638
self.word(" + ");
@@ -1650,7 +1644,7 @@ impl<'a> State<'a> {
16501644
}
16511645
}
16521646

1653-
pub(crate) fn print_generic_params(&mut self, generic_params: &[ast::GenericParam]) {
1647+
fn print_generic_params(&mut self, generic_params: &[ast::GenericParam]) {
16541648
if generic_params.is_empty() {
16551649
return;
16561650
}
@@ -1714,12 +1708,12 @@ impl<'a> State<'a> {
17141708
}
17151709
}
17161710

1717-
pub(crate) fn print_mt(&mut self, mt: &ast::MutTy, print_const: bool) {
1711+
fn print_mt(&mut self, mt: &ast::MutTy, print_const: bool) {
17181712
self.print_mutability(mt.mutbl, print_const);
17191713
self.print_type(&mt.ty)
17201714
}
17211715

1722-
pub(crate) fn print_param(&mut self, input: &ast::Param, is_closure: bool) {
1716+
fn print_param(&mut self, input: &ast::Param, is_closure: bool) {
17231717
self.ibox(INDENT_UNIT);
17241718

17251719
self.print_outer_attributes_inline(&input.attrs);
@@ -1747,7 +1741,7 @@ impl<'a> State<'a> {
17471741
self.end();
17481742
}
17491743

1750-
pub(crate) fn print_fn_ret_ty(&mut self, fn_ret_ty: &ast::FnRetTy) {
1744+
fn print_fn_ret_ty(&mut self, fn_ret_ty: &ast::FnRetTy) {
17511745
if let ast::FnRetTy::Ty(ty) = fn_ret_ty {
17521746
self.space_if_not_bol();
17531747
self.ibox(INDENT_UNIT);
@@ -1758,7 +1752,7 @@ impl<'a> State<'a> {
17581752
}
17591753
}
17601754

1761-
pub(crate) fn print_ty_fn(
1755+
fn print_ty_fn(
17621756
&mut self,
17631757
ext: ast::Extern,
17641758
unsafety: ast::Unsafe,
@@ -1782,7 +1776,7 @@ impl<'a> State<'a> {
17821776
self.end();
17831777
}
17841778

1785-
pub(crate) fn print_fn_header_info(&mut self, header: ast::FnHeader) {
1779+
fn print_fn_header_info(&mut self, header: ast::FnHeader) {
17861780
self.print_constness(header.constness);
17871781
self.print_asyncness(header.asyncness);
17881782
self.print_unsafety(header.unsafety);
@@ -1802,21 +1796,21 @@ impl<'a> State<'a> {
18021796
self.word("fn")
18031797
}
18041798

1805-
pub(crate) fn print_unsafety(&mut self, s: ast::Unsafe) {
1799+
fn print_unsafety(&mut self, s: ast::Unsafe) {
18061800
match s {
18071801
ast::Unsafe::No => {}
18081802
ast::Unsafe::Yes(_) => self.word_nbsp("unsafe"),
18091803
}
18101804
}
18111805

1812-
pub(crate) fn print_constness(&mut self, s: ast::Const) {
1806+
fn print_constness(&mut self, s: ast::Const) {
18131807
match s {
18141808
ast::Const::No => {}
18151809
ast::Const::Yes(_) => self.word_nbsp("const"),
18161810
}
18171811
}
18181812

1819-
pub(crate) fn print_is_auto(&mut self, s: ast::IsAuto) {
1813+
fn print_is_auto(&mut self, s: ast::IsAuto) {
18201814
match s {
18211815
ast::IsAuto::Yes => self.word_nbsp("auto"),
18221816
ast::IsAuto::No => {}

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl<'a> State<'a> {
281281
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX)
282282
}
283283

284-
pub fn print_expr(&mut self, expr: &ast::Expr) {
284+
pub(super) fn print_expr(&mut self, expr: &ast::Expr) {
285285
self.print_expr_outer_attr_style(expr, true)
286286
}
287287

@@ -681,7 +681,7 @@ impl<'a> State<'a> {
681681
}
682682
}
683683

684-
pub fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> String {
684+
fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> String {
685685
let mut template = "\"".to_string();
686686
for piece in pieces {
687687
match piece {

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<'a> State<'a> {
2020
}
2121
}
2222

23-
pub(crate) fn print_foreign_item(&mut self, item: &ast::ForeignItem) {
23+
fn print_foreign_item(&mut self, item: &ast::ForeignItem) {
2424
let ast::Item { id, span, ident, ref attrs, ref kind, ref vis, tokens: _ } = *item;
2525
self.ann.pre(self, AnnNode::SubItem(id));
2626
self.hardbreak_if_not_bol();
@@ -518,7 +518,7 @@ impl<'a> State<'a> {
518518
}
519519
}
520520

521-
pub(crate) fn print_assoc_item(&mut self, item: &ast::AssocItem) {
521+
fn print_assoc_item(&mut self, item: &ast::AssocItem) {
522522
let ast::Item { id, span, ident, ref attrs, ref kind, ref vis, tokens: _ } = *item;
523523
self.ann.pre(self, AnnNode::SubItem(id));
524524
self.hardbreak_if_not_bol();
@@ -621,7 +621,7 @@ impl<'a> State<'a> {
621621
self.print_where_clause_parts(where_clause.has_where_token, &where_clause.predicates);
622622
}
623623

624-
pub(crate) fn print_where_clause_parts(
624+
fn print_where_clause_parts(
625625
&mut self,
626626
has_where_token: bool,
627627
predicates: &[ast::WherePredicate],
@@ -668,7 +668,7 @@ impl<'a> State<'a> {
668668
}
669669
}
670670

671-
pub fn print_where_bound_predicate(
671+
pub(crate) fn print_where_bound_predicate(
672672
&mut self,
673673
where_bound_predicate: &ast::WhereBoundPredicate,
674674
) {

0 commit comments

Comments
 (0)