Skip to content

Commit f2fc87d

Browse files
committed
Add warn(unreachable_pub) to rustc_ast_pretty.
1 parent a6b2880 commit f2fc87d

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

compiler/rustc_ast_pretty/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![doc(rust_logo)]
44
#![feature(box_patterns)]
55
#![feature(rustdoc_internals)]
6+
#![warn(unreachable_pub)]
67
// tidy-alphabetical-end
78

89
mod helpers;

compiler/rustc_ast_pretty/src/pp/convenience.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Printer {
8989
}
9090

9191
impl Token {
92-
pub fn is_hardbreak_tok(&self) -> bool {
92+
pub(crate) fn is_hardbreak_tok(&self) -> bool {
9393
*self == Printer::hardbreak_tok_offset(0)
9494
}
9595
}

compiler/rustc_ast_pretty/src/pp/ring.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,54 @@ use std::ops::{Index, IndexMut};
1111
/// Holding a RingBuffer whose view is elements left..right gives the ability to
1212
/// use Index and IndexMut to access elements i in the infinitely long queue for
1313
/// which left <= i < right.
14-
pub struct RingBuffer<T> {
14+
pub(super) struct RingBuffer<T> {
1515
data: VecDeque<T>,
1616
// Abstract index of data[0] in the infinitely sized queue.
1717
offset: usize,
1818
}
1919

2020
impl<T> RingBuffer<T> {
21-
pub fn new() -> Self {
21+
pub(super) fn new() -> Self {
2222
RingBuffer { data: VecDeque::new(), offset: 0 }
2323
}
2424

25-
pub fn is_empty(&self) -> bool {
25+
pub(super) fn is_empty(&self) -> bool {
2626
self.data.is_empty()
2727
}
2828

29-
pub fn push(&mut self, value: T) -> usize {
29+
pub(super) fn push(&mut self, value: T) -> usize {
3030
let index = self.offset + self.data.len();
3131
self.data.push_back(value);
3232
index
3333
}
3434

35-
pub fn clear(&mut self) {
35+
pub(super) fn clear(&mut self) {
3636
self.data.clear();
3737
}
3838

39-
pub fn index_of_first(&self) -> usize {
39+
pub(super) fn index_of_first(&self) -> usize {
4040
self.offset
4141
}
4242

43-
pub fn first(&self) -> Option<&T> {
43+
pub(super) fn first(&self) -> Option<&T> {
4444
self.data.front()
4545
}
4646

47-
pub fn first_mut(&mut self) -> Option<&mut T> {
47+
pub(super) fn first_mut(&mut self) -> Option<&mut T> {
4848
self.data.front_mut()
4949
}
5050

51-
pub fn pop_first(&mut self) -> Option<T> {
51+
pub(super) fn pop_first(&mut self) -> Option<T> {
5252
let first = self.data.pop_front()?;
5353
self.offset += 1;
5454
Some(first)
5555
}
5656

57-
pub fn last(&self) -> Option<&T> {
57+
pub(super) fn last(&self) -> Option<&T> {
5858
self.data.back()
5959
}
6060

61-
pub fn last_mut(&mut self) -> Option<&mut T> {
61+
pub(super) fn last_mut(&mut self) -> Option<&mut T> {
6262
self.data.back_mut()
6363
}
6464
}

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,21 @@ impl Default for FixupContext {
110110
impl FixupContext {
111111
/// Create the initial fixup for printing an expression in statement
112112
/// position.
113-
pub fn new_stmt() -> Self {
113+
pub(crate) fn new_stmt() -> Self {
114114
FixupContext { stmt: true, ..FixupContext::default() }
115115
}
116116

117117
/// Create the initial fixup for printing an expression as the right-hand
118118
/// side of a match arm.
119-
pub fn new_match_arm() -> Self {
119+
pub(crate) fn new_match_arm() -> Self {
120120
FixupContext { match_arm: true, ..FixupContext::default() }
121121
}
122122

123123
/// Create the initial fixup for printing an expression as the "condition"
124124
/// of an `if` or `while`. There are a few other positions which are
125125
/// grammatically equivalent and also use this, such as the iterator
126126
/// expression in `for` and the scrutinee in `match`.
127-
pub fn new_cond() -> Self {
127+
pub(crate) fn new_cond() -> Self {
128128
FixupContext { parenthesize_exterior_struct_lit: true, ..FixupContext::default() }
129129
}
130130

@@ -139,7 +139,7 @@ impl FixupContext {
139139
///
140140
/// Not every expression has a leftmost subexpression. For example neither
141141
/// `-$a` nor `[$a]` have one.
142-
pub fn leftmost_subexpression(self) -> Self {
142+
pub(crate) fn leftmost_subexpression(self) -> Self {
143143
FixupContext {
144144
stmt: false,
145145
leftmost_subexpression_in_stmt: self.stmt || self.leftmost_subexpression_in_stmt,
@@ -158,7 +158,7 @@ impl FixupContext {
158158
/// current expression, and is not surrounded by a paren/bracket/brace. For
159159
/// example the `$b` in `$a + $b` and `-$b`, but not the one in `[$b]` or
160160
/// `$a.f($b)`.
161-
pub fn subsequent_subexpression(self) -> Self {
161+
pub(crate) fn subsequent_subexpression(self) -> Self {
162162
FixupContext {
163163
stmt: false,
164164
leftmost_subexpression_in_stmt: false,
@@ -173,7 +173,7 @@ impl FixupContext {
173173
///
174174
/// The documentation on `FixupContext::leftmost_subexpression_in_stmt` has
175175
/// examples.
176-
pub fn would_cause_statement_boundary(self, expr: &Expr) -> bool {
176+
pub(crate) fn would_cause_statement_boundary(self, expr: &Expr) -> bool {
177177
(self.leftmost_subexpression_in_stmt && !classify::expr_requires_semi_to_be_stmt(expr))
178178
|| (self.leftmost_subexpression_in_match_arm && classify::expr_is_complete(expr))
179179
}
@@ -189,7 +189,7 @@ impl FixupContext {
189189
///
190190
/// - `true && false`, because otherwise this would be misinterpreted as a
191191
/// "let chain".
192-
pub fn needs_par_as_let_scrutinee(self, expr: &Expr) -> bool {
192+
pub(crate) fn needs_par_as_let_scrutinee(self, expr: &Expr) -> bool {
193193
self.parenthesize_exterior_struct_lit && parser::contains_exterior_struct_lit(expr)
194194
|| parser::needs_par_as_let_scrutinee(expr.precedence().order())
195195
}

0 commit comments

Comments
 (0)