Skip to content

Commit

Permalink
[red-knot] Use a distinct type for module search paths in the module …
Browse files Browse the repository at this point in the history
…resolver
  • Loading branch information
AlexWaygood committed Jul 18, 2024
1 parent 2e77b77 commit e6067be
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 182 deletions.
4 changes: 2 additions & 2 deletions crates/red_knot_module_resolver/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use ruff_db::Upcast;

use crate::resolver::{
editable_install_resolution_paths, file_to_module, internal::ModuleNameIngredient,
module_resolution_settings, resolve_module_query,
resolve_module_query, resolve_module_resolution_settings,
};
use crate::typeshed::parse_typeshed_versions;

#[salsa::jar(db=Db)]
pub struct Jar(
ModuleNameIngredient<'_>,
module_resolution_settings,
resolve_module_resolution_settings,
editable_install_resolution_paths,
resolve_module_query,
file_to_module,
Expand Down
1 change: 1 addition & 0 deletions crates/red_knot_module_resolver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod testing;
pub use db::{Db, Jar};
pub use module::{Module, ModuleKind};
pub use module_name::ModuleName;
pub use path::SearchPathValidationError;
pub use resolver::resolve_module;
pub use typeshed::{
vendored_typeshed_stubs, TypeshedVersionsParseError, TypeshedVersionsParseErrorKind,
Expand Down
10 changes: 5 additions & 5 deletions crates/red_knot_module_resolver/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ruff_db::files::File;

use crate::db::Db;
use crate::module_name::ModuleName;
use crate::path::{ModuleResolutionPathBuf, ModuleResolutionPathRef};
use crate::path::ModuleSearchPath;

/// Representation of a Python module.
#[derive(Clone, PartialEq, Eq)]
Expand All @@ -17,7 +17,7 @@ impl Module {
pub(crate) fn new(
name: ModuleName,
kind: ModuleKind,
search_path: Arc<ModuleResolutionPathBuf>,
search_path: ModuleSearchPath,
file: File,
) -> Self {
Self {
Expand All @@ -41,8 +41,8 @@ impl Module {
}

/// The search path from which the module was resolved.
pub(crate) fn search_path(&self) -> ModuleResolutionPathRef {
ModuleResolutionPathRef::from(&*self.inner.search_path)
pub(crate) fn search_path(&self) -> &ModuleSearchPath {
&self.inner.search_path
}

/// Determine whether this module is a single-file module or a package
Expand Down Expand Up @@ -77,7 +77,7 @@ impl salsa::DebugWithDb<dyn Db> for Module {
struct ModuleInner {
name: ModuleName,
kind: ModuleKind,
search_path: Arc<ModuleResolutionPathBuf>,
search_path: ModuleSearchPath,
file: File,
}

Expand Down
Loading

0 comments on commit e6067be

Please sign in to comment.