Remove crate
visibility usage in compiler
This commit is contained in:
parent
536020c5f9
commit
49c82f31a8
186 changed files with 865 additions and 800 deletions
|
@ -81,7 +81,7 @@ impl<'a> ToNameBinding<'a> for (Res, ty::Visibility, Span, LocalExpnId, IsMacroE
|
|||
impl<'a> Resolver<'a> {
|
||||
/// Defines `name` in namespace `ns` of module `parent` to be `def` if it is not yet defined;
|
||||
/// otherwise, reports an error.
|
||||
crate fn define<T>(&mut self, parent: Module<'a>, ident: Ident, ns: Namespace, def: T)
|
||||
pub(crate) fn define<T>(&mut self, parent: Module<'a>, ident: Ident, ns: Namespace, def: T)
|
||||
where
|
||||
T: ToNameBinding<'a>,
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ impl<'a> Resolver<'a> {
|
|||
/// If `def_id` refers to a module (in resolver's sense, i.e. a module item, crate root, enum,
|
||||
/// or trait), then this function returns that module's resolver representation, otherwise it
|
||||
/// returns `None`.
|
||||
crate fn get_module(&mut self, def_id: DefId) -> Option<Module<'a>> {
|
||||
pub(crate) fn get_module(&mut self, def_id: DefId) -> Option<Module<'a>> {
|
||||
if let module @ Some(..) = self.module_map.get(&def_id) {
|
||||
return module.copied();
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn expn_def_scope(&mut self, expn_id: ExpnId) -> Module<'a> {
|
||||
pub(crate) fn expn_def_scope(&mut self, expn_id: ExpnId) -> Module<'a> {
|
||||
match expn_id.expn_data().macro_def_id {
|
||||
Some(def_id) => self.macro_def_scope(def_id),
|
||||
None => expn_id
|
||||
|
@ -172,7 +172,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn macro_def_scope(&mut self, def_id: DefId) -> Module<'a> {
|
||||
pub(crate) fn macro_def_scope(&mut self, def_id: DefId) -> Module<'a> {
|
||||
if let Some(id) = def_id.as_local() {
|
||||
self.local_macro_def_scopes[&id]
|
||||
} else {
|
||||
|
@ -180,7 +180,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn get_macro(&mut self, res: Res) -> Option<Lrc<SyntaxExtension>> {
|
||||
pub(crate) fn get_macro(&mut self, res: Res) -> Option<Lrc<SyntaxExtension>> {
|
||||
match res {
|
||||
Res::Def(DefKind::Macro(..), def_id) => Some(self.get_macro_by_def_id(def_id)),
|
||||
Res::NonMacroAttr(_) => Some(self.non_macro_attr.clone()),
|
||||
|
@ -188,7 +188,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn get_macro_by_def_id(&mut self, def_id: DefId) -> Lrc<SyntaxExtension> {
|
||||
pub(crate) fn get_macro_by_def_id(&mut self, def_id: DefId) -> Lrc<SyntaxExtension> {
|
||||
if let Some(ext) = self.macro_map.get(&def_id) {
|
||||
return ext.clone();
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ impl<'a> Resolver<'a> {
|
|||
ext
|
||||
}
|
||||
|
||||
crate fn build_reduced_graph(
|
||||
pub(crate) fn build_reduced_graph(
|
||||
&mut self,
|
||||
fragment: &AstFragment,
|
||||
parent_scope: ParentScope<'a>,
|
||||
|
@ -213,7 +213,7 @@ impl<'a> Resolver<'a> {
|
|||
visitor.parent_scope.macro_rules
|
||||
}
|
||||
|
||||
crate fn build_reduced_graph_external(&mut self, module: Module<'a>) {
|
||||
pub(crate) fn build_reduced_graph_external(&mut self, module: Module<'a>) {
|
||||
for child in self.cstore().module_children_untracked(module.def_id(), self.session) {
|
||||
let parent_scope = ParentScope::module(module, self);
|
||||
BuildReducedGraphVisitor { r: self, parent_scope }
|
||||
|
|
|
@ -224,7 +224,7 @@ fn calc_unused_spans(
|
|||
}
|
||||
|
||||
impl Resolver<'_> {
|
||||
crate fn check_unused(&mut self, krate: &ast::Crate) {
|
||||
pub(crate) fn check_unused(&mut self, krate: &ast::Crate) {
|
||||
for import in self.potentially_unused_imports.iter() {
|
||||
match import.kind {
|
||||
_ if import.used.get()
|
||||
|
|
|
@ -11,7 +11,7 @@ use rustc_span::symbol::sym;
|
|||
use rustc_span::Span;
|
||||
use tracing::debug;
|
||||
|
||||
crate fn collect_definitions(
|
||||
pub(crate) fn collect_definitions(
|
||||
resolver: &mut Resolver<'_>,
|
||||
fragment: &AstFragment,
|
||||
expansion: LocalExpnId,
|
||||
|
|
|
@ -41,36 +41,36 @@ mod tests;
|
|||
type Res = def::Res<ast::NodeId>;
|
||||
|
||||
/// A vector of spans and replacements, a message and applicability.
|
||||
crate type Suggestion = (Vec<(Span, String)>, String, Applicability);
|
||||
pub(crate) type Suggestion = (Vec<(Span, String)>, String, Applicability);
|
||||
|
||||
/// Potential candidate for an undeclared or out-of-scope label - contains the ident of a
|
||||
/// similarly named label and whether or not it is reachable.
|
||||
crate type LabelSuggestion = (Ident, bool);
|
||||
pub(crate) type LabelSuggestion = (Ident, bool);
|
||||
|
||||
crate enum SuggestionTarget {
|
||||
pub(crate) enum SuggestionTarget {
|
||||
/// The target has a similar name as the name used by the programmer (probably a typo)
|
||||
SimilarlyNamed,
|
||||
/// The target is the only valid item that can be used in the corresponding context
|
||||
SingleItem,
|
||||
}
|
||||
|
||||
crate struct TypoSuggestion {
|
||||
pub(crate) struct TypoSuggestion {
|
||||
pub candidate: Symbol,
|
||||
pub res: Res,
|
||||
pub target: SuggestionTarget,
|
||||
}
|
||||
|
||||
impl TypoSuggestion {
|
||||
crate fn typo_from_res(candidate: Symbol, res: Res) -> TypoSuggestion {
|
||||
pub(crate) fn typo_from_res(candidate: Symbol, res: Res) -> TypoSuggestion {
|
||||
Self { candidate, res, target: SuggestionTarget::SimilarlyNamed }
|
||||
}
|
||||
crate fn single_item_from_res(candidate: Symbol, res: Res) -> TypoSuggestion {
|
||||
pub(crate) fn single_item_from_res(candidate: Symbol, res: Res) -> TypoSuggestion {
|
||||
Self { candidate, res, target: SuggestionTarget::SingleItem }
|
||||
}
|
||||
}
|
||||
|
||||
/// A free importable items suggested in case of resolution failure.
|
||||
crate struct ImportSuggestion {
|
||||
pub(crate) struct ImportSuggestion {
|
||||
pub did: Option<DefId>,
|
||||
pub descr: &'static str,
|
||||
pub path: Path,
|
||||
|
@ -92,7 +92,7 @@ fn reduce_impl_span_to_impl_keyword(sm: &SourceMap, impl_span: Span) -> Span {
|
|||
}
|
||||
|
||||
impl<'a> Resolver<'a> {
|
||||
crate fn report_errors(&mut self, krate: &Crate) {
|
||||
pub(crate) fn report_errors(&mut self, krate: &Crate) {
|
||||
self.report_with_use_injections(krate);
|
||||
|
||||
for &(span_use, span_def) in &self.macro_expanded_macro_export_errors {
|
||||
|
@ -147,7 +147,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn report_conflict<'b>(
|
||||
pub(crate) fn report_conflict<'b>(
|
||||
&mut self,
|
||||
parent: Module<'_>,
|
||||
ident: Ident,
|
||||
|
@ -419,7 +419,7 @@ impl<'a> Resolver<'a> {
|
|||
err.span_suggestion(span, message, String::new(), Applicability::MachineApplicable);
|
||||
}
|
||||
|
||||
crate fn lint_if_path_starts_with_module(
|
||||
pub(crate) fn lint_if_path_starts_with_module(
|
||||
&mut self,
|
||||
finalize: Option<Finalize>,
|
||||
path: &[Segment],
|
||||
|
@ -475,7 +475,7 @@ impl<'a> Resolver<'a> {
|
|||
);
|
||||
}
|
||||
|
||||
crate fn add_module_candidates(
|
||||
pub(crate) fn add_module_candidates(
|
||||
&mut self,
|
||||
module: Module<'a>,
|
||||
names: &mut Vec<TypoSuggestion>,
|
||||
|
@ -495,11 +495,11 @@ impl<'a> Resolver<'a> {
|
|||
///
|
||||
/// This takes the error provided, combines it with the span and any additional spans inside the
|
||||
/// error and emits it.
|
||||
crate fn report_error(&mut self, span: Span, resolution_error: ResolutionError<'a>) {
|
||||
pub(crate) fn report_error(&mut self, span: Span, resolution_error: ResolutionError<'a>) {
|
||||
self.into_struct_error(span, resolution_error).emit();
|
||||
}
|
||||
|
||||
crate fn into_struct_error(
|
||||
pub(crate) fn into_struct_error(
|
||||
&mut self,
|
||||
span: Span,
|
||||
resolution_error: ResolutionError<'a>,
|
||||
|
@ -1052,7 +1052,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn report_vis_error(
|
||||
pub(crate) fn report_vis_error(
|
||||
&mut self,
|
||||
vis_resolution_error: VisResolutionError<'_>,
|
||||
) -> ErrorGuaranteed {
|
||||
|
@ -1413,7 +1413,7 @@ impl<'a> Resolver<'a> {
|
|||
///
|
||||
/// N.B., the method does not look into imports, but this is not a problem,
|
||||
/// since we report the definitions (thus, the de-aliased imports).
|
||||
crate fn lookup_import_candidates<FilterFn>(
|
||||
pub(crate) fn lookup_import_candidates<FilterFn>(
|
||||
&mut self,
|
||||
lookup_ident: Ident,
|
||||
namespace: Namespace,
|
||||
|
@ -1460,7 +1460,7 @@ impl<'a> Resolver<'a> {
|
|||
suggestions
|
||||
}
|
||||
|
||||
crate fn unresolved_macro_suggestions(
|
||||
pub(crate) fn unresolved_macro_suggestions(
|
||||
&mut self,
|
||||
err: &mut Diagnostic,
|
||||
macro_kind: MacroKind,
|
||||
|
@ -1551,7 +1551,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn add_typo_suggestion(
|
||||
pub(crate) fn add_typo_suggestion(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
suggestion: Option<TypoSuggestion>,
|
||||
|
@ -1780,7 +1780,7 @@ impl<'a> Resolver<'a> {
|
|||
err.emit();
|
||||
}
|
||||
|
||||
crate fn find_similarly_named_module_or_crate(
|
||||
pub(crate) fn find_similarly_named_module_or_crate(
|
||||
&mut self,
|
||||
ident: Symbol,
|
||||
current_module: &Module<'a>,
|
||||
|
@ -1807,7 +1807,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn report_path_resolution_error(
|
||||
pub(crate) fn report_path_resolution_error(
|
||||
&mut self,
|
||||
path: &[Segment],
|
||||
opt_ns: Option<Namespace>, // `None` indicates a module path in import
|
||||
|
@ -2680,7 +2680,7 @@ fn is_span_suitable_for_use_injection(s: Span) -> bool {
|
|||
}
|
||||
|
||||
/// Convert the given number into the corresponding ordinal
|
||||
crate fn ordinalize(v: usize) -> String {
|
||||
pub(crate) fn ordinalize(v: usize) -> String {
|
||||
let suffix = match ((11..=13).contains(&(v % 100)), v % 10) {
|
||||
(false, 1) => "st",
|
||||
(false, 2) => "nd",
|
||||
|
|
|
@ -28,7 +28,7 @@ impl<'a> Resolver<'a> {
|
|||
/// A generic scope visitor.
|
||||
/// Visits scopes in order to resolve some identifier in them or perform other actions.
|
||||
/// If the callback returns `Some` result, we stop visiting scopes and return it.
|
||||
crate fn visit_scopes<T>(
|
||||
pub(crate) fn visit_scopes<T>(
|
||||
&mut self,
|
||||
scope_set: ScopeSet<'a>,
|
||||
parent_scope: &ParentScope<'a>,
|
||||
|
@ -274,7 +274,7 @@ impl<'a> Resolver<'a> {
|
|||
/// Invariant: This must only be called during main resolution, not during
|
||||
/// import resolution.
|
||||
#[tracing::instrument(level = "debug", skip(self, ribs))]
|
||||
crate fn resolve_ident_in_lexical_scope(
|
||||
pub(crate) fn resolve_ident_in_lexical_scope(
|
||||
&mut self,
|
||||
mut ident: Ident,
|
||||
ns: Namespace,
|
||||
|
@ -368,7 +368,7 @@ impl<'a> Resolver<'a> {
|
|||
/// The function is used for resolving initial segments of macro paths (e.g., `foo` in
|
||||
/// `foo::bar!(); or `foo!();`) and also for import paths on 2018 edition.
|
||||
#[tracing::instrument(level = "debug", skip(self, scope_set))]
|
||||
crate fn early_resolve_ident_in_lexical_scope(
|
||||
pub(crate) fn early_resolve_ident_in_lexical_scope(
|
||||
&mut self,
|
||||
orig_ident: Ident,
|
||||
scope_set: ScopeSet<'a>,
|
||||
|
@ -717,7 +717,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
crate fn maybe_resolve_ident_in_module(
|
||||
pub(crate) fn maybe_resolve_ident_in_module(
|
||||
&mut self,
|
||||
module: ModuleOrUniformRoot<'a>,
|
||||
ident: Ident,
|
||||
|
@ -729,7 +729,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
crate fn resolve_ident_in_module(
|
||||
pub(crate) fn resolve_ident_in_module(
|
||||
&mut self,
|
||||
module: ModuleOrUniformRoot<'a>,
|
||||
ident: Ident,
|
||||
|
@ -1303,7 +1303,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
crate fn maybe_resolve_path(
|
||||
pub(crate) fn maybe_resolve_path(
|
||||
&mut self,
|
||||
path: &[Segment],
|
||||
opt_ns: Option<Namespace>, // `None` indicates a module path in import
|
||||
|
@ -1313,7 +1313,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
crate fn resolve_path(
|
||||
pub(crate) fn resolve_path(
|
||||
&mut self,
|
||||
path: &[Segment],
|
||||
opt_ns: Option<Namespace>, // `None` indicates a module path in import
|
||||
|
@ -1324,7 +1324,7 @@ impl<'a> Resolver<'a> {
|
|||
self.resolve_path_with_ribs(path, opt_ns, parent_scope, finalize, None, ignore_binding)
|
||||
}
|
||||
|
||||
crate fn resolve_path_with_ribs(
|
||||
pub(crate) fn resolve_path_with_ribs(
|
||||
&mut self,
|
||||
path: &[Segment],
|
||||
opt_ns: Option<Namespace>, // `None` indicates a module path in import
|
||||
|
|
|
@ -64,7 +64,7 @@ pub enum ImportKind<'a> {
|
|||
|
||||
/// One import.
|
||||
#[derive(Debug, Clone)]
|
||||
crate struct Import<'a> {
|
||||
pub(crate) struct Import<'a> {
|
||||
pub kind: ImportKind<'a>,
|
||||
|
||||
/// The ID of the `extern crate`, `UseTree` etc that imported this `Import`.
|
||||
|
@ -125,7 +125,7 @@ impl<'a> Import<'a> {
|
|||
|
||||
/// Records information about the resolution of a name in a namespace of a module.
|
||||
#[derive(Clone, Default, Debug)]
|
||||
crate struct NameResolution<'a> {
|
||||
pub(crate) struct NameResolution<'a> {
|
||||
/// Single imports that may define the name in the namespace.
|
||||
/// Imports are arena-allocated, so it's ok to use pointers as keys.
|
||||
pub single_imports: FxHashSet<Interned<'a, Import<'a>>>,
|
||||
|
@ -146,7 +146,7 @@ impl<'a> NameResolution<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
crate fn add_single_import(&mut self, import: &'a Import<'a>) {
|
||||
pub(crate) fn add_single_import(&mut self, import: &'a Import<'a>) {
|
||||
self.single_imports.insert(Interned::new_unchecked(import));
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ fn pub_use_of_private_extern_crate_hack(import: &Import<'_>, binding: &NameBindi
|
|||
impl<'a> Resolver<'a> {
|
||||
// Given a binding and an import that resolves to it,
|
||||
// return the corresponding binding defined by the import.
|
||||
crate fn import(
|
||||
pub(crate) fn import(
|
||||
&self,
|
||||
binding: &'a NameBinding<'a>,
|
||||
import: &'a Import<'a>,
|
||||
|
@ -198,7 +198,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
|
||||
// Define the name or return the existing binding if there is a collision.
|
||||
crate fn try_define(
|
||||
pub(crate) fn try_define(
|
||||
&mut self,
|
||||
module: Module<'a>,
|
||||
key: BindingKey,
|
||||
|
|
|
@ -37,7 +37,7 @@ use std::mem::{replace, take};
|
|||
use tracing::debug;
|
||||
|
||||
mod diagnostics;
|
||||
crate mod lifetimes;
|
||||
pub(crate) mod lifetimes;
|
||||
|
||||
type Res = def::Res<NodeId>;
|
||||
|
||||
|
@ -90,7 +90,7 @@ enum PatBoundCtx {
|
|||
|
||||
/// Does this the item (from the item rib scope) allow generic parameters?
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
crate enum HasGenericParams {
|
||||
pub(crate) enum HasGenericParams {
|
||||
Yes,
|
||||
No,
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ impl HasGenericParams {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
crate enum ConstantItemKind {
|
||||
pub(crate) enum ConstantItemKind {
|
||||
Const,
|
||||
Static,
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ crate enum ConstantItemKind {
|
|||
/// The rib kind restricts certain accesses,
|
||||
/// e.g. to a `Res::Local` of an outer item.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
crate enum RibKind<'a> {
|
||||
pub(crate) enum RibKind<'a> {
|
||||
/// No restriction needs to be applied.
|
||||
NormalRibKind,
|
||||
|
||||
|
@ -159,7 +159,7 @@ crate enum RibKind<'a> {
|
|||
impl RibKind<'_> {
|
||||
/// Whether this rib kind contains generic parameters, as opposed to local
|
||||
/// variables.
|
||||
crate fn contains_params(&self) -> bool {
|
||||
pub(crate) fn contains_params(&self) -> bool {
|
||||
match self {
|
||||
NormalRibKind
|
||||
| ClosureOrAsyncRibKind
|
||||
|
@ -187,7 +187,7 @@ impl RibKind<'_> {
|
|||
/// The resolution keeps a separate stack of ribs as it traverses the AST for each namespace. When
|
||||
/// resolving, the name is looked up from inside out.
|
||||
#[derive(Debug)]
|
||||
crate struct Rib<'a, R = Res> {
|
||||
pub(crate) struct Rib<'a, R = Res> {
|
||||
pub bindings: IdentMap<R>,
|
||||
pub kind: RibKind<'a>,
|
||||
}
|
||||
|
@ -278,13 +278,13 @@ impl LifetimeRib {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
crate enum AliasPossibility {
|
||||
pub(crate) enum AliasPossibility {
|
||||
No,
|
||||
Maybe,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
crate enum PathSource<'a> {
|
||||
pub(crate) enum PathSource<'a> {
|
||||
// Type paths `Path`.
|
||||
Type,
|
||||
// Trait paths in bounds or impls.
|
||||
|
@ -366,7 +366,7 @@ impl<'a> PathSource<'a> {
|
|||
matches!(self, PathSource::Expr(Some(&Expr { kind: ExprKind::Call(..), .. })))
|
||||
}
|
||||
|
||||
crate fn is_expected(self, res: Res) -> bool {
|
||||
pub(crate) fn is_expected(self, res: Res) -> bool {
|
||||
match self {
|
||||
PathSource::Type => matches!(
|
||||
res,
|
||||
|
|
|
@ -59,13 +59,13 @@ impl AssocSuggestion {
|
|||
}
|
||||
}
|
||||
|
||||
crate enum MissingLifetimeSpot<'tcx> {
|
||||
pub(crate) enum MissingLifetimeSpot<'tcx> {
|
||||
Generics(&'tcx hir::Generics<'tcx>),
|
||||
HigherRanked { span: Span, span_type: ForLifetimeSpanType },
|
||||
Static,
|
||||
}
|
||||
|
||||
crate enum ForLifetimeSpanType {
|
||||
pub(crate) enum ForLifetimeSpanType {
|
||||
BoundEmpty,
|
||||
BoundTail,
|
||||
TypeEmpty,
|
||||
|
@ -73,14 +73,14 @@ crate enum ForLifetimeSpanType {
|
|||
}
|
||||
|
||||
impl ForLifetimeSpanType {
|
||||
crate fn descr(&self) -> &'static str {
|
||||
pub(crate) fn descr(&self) -> &'static str {
|
||||
match self {
|
||||
Self::BoundEmpty | Self::BoundTail => "bound",
|
||||
Self::TypeEmpty | Self::TypeTail => "type",
|
||||
}
|
||||
}
|
||||
|
||||
crate fn suggestion(&self, sugg: &str) -> String {
|
||||
pub(crate) fn suggestion(&self, sugg: &str) -> String {
|
||||
match self {
|
||||
Self::BoundEmpty | Self::TypeEmpty => format!("for<{}> ", sugg),
|
||||
Self::BoundTail | Self::TypeTail => format!(", {}", sugg),
|
||||
|
@ -1221,7 +1221,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
|
||||
/// Given the target `ident` and `kind`, search for the similarly named associated item
|
||||
/// in `self.current_trait_ref`.
|
||||
crate fn find_similarly_named_assoc_item(
|
||||
pub(crate) fn find_similarly_named_assoc_item(
|
||||
&mut self,
|
||||
ident: Symbol,
|
||||
kind: &AssocItemKind,
|
||||
|
@ -1729,7 +1729,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn report_missing_type_error(
|
||||
pub(crate) fn report_missing_type_error(
|
||||
&self,
|
||||
path: &[Segment],
|
||||
) -> Option<(Span, &'static str, String, Applicability)> {
|
||||
|
@ -1809,7 +1809,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
|
||||
/// Given the target `label`, search the `rib_index`th label rib for similarly named labels,
|
||||
/// optionally returning the closest match and whether it is reachable.
|
||||
crate fn suggestion_for_label_in_rib(
|
||||
pub(crate) fn suggestion_for_label_in_rib(
|
||||
&self,
|
||||
rib_index: usize,
|
||||
label: Ident,
|
||||
|
@ -1834,7 +1834,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
})
|
||||
}
|
||||
|
||||
crate fn maybe_report_lifetime_uses(
|
||||
pub(crate) fn maybe_report_lifetime_uses(
|
||||
&mut self,
|
||||
generics_span: Span,
|
||||
params: &[ast::GenericParam],
|
||||
|
@ -1904,7 +1904,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn emit_undeclared_lifetime_error(
|
||||
pub(crate) fn emit_undeclared_lifetime_error(
|
||||
&self,
|
||||
lifetime_ref: &ast::Lifetime,
|
||||
outer_lifetime_ref: Option<Ident>,
|
||||
|
@ -2000,7 +2000,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
err.emit();
|
||||
}
|
||||
|
||||
crate fn emit_non_static_lt_in_const_generic_error(&self, lifetime_ref: &ast::Lifetime) {
|
||||
pub(crate) fn emit_non_static_lt_in_const_generic_error(&self, lifetime_ref: &ast::Lifetime) {
|
||||
struct_span_err!(
|
||||
self.r.session,
|
||||
lifetime_ref.ident.span,
|
||||
|
@ -2018,7 +2018,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
|
||||
/// This function will emit an error if `generic_const_exprs` is not enabled, the body identified by
|
||||
/// `body_id` is an anonymous constant and `lifetime_ref` is non-static.
|
||||
crate fn maybe_emit_forbidden_non_static_lifetime_error(&self, lifetime_ref: &ast::Lifetime) {
|
||||
pub(crate) fn maybe_emit_forbidden_non_static_lifetime_error(
|
||||
&self,
|
||||
lifetime_ref: &ast::Lifetime,
|
||||
) {
|
||||
let feature_active = self.r.session.features_untracked().generic_const_exprs;
|
||||
if !feature_active {
|
||||
feature_err(
|
||||
|
@ -2033,7 +2036,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
}
|
||||
|
||||
impl<'tcx> LifetimeContext<'_, 'tcx> {
|
||||
crate fn report_missing_lifetime_specifiers(
|
||||
pub(crate) fn report_missing_lifetime_specifiers(
|
||||
&self,
|
||||
spans: Vec<Span>,
|
||||
count: usize,
|
||||
|
@ -2048,7 +2051,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
}
|
||||
|
||||
/// Returns whether to add `'static` lifetime to the suggested lifetime list.
|
||||
crate fn report_elision_failure(
|
||||
pub(crate) fn report_elision_failure(
|
||||
&mut self,
|
||||
diag: &mut Diagnostic,
|
||||
params: &[ElisionFailureInfo],
|
||||
|
@ -2126,7 +2129,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn is_trait_ref_fn_scope(&mut self, trait_ref: &'tcx hir::PolyTraitRef<'tcx>) -> bool {
|
||||
pub(crate) fn is_trait_ref_fn_scope(
|
||||
&mut self,
|
||||
trait_ref: &'tcx hir::PolyTraitRef<'tcx>,
|
||||
) -> bool {
|
||||
if let def::Res::Def(_, did) = trait_ref.trait_ref.path.res {
|
||||
if [
|
||||
self.tcx.lang_items().fn_once_trait(),
|
||||
|
@ -2147,7 +2153,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
false
|
||||
}
|
||||
|
||||
crate fn add_missing_lifetime_specifiers_label(
|
||||
pub(crate) fn add_missing_lifetime_specifiers_label(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
mut spans_with_counts: Vec<(Span, usize)>,
|
||||
|
|
|
@ -151,8 +151,8 @@ struct NamedRegionMap {
|
|||
scope_for_path: Option<FxHashMap<LocalDefId, FxHashMap<ItemLocalId, LifetimeScopeForPath>>>,
|
||||
}
|
||||
|
||||
crate struct LifetimeContext<'a, 'tcx> {
|
||||
crate tcx: TyCtxt<'tcx>,
|
||||
pub(crate) struct LifetimeContext<'a, 'tcx> {
|
||||
pub(crate) tcx: TyCtxt<'tcx>,
|
||||
map: &'a mut NamedRegionMap,
|
||||
scope: ScopeRef<'a>,
|
||||
|
||||
|
@ -169,7 +169,7 @@ crate struct LifetimeContext<'a, 'tcx> {
|
|||
|
||||
/// When encountering an undefined named lifetime, we will suggest introducing it in these
|
||||
/// places.
|
||||
crate missing_named_lifetime_spots: Vec<MissingLifetimeSpot<'tcx>>,
|
||||
pub(crate) missing_named_lifetime_spots: Vec<MissingLifetimeSpot<'tcx>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -335,14 +335,14 @@ enum Elide {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
crate struct ElisionFailureInfo {
|
||||
pub(crate) struct ElisionFailureInfo {
|
||||
/// Where we can find the argument pattern.
|
||||
crate parent: Option<hir::BodyId>,
|
||||
pub(crate) parent: Option<hir::BodyId>,
|
||||
/// The index of the argument in the original definition.
|
||||
crate index: usize,
|
||||
crate lifetime_count: usize,
|
||||
crate have_bound_regions: bool,
|
||||
crate span: Span,
|
||||
pub(crate) index: usize,
|
||||
pub(crate) lifetime_count: usize,
|
||||
pub(crate) have_bound_regions: bool,
|
||||
pub(crate) span: Span,
|
||||
}
|
||||
|
||||
type ScopeRef<'a> = &'a Scope<'a>;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(let_else)]
|
||||
|
|
|
@ -41,10 +41,10 @@ type Res = def::Res<NodeId>;
|
|||
/// Not modularized, can shadow previous `macro_rules` bindings, etc.
|
||||
#[derive(Debug)]
|
||||
pub struct MacroRulesBinding<'a> {
|
||||
crate binding: &'a NameBinding<'a>,
|
||||
pub(crate) binding: &'a NameBinding<'a>,
|
||||
/// `macro_rules` scope into which the `macro_rules` item was planted.
|
||||
crate parent_macro_rules_scope: MacroRulesScopeRef<'a>,
|
||||
crate ident: Ident,
|
||||
pub(crate) parent_macro_rules_scope: MacroRulesScopeRef<'a>,
|
||||
pub(crate) ident: Ident,
|
||||
}
|
||||
|
||||
/// The scope introduced by a `macro_rules!` macro.
|
||||
|
@ -74,7 +74,10 @@ pub(crate) type MacroRulesScopeRef<'a> = Interned<'a, Cell<MacroRulesScope<'a>>>
|
|||
/// Macro namespace is separated into two sub-namespaces, one for bang macros and
|
||||
/// one for attribute-like macros (attributes, derives).
|
||||
/// We ignore resolutions from one sub-namespace when searching names in scope for another.
|
||||
crate fn sub_namespace_match(candidate: Option<MacroKind>, requirement: Option<MacroKind>) -> bool {
|
||||
pub(crate) fn sub_namespace_match(
|
||||
candidate: Option<MacroKind>,
|
||||
requirement: Option<MacroKind>,
|
||||
) -> bool {
|
||||
#[derive(PartialEq)]
|
||||
enum SubNS {
|
||||
Bang,
|
||||
|
@ -140,7 +143,7 @@ fn registered_idents(
|
|||
registered
|
||||
}
|
||||
|
||||
crate fn registered_attrs_and_tools(
|
||||
pub(crate) fn registered_attrs_and_tools(
|
||||
sess: &Session,
|
||||
attrs: &[ast::Attribute],
|
||||
) -> (FxHashSet<Ident>, FxHashSet<Ident>) {
|
||||
|
@ -651,7 +654,7 @@ impl<'a> Resolver<'a> {
|
|||
res.map(|res| (self.get_macro(res), res))
|
||||
}
|
||||
|
||||
crate fn finalize_macro_resolutions(&mut self) {
|
||||
pub(crate) fn finalize_macro_resolutions(&mut self) {
|
||||
let check_consistency = |this: &mut Self,
|
||||
path: &[Segment],
|
||||
span,
|
||||
|
@ -839,7 +842,7 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn check_reserved_macro_name(&mut self, ident: Ident, res: Res) {
|
||||
pub(crate) fn check_reserved_macro_name(&mut self, ident: Ident, res: Res) {
|
||||
// Reserve some names that are not quite covered by the general check
|
||||
// performed on `Resolver::builtin_attrs`.
|
||||
if ident.name == sym::cfg || ident.name == sym::cfg_attr {
|
||||
|
@ -856,7 +859,7 @@ impl<'a> Resolver<'a> {
|
|||
/// Compile the macro into a `SyntaxExtension` and its rule spans.
|
||||
///
|
||||
/// Possibly replace its expander to a pre-defined one for built-in macros.
|
||||
crate fn compile_macro(
|
||||
pub(crate) fn compile_macro(
|
||||
&mut self,
|
||||
item: &ast::Item,
|
||||
edition: Edition,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue