Remove scope parameter from ModuleResolver::resolve.
This commit is contained in:
parent
348c3edc76
commit
ffe0c559be
@ -4,6 +4,11 @@ Rhai Release Notes
|
|||||||
Version 0.15.2
|
Version 0.15.2
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
Breaking changes
|
||||||
|
----------------
|
||||||
|
|
||||||
|
* The trait function `ModuleResolver::resolve` no longer takes a `Scope` as argument.
|
||||||
|
|
||||||
|
|
||||||
Version 0.15.1
|
Version 0.15.1
|
||||||
==============
|
==============
|
||||||
|
@ -2081,10 +2081,7 @@ impl Engine {
|
|||||||
#[cfg(not(feature = "no_module"))]
|
#[cfg(not(feature = "no_module"))]
|
||||||
{
|
{
|
||||||
if let Some(resolver) = &self.module_resolver {
|
if let Some(resolver) = &self.module_resolver {
|
||||||
// Use an empty scope to create a module
|
let module = resolver.resolve(self, &path, expr.position())?;
|
||||||
let module =
|
|
||||||
resolver.resolve(self, Scope::new(), &path, expr.position())?;
|
|
||||||
|
|
||||||
let mod_name = unsafe_cast_var_name_to_lifetime(name, &state);
|
let mod_name = unsafe_cast_var_name_to_lifetime(name, &state);
|
||||||
scope.push_module_internal(mod_name, module);
|
scope.push_module_internal(mod_name, module);
|
||||||
|
|
||||||
|
@ -1031,13 +1031,7 @@ impl ModuleRef {
|
|||||||
/// Trait that encapsulates a module resolution service.
|
/// Trait that encapsulates a module resolution service.
|
||||||
pub trait ModuleResolver: SendSync {
|
pub trait ModuleResolver: SendSync {
|
||||||
/// Resolve a module based on a path string.
|
/// Resolve a module based on a path string.
|
||||||
fn resolve(
|
fn resolve(&self, _: &Engine, path: &str, pos: Position) -> Result<Module, Box<EvalAltResult>>;
|
||||||
&self,
|
|
||||||
_: &Engine,
|
|
||||||
scope: Scope,
|
|
||||||
path: &str,
|
|
||||||
pos: Position,
|
|
||||||
) -> Result<Module, Box<EvalAltResult>>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Re-export module resolvers.
|
/// Re-export module resolvers.
|
||||||
@ -1161,10 +1155,9 @@ mod file {
|
|||||||
pub fn create_module<P: Into<PathBuf>>(
|
pub fn create_module<P: Into<PathBuf>>(
|
||||||
&self,
|
&self,
|
||||||
engine: &Engine,
|
engine: &Engine,
|
||||||
scope: Scope,
|
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> Result<Module, Box<EvalAltResult>> {
|
) -> Result<Module, Box<EvalAltResult>> {
|
||||||
self.resolve(engine, scope, path, Default::default())
|
self.resolve(engine, path, Default::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,7 +1165,6 @@ mod file {
|
|||||||
fn resolve(
|
fn resolve(
|
||||||
&self,
|
&self,
|
||||||
engine: &Engine,
|
engine: &Engine,
|
||||||
scope: Scope,
|
|
||||||
path: &str,
|
path: &str,
|
||||||
pos: Position,
|
pos: Position,
|
||||||
) -> Result<Module, Box<EvalAltResult>> {
|
) -> Result<Module, Box<EvalAltResult>> {
|
||||||
@ -1186,7 +1178,7 @@ mod file {
|
|||||||
.compile_file(file_path)
|
.compile_file(file_path)
|
||||||
.map_err(|err| err.new_position(pos))?;
|
.map_err(|err| err.new_position(pos))?;
|
||||||
|
|
||||||
Module::eval_ast_as_new(scope, &ast, engine).map_err(|err| err.new_position(pos))
|
Module::eval_ast_as_new(Scope::new(), &ast, engine).map_err(|err| err.new_position(pos))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1258,7 +1250,6 @@ mod stat {
|
|||||||
fn resolve(
|
fn resolve(
|
||||||
&self,
|
&self,
|
||||||
_: &Engine,
|
_: &Engine,
|
||||||
_: Scope,
|
|
||||||
path: &str,
|
path: &str,
|
||||||
pos: Position,
|
pos: Position,
|
||||||
) -> Result<Module, Box<EvalAltResult>> {
|
) -> Result<Module, Box<EvalAltResult>> {
|
||||||
|
Loading…
Reference in New Issue
Block a user