diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-08 12:52:52 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-08 12:52:52 +1000 |
| commit | ecce94c0a5d2ca0e4ac6f63bf5fa0d1b78259f5d (patch) | |
| tree | c657a613b5b60ff7d3c5332fd60a6146e12cce5c /compiler/rustc_resolve/src/late/diagnostics.rs | |
| parent | 3f941010890e156043cc000ef2d9fbc22ee2b234 (diff) | |
| parent | 487e5ce371cc9e77187719829bb3b058638cb8a3 (diff) | |
| download | rust-ecce94c0a5d2ca0e4ac6f63bf5fa0d1b78259f5d.tar.gz rust-ecce94c0a5d2ca0e4ac6f63bf5fa0d1b78259f5d.zip | |
Rollup merge of #144912 - LorrensP-2158466:smart-resolver, r=petrochenkov
Resolver: introduce a conditionally mutable Resolver for (non-)speculative resolution.
This pr introduces a `CmResolver`, a wrapper around the main resolver which gives out mutable access given a condition.
`CmResolver` only allows mutation when we’re not in speculative import resolution. This ensures we can’t accidentally mutate the resolver during this process, which is important as we move towards a batched resolution algorithm.
This also changes functions that are used during speculative import resolution to take a `CmResolver` instead of a `&mut Resolver`.
Also introduces a new kind of "smart pointer" which has the behaviour described above:
```rust
/// A wrapper around a mutable reference that conditionally allows mutable access.
pub(crate) struct RefOrMut<'a, T> {
p: &'a mut T,
mutable: bool,
}
type CmResolver<'r, 'ra, 'tcx> = RefOrMut<'r, Resolver<'ra, 'tcx>>;
```
r? petrochenkov
Diffstat (limited to 'compiler/rustc_resolve/src/late/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 165a0eb63f6..19cd45294eb 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2389,7 +2389,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { // Look for associated items in the current trait. if let Some((module, _)) = self.current_trait_ref - && let Ok(binding) = self.r.maybe_resolve_ident_in_module( + && let Ok(binding) = self.r.cm().maybe_resolve_ident_in_module( ModuleOrUniformRoot::Module(module), ident, ns, |
