Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
res,
))
};
match self.cm().resolve_path(
match self.cm_mut().resolve_path(
&segments,
None,
parent_scope,
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_resolve/src/diagnostics/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,15 +782,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// This takes the error provided, combines it with the span and any additional spans inside the
/// error and emits it.
pub(crate) fn report_error(
&mut self,
&self,
span: Span,
resolution_error: ResolutionError<'ra>,
) -> ErrorGuaranteed {
self.into_struct_error(span, resolution_error).emit()
}

pub(crate) fn into_struct_error(
&mut self,
&self,
span: Span,
resolution_error: ResolutionError<'ra>,
) -> Diag<'_> {
Expand Down Expand Up @@ -1459,7 +1459,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}

pub(crate) fn add_scope_set_candidates(
&mut self,
&self,
suggestions: &mut Vec<TypoSuggestion>,
scope_set: ScopeSet<'ra>,
ps: &ParentScope<'ra>,
Expand Down Expand Up @@ -1560,7 +1560,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

/// Lookup typo candidate in scope for a macro or import.
fn early_lookup_typo_candidate(
&mut self,
&self,
scope_set: ScopeSet<'ra>,
parent_scope: &ParentScope<'ra>,
ident: Ident,
Expand Down Expand Up @@ -1828,7 +1828,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// 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).
pub(crate) fn lookup_import_candidates<FilterFn>(
&mut self,
&self,
lookup_ident: Ident,
namespace: Namespace,
parent_scope: &ParentScope<'ra>,
Expand Down Expand Up @@ -3310,7 +3310,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// ```
#[instrument(level = "debug", skip(self, parent_scope))]
fn make_missing_self_suggestion(
&mut self,
&self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)> {
Expand All @@ -3330,7 +3330,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// ```
#[instrument(level = "debug", skip(self, parent_scope))]
fn make_missing_crate_suggestion(
&mut self,
&self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)> {
Expand Down Expand Up @@ -3362,7 +3362,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// ```
#[instrument(level = "debug", skip(self, parent_scope))]
fn make_missing_super_suggestion(
&mut self,
&self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)> {
Expand All @@ -3385,7 +3385,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// name as the first part of path.
#[instrument(level = "debug", skip(self, parent_scope))]
fn make_external_crate_suggestion(
&mut self,
&self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'ra>,
) -> Option<(Vec<Segment>, Option<String>)> {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
diag_metadata,
)));
} else if let RibKind::Block(Some(module)) = rib.kind
&& let Ok(binding) = self.cm().resolve_ident_in_scope_set(
&& let Ok(binding) = self.cm_mut().resolve_ident_in_scope_set(
ident,
ScopeSet::Module(ns, module.to_module()),
parent_scope,
Expand All @@ -362,7 +362,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let parent_scope = &ParentScope { module: module.to_module(), ..*parent_scope };
let finalize = finalize.map(|f| Finalize { stage: Stage::Late, ..f });
return self
.cm()
.cm_mut()
.resolve_ident_in_scope_set(
orig_ident,
ScopeSet::All(ns),
Expand Down Expand Up @@ -1457,7 +1457,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// Validate a local resolution (from ribs).
#[instrument(level = "debug", skip(self, all_ribs))]
fn validate_res_from_ribs(
&mut self,
&self,
rib_index: usize,
rib_ident: Ident,
res: Res,
Expand Down
52 changes: 21 additions & 31 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ use crate::diagnostics::{
};
use crate::ref_mut::{CmCell, CmRefCell};
use crate::{
AmbiguityError, BindingKey, CmResolver, Decl, DeclData, DeclKind, Determinacy, Finalize,
IdentKey, ImportSuggestion, ImportSummary, LocalModule, ModuleOrUniformRoot, ParentScope,
PathResult, PerNS, Res, ResolutionError, Resolver, ScopeSet, Segment, Used, module_to_string,
AmbiguityError, BindingKey, Decl, DeclData, DeclKind, Determinacy, Finalize, IdentKey,
ImportSuggestion, ImportSummary, LocalModule, ModuleOrUniformRoot, ParentScope, PathResult,
PerNS, Res, ResolutionError, Resolver, ScopeSet, Segment, Used, module_to_string,
names_to_string,
};

Expand Down Expand Up @@ -735,7 +735,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
let dummy_decl = self.dummy_decl;
let dummy_decl = self.new_import_decl(dummy_decl, import);
self.per_ns(|this, ns| {
self.per_ns_mut(|this, ns| {
let ident = IdentKey::new(target);
// This can fail, dummies are inserted only in non-occupied slots.
let _ = this.try_plant_decl_into_local_module(ident, target.span, ns, dummy_decl);
Expand Down Expand Up @@ -782,13 +782,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let mut imports_to_resolve = mem::take(&mut self.indeterminate_imports);

self.assert_speculative = true;
let cm_resolver = self.cm();

rustc_data_structures::sync::par_for_each_slice(
&mut imports_to_resolve,
|(import, resolution, indeterminate_count)| {
(*resolution, *indeterminate_count) =
cm_resolver.reborrow_ref().resolve_import(*import);
(*resolution, *indeterminate_count) = self.resolve_import(*import);
},
);
self.assert_speculative = false;
Expand Down Expand Up @@ -835,7 +832,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
ImportKind::Single { target, decls, .. },
ImportResolutionKind::Single(import_decls),
) => {
self.per_ns(|this, ns| {
self.per_ns_mut(|this, ns| {
match import_decls[ns] {
PendingDecl::Ready(Some(decl)) => {
// We need the `target`, `source` can be extracted.
Expand Down Expand Up @@ -1116,10 +1113,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// - Other values mean that indeterminate exists under certain namespaces.
///
/// Meanwhile, if resolution is successful, its result is returned.
fn resolve_import<'r>(
mut self: CmResolver<'r, 'ra, 'tcx>,
import: Import<'ra>,
) -> (Option<ImportResolution<'ra>>, usize) {
fn resolve_import(&self, import: Import<'ra>) -> (Option<ImportResolution<'ra>>, usize) {
debug!(
"(resolving import for module) resolving import `{}::{}` in `{}`",
Segment::names_to_string(&import.module_path),
Expand All @@ -1129,7 +1123,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let module = if let Some(module) = import.imported_module.get() {
module
} else {
let path_res = self.reborrow().maybe_resolve_path(
let path_res = self.cm().maybe_resolve_path(
&import.module_path,
None,
&import.parent_scope,
Expand Down Expand Up @@ -1157,11 +1151,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

let mut decls = PerNS::default();
let mut indeterminate_count = 0;
self.per_ns_cm(|mut this, ns| {
self.per_ns(|this, ns| {
if bindings[ns].get() != PendingDecl::Pending {
return;
};
let binding_result = this.reborrow().maybe_resolve_ident_in_module(
let binding_result = this.cm().maybe_resolve_ident_in_module(
module,
source,
ns,
Expand Down Expand Up @@ -1202,7 +1196,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// We'll provide more context to the privacy errors later, up to `len`.
let privacy_errors_len = self.privacy_errors.len();

let path_res = self.cm().resolve_path(
let path_res = self.cm_mut().resolve_path(
&import.module_path,
None,
&import.parent_scope,
Expand Down Expand Up @@ -1370,14 +1364,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// importing it if available.
let mut path = import.module_path.clone();
path.push(Segment::from_ident(ident));
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.cm().resolve_path(
&path,
None,
&import.parent_scope,
Some(finalize),
ignore_decl,
None,
) {
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self
.cm_mut()
.resolve_path(&path, None, &import.parent_scope, Some(finalize), ignore_decl, None)
{
let res = module.res().map(|r| (r, ident));
for error in &mut self.privacy_errors[privacy_errors_len..] {
error.outermost_res = res;
Expand Down Expand Up @@ -1407,8 +1397,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}

let mut all_ns_err = true;
self.per_ns(|this, ns| {
let binding = this.cm().resolve_ident_in_module(
self.per_ns_mut(|this, ns| {
let binding = this.cm_mut().resolve_ident_in_module(
module,
ident,
ns,
Expand Down Expand Up @@ -1472,8 +1462,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

if all_ns_err {
let mut all_ns_failed = true;
self.per_ns(|this, ns| {
let binding = this.cm().resolve_ident_in_module(
self.per_ns_mut(|this, ns| {
let binding = this.cm_mut().resolve_ident_in_module(
module,
ident,
ns,
Expand Down Expand Up @@ -1632,7 +1622,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// 2 segments, so the `resolve_path` above won't trigger it.
let mut full_path = import.module_path.clone();
full_path.push(Segment::from_ident(ident));
self.per_ns(|this, ns| {
self.per_ns_mut(|this, ns| {
if let Some(binding) = bindings[ns].get().decl().map(|b| b.import_source()) {
this.lint_if_path_starts_with_module(finalize, &full_path, Some(binding));
}
Expand All @@ -1642,7 +1632,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// Record what this import resolves to for later uses in documentation,
// this may resolve to either a value or a type, but for documentation
// purposes it's good enough to just favor one over the other.
self.per_ns(|this, ns| {
self.per_ns_mut(|this, ns| {
if let Some(binding) = bindings[ns].get().decl().map(|b| b.import_source()) {
this.owners.get_mut(&import_id).unwrap().import_res[ns] = Some(binding.res());
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
finalize: Option<Finalize>,
source: PathSource<'_, 'ast, 'ra>,
) -> PathResult<'ra> {
self.r.cm().resolve_path_with_ribs(
self.r.cm_mut().resolve_path_with_ribs(
path,
opt_ns,
&self.parent_scope,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
}

fn update_err_for_private_tuple_struct_fields(
&mut self,
&self,
err: &mut Diag<'_>,
source: &PathSource<'_, '_, '_>,
def_id: DefId,
Expand Down Expand Up @@ -2177,7 +2177,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
}
};

let bad_struct_syntax_suggestion = |this: &mut Self, err: &mut Diag<'_>, def_id: DefId| {
let bad_struct_syntax_suggestion = |this: &Self, err: &mut Diag<'_>, def_id: DefId| {
let (followed_by_brace, closing_brace) = this.followed_by_brace(span);

match source {
Expand Down Expand Up @@ -2629,7 +2629,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
}

fn suggest_alternative_construction_methods(
&mut self,
&self,
def_id: DefId,
err: &mut Diag<'_>,
path_span: Span,
Expand Down Expand Up @@ -2784,7 +2784,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
}

fn lookup_assoc_candidate<FilterFn>(
&mut self,
&self,
ident: Ident,
ns: Namespace,
filter_fn: FilterFn,
Expand Down
Loading
Loading