From 4f8dc1b9f0fd544b0565dc95bb3f14478aa467bf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 13 Apr 2019 11:06:53 +0300 Subject: make expr scope stuff private --- crates/ra_hir/src/expr/scope.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 476385a2f..4ac797eb7 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use rustc_hash::{FxHashMap}; use ra_syntax::{ TextRange, AstPtr, - algo::generate, ast, }; use ra_arena::{Arena, RawId, impl_arena_id}; @@ -26,13 +25,13 @@ pub struct ExprScopes { } #[derive(Debug, PartialEq, Eq)] -pub struct ScopeEntry { +pub(crate) struct ScopeEntry { name: Name, pat: PatId, } #[derive(Debug, PartialEq, Eq)] -pub struct ScopeData { +pub(crate) struct ScopeData { parent: Option, entries: Vec, } @@ -57,16 +56,15 @@ impl ExprScopes { scopes } - pub fn body(&self) -> Arc { - self.body.clone() - } - - pub fn entries(&self, scope: ScopeId) -> &[ScopeEntry] { + pub(crate) fn entries(&self, scope: ScopeId) -> &[ScopeEntry] { &self.scopes[scope].entries } - pub fn scope_chain<'a>(&'a self, scope: Option) -> impl Iterator + 'a { - generate(scope, move |&scope| self.scopes[scope].parent) + pub(crate) fn scope_chain<'a>( + &'a self, + scope: Option, + ) -> impl Iterator + 'a { + std::iter::successors(scope, move |&scope| self.scopes[scope].parent) } fn root_scope(&mut self) -> ScopeId { @@ -98,7 +96,7 @@ impl ExprScopes { self.scope_for.insert(node, scope); } - pub fn scope_for(&self, expr: ExprId) -> Option { + pub(crate) fn scope_for(&self, expr: ExprId) -> Option { self.scope_for.get(&expr).map(|&scope| scope) } } -- cgit v1.2.3