Skip to content

Commit

Permalink
Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett
Browse files Browse the repository at this point in the history
Remove `crate` visibility modifier

FCP to remove this syntax is just about complete in #53120. Once it completes, this should be merged ASAP to avoid merge conflicts.

The first two commits remove usage of the feature in this repository, while the last removes the feature itself.
  • Loading branch information
bors committed May 21, 2022
2 parents 3b64fe9 + 6970246 commit 4f372b1
Show file tree
Hide file tree
Showing 271 changed files with 1,902 additions and 2,052 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem {
NestedMetaItem::MetaItem(mk_word_item(ident))
}

crate fn mk_attr_id() -> AttrId {
pub(crate) fn mk_attr_id() -> AttrId {
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering;

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#![feature(box_patterns)]
#![feature(const_default_impls)]
#![feature(const_trait_impl)]
#![feature(crate_visibility_modifier)]
#![feature(if_let_guard)]
#![feature(label_break_value)]
#![feature(let_chains)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl LitKind {
}
}

crate fn may_have_suffix(self) -> bool {
pub(crate) fn may_have_suffix(self) -> bool {
matches!(self, Integer | Float | Err)
}
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ use std::collections::hash_map::Entry;
use std::fmt::Write;

impl<'a, 'hir> LoweringContext<'a, 'hir> {
crate fn lower_inline_asm(&mut self, sp: Span, asm: &InlineAsm) -> &'hir hir::InlineAsm<'hir> {
pub(crate) fn lower_inline_asm(
&mut self,
sp: Span,
asm: &InlineAsm,
) -> &'hir hir::InlineAsm<'hir> {
// Rustdoc needs to support asm! from foreign architectures: don't try
// lowering the register constraints in this case.
let asm_arch = if self.sess.opts.actually_rustdoc { None } else { self.sess.asm_arch };
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

/// Construct `ExprKind::Err` for the given `span`.
crate fn expr_err(&mut self, span: Span) -> hir::Expr<'hir> {
pub(crate) fn expr_err(&mut self, span: Span) -> hir::Expr<'hir> {
self.expr(span, hir::ExprKind::Err, AttrVec::new())
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
//! get confused if the spans from leaf AST nodes occur in multiple places
//! in the HIR, especially for multiple identifiers.
#![feature(crate_visibility_modifier)]
#![feature(box_patterns)]
#![feature(let_chains)]
#![feature(let_else)]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_lowering/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use rustc_span::symbol::Ident;
use rustc_span::{source_map::Spanned, Span};

impl<'a, 'hir> LoweringContext<'a, 'hir> {
crate fn lower_pat(&mut self, pattern: &Pat) -> &'hir hir::Pat<'hir> {
pub(crate) fn lower_pat(&mut self, pattern: &Pat) -> &'hir hir::Pat<'hir> {
self.arena.alloc(self.lower_pat_mut(pattern))
}

crate fn lower_pat_mut(&mut self, mut pattern: &Pat) -> hir::Pat<'hir> {
pub(crate) fn lower_pat_mut(&mut self, mut pattern: &Pat) -> hir::Pat<'hir> {
ensure_sufficient_stack(|| {
// loop here to avoid recursion
let node = loop {
Expand Down Expand Up @@ -290,7 +290,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

/// Emit a friendly error for extra `..` patterns in a tuple/tuple struct/slice pattern.
crate fn ban_extra_rest_pat(&self, sp: Span, prev_sp: Span, ctx: &str) {
pub(crate) fn ban_extra_rest_pat(&self, sp: Span, prev_sp: Span, ctx: &str) {
self.diagnostic()
.struct_span_err(sp, &format!("`..` can only be used once per {} pattern", ctx))
.span_label(sp, &format!("can only be used once per {} pattern", ctx))
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use smallvec::smallvec;
use tracing::debug;

impl<'a, 'hir> LoweringContext<'a, 'hir> {
crate fn lower_qpath(
pub(crate) fn lower_qpath(
&mut self,
id: NodeId,
qself: &Option<QSelf>,
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
);
}

crate fn lower_path_extra(
pub(crate) fn lower_path_extra(
&mut self,
res: Res,
p: &Path,
Expand All @@ -163,7 +163,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
})
}

crate fn lower_path(
pub(crate) fn lower_path(
&mut self,
id: NodeId,
p: &Path,
Expand All @@ -174,7 +174,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.lower_path_extra(res, p, param_mode)
}

crate fn lower_path_segment(
pub(crate) fn lower_path_segment(
&mut self,
path_span: Span,
segment: &PathSegment,
Expand Down Expand Up @@ -381,7 +381,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

/// An associated type binding `Output = $ty`.
crate fn output_ty_binding(
pub(crate) fn output_ty_binding(
&mut self,
span: Span,
ty: &'hir hir::Ty<'hir>,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_pretty/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(associated_type_bounds)]
#![feature(crate_visibility_modifier)]
#![feature(box_patterns)]
#![feature(with_negative_coherence)]
#![recursion_limit = "256"]
Expand Down
57 changes: 31 additions & 26 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub struct State<'a> {
ann: &'a (dyn PpAnn + 'a),
}

crate const INDENT_UNIT: isize = 4;
pub(crate) const INDENT_UNIT: isize = 4;

/// Requires you to pass an input filename and reader so that
/// it can scan the input text for comments to copy forward.
Expand Down Expand Up @@ -955,8 +955,13 @@ impl<'a> State<'a> {
State { s: pp::Printer::new(), comments: None, ann: &NoAnn }
}

crate fn commasep_cmnt<T, F, G>(&mut self, b: Breaks, elts: &[T], mut op: F, mut get_span: G)
where
pub(crate) fn commasep_cmnt<T, F, G>(
&mut self,
b: Breaks,
elts: &[T],
mut op: F,
mut get_span: G,
) where
F: FnMut(&mut State<'_>, &T),
G: FnMut(&T) -> rustc_span::Span,
{
Expand All @@ -976,7 +981,7 @@ impl<'a> State<'a> {
self.end();
}

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

Expand Down Expand Up @@ -1109,7 +1114,7 @@ impl<'a> State<'a> {
self.print_trait_ref(&t.trait_ref)
}

crate fn print_stmt(&mut self, st: &ast::Stmt) {
pub(crate) fn print_stmt(&mut self, st: &ast::Stmt) {
self.maybe_print_comment(st.span.lo());
match st.kind {
ast::StmtKind::Local(ref loc) => {
Expand Down Expand Up @@ -1164,19 +1169,19 @@ impl<'a> State<'a> {
self.maybe_print_trailing_comment(st.span, None)
}

crate fn print_block(&mut self, blk: &ast::Block) {
pub(crate) fn print_block(&mut self, blk: &ast::Block) {
self.print_block_with_attrs(blk, &[])
}

crate fn print_block_unclosed_indent(&mut self, blk: &ast::Block) {
pub(crate) fn print_block_unclosed_indent(&mut self, blk: &ast::Block) {
self.print_block_maybe_unclosed(blk, &[], false)
}

crate fn print_block_with_attrs(&mut self, blk: &ast::Block, attrs: &[ast::Attribute]) {
pub(crate) fn print_block_with_attrs(&mut self, blk: &ast::Block, attrs: &[ast::Attribute]) {
self.print_block_maybe_unclosed(blk, attrs, true)
}

crate fn print_block_maybe_unclosed(
pub(crate) fn print_block_maybe_unclosed(
&mut self,
blk: &ast::Block,
attrs: &[ast::Attribute],
Expand Down Expand Up @@ -1210,7 +1215,7 @@ impl<'a> State<'a> {
}

/// Print a `let pat = expr` expression.
crate fn print_let(&mut self, pat: &ast::Pat, expr: &ast::Expr) {
pub(crate) fn print_let(&mut self, pat: &ast::Pat, expr: &ast::Expr) {
self.word("let ");
self.print_pat(pat);
self.space();
Expand All @@ -1219,7 +1224,7 @@ impl<'a> State<'a> {
self.print_expr_cond_paren(expr, Self::cond_needs_par(expr) || npals())
}

crate fn print_mac(&mut self, m: &ast::MacCall) {
pub(crate) fn print_mac(&mut self, m: &ast::MacCall) {
self.print_mac_common(
Some(MacHeader::Path(&m.path)),
true,
Expand Down Expand Up @@ -1360,15 +1365,15 @@ impl<'a> State<'a> {
self.pclose();
}

crate fn print_local_decl(&mut self, loc: &ast::Local) {
pub(crate) fn print_local_decl(&mut self, loc: &ast::Local) {
self.print_pat(&loc.pat);
if let Some(ref ty) = loc.ty {
self.word_space(":");
self.print_type(ty);
}
}

crate fn print_name(&mut self, name: Symbol) {
pub(crate) fn print_name(&mut self, name: Symbol) {
self.word(name.to_string());
self.ann.post(self, AnnNode::Name(&name))
}
Expand All @@ -1392,7 +1397,7 @@ impl<'a> State<'a> {
}
}

crate fn print_pat(&mut self, pat: &ast::Pat) {
pub(crate) fn print_pat(&mut self, pat: &ast::Pat) {
self.maybe_print_comment(pat.span.lo());
self.ann.pre(self, AnnNode::Pat(pat));
/* Pat isn't normalized, but the beauty of it
Expand Down Expand Up @@ -1551,7 +1556,7 @@ impl<'a> State<'a> {
}
}

crate fn print_asyncness(&mut self, asyncness: ast::Async) {
pub(crate) fn print_asyncness(&mut self, asyncness: ast::Async) {
if asyncness.is_async() {
self.word_nbsp("async");
}
Expand Down Expand Up @@ -1584,11 +1589,11 @@ impl<'a> State<'a> {
}
}

crate fn print_lifetime(&mut self, lifetime: ast::Lifetime) {
pub(crate) fn print_lifetime(&mut self, lifetime: ast::Lifetime) {
self.print_name(lifetime.ident.name)
}

crate fn print_lifetime_bounds(
pub(crate) fn print_lifetime_bounds(
&mut self,
lifetime: ast::Lifetime,
bounds: &ast::GenericBounds,
Expand All @@ -1608,7 +1613,7 @@ impl<'a> State<'a> {
}
}

crate fn print_generic_params(&mut self, generic_params: &[ast::GenericParam]) {
pub(crate) fn print_generic_params(&mut self, generic_params: &[ast::GenericParam]) {
if generic_params.is_empty() {
return;
}
Expand Down Expand Up @@ -1662,12 +1667,12 @@ impl<'a> State<'a> {
}
}

crate fn print_mt(&mut self, mt: &ast::MutTy, print_const: bool) {
pub(crate) fn print_mt(&mut self, mt: &ast::MutTy, print_const: bool) {
self.print_mutability(mt.mutbl, print_const);
self.print_type(&mt.ty)
}

crate fn print_param(&mut self, input: &ast::Param, is_closure: bool) {
pub(crate) fn print_param(&mut self, input: &ast::Param, is_closure: bool) {
self.ibox(INDENT_UNIT);

self.print_outer_attributes_inline(&input.attrs);
Expand Down Expand Up @@ -1695,7 +1700,7 @@ impl<'a> State<'a> {
self.end();
}

crate fn print_fn_ret_ty(&mut self, fn_ret_ty: &ast::FnRetTy) {
pub(crate) fn print_fn_ret_ty(&mut self, fn_ret_ty: &ast::FnRetTy) {
if let ast::FnRetTy::Ty(ty) = fn_ret_ty {
self.space_if_not_bol();
self.ibox(INDENT_UNIT);
Expand All @@ -1706,7 +1711,7 @@ impl<'a> State<'a> {
}
}

crate fn print_ty_fn(
pub(crate) fn print_ty_fn(
&mut self,
ext: ast::Extern,
unsafety: ast::Unsafe,
Expand All @@ -1730,7 +1735,7 @@ impl<'a> State<'a> {
self.end();
}

crate fn print_fn_header_info(&mut self, header: ast::FnHeader) {
pub(crate) fn print_fn_header_info(&mut self, header: ast::FnHeader) {
self.print_constness(header.constness);
self.print_asyncness(header.asyncness);
self.print_unsafety(header.unsafety);
Expand All @@ -1750,21 +1755,21 @@ impl<'a> State<'a> {
self.word("fn")
}

crate fn print_unsafety(&mut self, s: ast::Unsafe) {
pub(crate) fn print_unsafety(&mut self, s: ast::Unsafe) {
match s {
ast::Unsafe::No => {}
ast::Unsafe::Yes(_) => self.word_nbsp("unsafe"),
}
}

crate fn print_constness(&mut self, s: ast::Const) {
pub(crate) fn print_constness(&mut self, s: ast::Const) {
match s {
ast::Const::No => {}
ast::Const::Yes(_) => self.word_nbsp("const"),
}
}

crate fn print_is_auto(&mut self, s: ast::IsAuto) {
pub(crate) fn print_is_auto(&mut self, s: ast::IsAuto) {
match s {
ast::IsAuto::Yes => self.word_nbsp("auto"),
ast::IsAuto::No => {}
Expand Down
Loading

0 comments on commit 4f372b1

Please sign in to comment.