Skip to main content

file_to_module

Function file_to_module 

Source
pub fn file_to_module<'db>(
    db: &'db dyn Db,
    resolver_file: ResolverFile<'db>,
) -> Option<Module<'db>>
Expand description

Resolves the module for the file with the given id.

Returns None if the file is not a module locatable via any of the known search paths.

This function can be understood as essentially resolving import .<self> in the file itself, and indeed, one of its primary jobs is resolving .<self> to derive the module name of .. This intuition is particularly useful for understanding why it’s correct that we pass the file itself as importing_file to various subroutines.