mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Remove mutability in ResolverAstLowering.
This commit is contained in:
parent
ffaf6f0d0c
commit
b29fa94d22
@ -159,7 +159,7 @@ struct LoweringContext<'a, 'hir: 'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait ResolverAstLowering {
|
pub trait ResolverAstLowering {
|
||||||
fn def_key(&mut self, id: DefId) -> DefKey;
|
fn def_key(&self, id: DefId) -> DefKey;
|
||||||
|
|
||||||
fn def_span(&self, id: LocalDefId) -> Span;
|
fn def_span(&self, id: LocalDefId) -> Span;
|
||||||
|
|
||||||
@ -171,17 +171,15 @@ pub trait ResolverAstLowering {
|
|||||||
fn get_partial_res(&self, id: NodeId) -> Option<PartialRes>;
|
fn get_partial_res(&self, id: NodeId) -> Option<PartialRes>;
|
||||||
|
|
||||||
/// Obtains per-namespace resolutions for `use` statement with the given `NodeId`.
|
/// Obtains per-namespace resolutions for `use` statement with the given `NodeId`.
|
||||||
fn get_import_res(&mut self, id: NodeId) -> PerNS<Option<Res<NodeId>>>;
|
fn get_import_res(&self, id: NodeId) -> PerNS<Option<Res<NodeId>>>;
|
||||||
|
|
||||||
/// Obtains resolution for a label with the given `NodeId`.
|
/// Obtains resolution for a label with the given `NodeId`.
|
||||||
fn get_label_res(&mut self, id: NodeId) -> Option<NodeId>;
|
fn get_label_res(&self, id: NodeId) -> Option<NodeId>;
|
||||||
|
|
||||||
/// We must keep the set of definitions up to date as we add nodes that weren't in the AST.
|
|
||||||
/// This should only return `None` during testing.
|
|
||||||
fn definitions(&mut self) -> &mut Definitions;
|
|
||||||
|
|
||||||
fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
|
fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
|
||||||
|
|
||||||
|
fn definitions(&self) -> &Definitions;
|
||||||
|
|
||||||
fn lint_buffer(&mut self) -> &mut LintBuffer;
|
fn lint_buffer(&mut self) -> &mut LintBuffer;
|
||||||
|
|
||||||
fn next_node_id(&mut self) -> NodeId;
|
fn next_node_id(&mut self) -> NodeId;
|
||||||
|
@ -1160,9 +1160,9 @@ impl<'a, 'b> DefIdTree for &'a Resolver<'b> {
|
|||||||
/// This interface is used through the AST→HIR step, to embed full paths into the HIR. After that
|
/// This interface is used through the AST→HIR step, to embed full paths into the HIR. After that
|
||||||
/// the resolver is no longer needed as all the relevant information is inline.
|
/// the resolver is no longer needed as all the relevant information is inline.
|
||||||
impl ResolverAstLowering for Resolver<'_> {
|
impl ResolverAstLowering for Resolver<'_> {
|
||||||
fn def_key(&mut self, id: DefId) -> DefKey {
|
fn def_key(&self, id: DefId) -> DefKey {
|
||||||
if let Some(id) = id.as_local() {
|
if let Some(id) = id.as_local() {
|
||||||
self.definitions().def_key(id)
|
self.definitions.def_key(id)
|
||||||
} else {
|
} else {
|
||||||
self.cstore().def_key(id)
|
self.cstore().def_key(id)
|
||||||
}
|
}
|
||||||
@ -1189,22 +1189,22 @@ impl ResolverAstLowering for Resolver<'_> {
|
|||||||
self.partial_res_map.get(&id).cloned()
|
self.partial_res_map.get(&id).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_import_res(&mut self, id: NodeId) -> PerNS<Option<Res>> {
|
fn get_import_res(&self, id: NodeId) -> PerNS<Option<Res>> {
|
||||||
self.import_res_map.get(&id).cloned().unwrap_or_default()
|
self.import_res_map.get(&id).cloned().unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_label_res(&mut self, id: NodeId) -> Option<NodeId> {
|
fn get_label_res(&self, id: NodeId) -> Option<NodeId> {
|
||||||
self.label_res_map.get(&id).cloned()
|
self.label_res_map.get(&id).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn definitions(&mut self) -> &mut Definitions {
|
|
||||||
&mut self.definitions
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
|
fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
|
||||||
StableHashingContext::new(self.session, &self.definitions, self.crate_loader.cstore())
|
StableHashingContext::new(self.session, &self.definitions, self.crate_loader.cstore())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn definitions(&self) -> &Definitions {
|
||||||
|
&self.definitions
|
||||||
|
}
|
||||||
|
|
||||||
fn lint_buffer(&mut self) -> &mut LintBuffer {
|
fn lint_buffer(&mut self) -> &mut LintBuffer {
|
||||||
&mut self.lint_buffer
|
&mut self.lint_buffer
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user