Remove warnings.
This commit is contained in:
parent
61056dfb24
commit
835fa8afa3
@ -222,10 +222,10 @@ impl Engine {
|
|||||||
self.token_mapper.as_ref().map(<_>::as_ref),
|
self.token_mapper.as_ref().map(<_>::as_ref),
|
||||||
);
|
);
|
||||||
let mut state = ParseState::new(self, scope, tokenizer_control);
|
let mut state = ParseState::new(self, scope, tokenizer_control);
|
||||||
let mut ast = self.parse(&mut stream.peekable(), &mut state, optimization_level)?;
|
let mut _ast = self.parse(&mut stream.peekable(), &mut state, optimization_level)?;
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
ast.set_doc(state.tokenizer_control.borrow().global_comments.join("\n"));
|
_ast.set_doc(state.tokenizer_control.borrow().global_comments.join("\n"));
|
||||||
Ok(ast)
|
Ok(_ast)
|
||||||
}
|
}
|
||||||
/// Compile a string containing an expression into an [`AST`],
|
/// Compile a string containing an expression into an [`AST`],
|
||||||
/// which can be used later for evaluation.
|
/// which can be used later for evaluation.
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#![cfg(not(feature = "no_optimize"))]
|
#![cfg(not(feature = "no_optimize"))]
|
||||||
|
|
||||||
use crate::{Engine, OptimizationLevel, Scope, AST};
|
use crate::{Engine, OptimizationLevel, Scope, AST};
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
impl Engine {
|
impl Engine {
|
||||||
/// Control whether and how the [`Engine`] will optimize an [`AST`] after compilation.
|
/// Control whether and how the [`Engine`] will optimize an [`AST`] after compilation.
|
||||||
@ -60,7 +59,7 @@ impl Engine {
|
|||||||
.map(|f| f.func.get_script_fn_def().unwrap().clone())
|
.map(|f| f.func.get_script_fn_def().unwrap().clone())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut new_ast = crate::optimizer::optimize_into_ast(
|
let mut _new_ast = crate::optimizer::optimize_into_ast(
|
||||||
self,
|
self,
|
||||||
scope,
|
scope,
|
||||||
ast.take_statements(),
|
ast.take_statements(),
|
||||||
@ -70,8 +69,8 @@ impl Engine {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
new_ast.set_doc(mem::take(ast.doc_mut()));
|
_new_ast.set_doc(std::mem::take(ast.doc_mut()));
|
||||||
|
|
||||||
new_ast
|
_new_ast
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Module defining the AST (abstract syntax tree).
|
//! Module defining the AST (abstract syntax tree).
|
||||||
|
|
||||||
use super::{ASTFlags, Expr, FnAccess, Stmt, StmtBlock, StmtBlockContainer};
|
use super::{ASTFlags, Expr, FnAccess, Stmt, StmtBlock, StmtBlockContainer};
|
||||||
use crate::{Dynamic, FnNamespace, Identifier, Position, SmartString};
|
use crate::{Dynamic, FnNamespace, Identifier, Position};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
use std::{
|
use std::{
|
||||||
@ -23,7 +23,7 @@ pub struct AST {
|
|||||||
source: Identifier,
|
source: Identifier,
|
||||||
/// [`AST`] documentation.
|
/// [`AST`] documentation.
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
doc: SmartString,
|
doc: crate::SmartString,
|
||||||
/// Global statements.
|
/// Global statements.
|
||||||
body: StmtBlock,
|
body: StmtBlock,
|
||||||
/// Script-defined functions.
|
/// Script-defined functions.
|
||||||
@ -76,7 +76,7 @@ impl AST {
|
|||||||
Self {
|
Self {
|
||||||
source: Identifier::new_const(),
|
source: Identifier::new_const(),
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
doc: SmartString::new_const(),
|
doc: crate::SmartString::new_const(),
|
||||||
body: StmtBlock::new(statements, Position::NONE, Position::NONE),
|
body: StmtBlock::new(statements, Position::NONE, Position::NONE),
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
lib: functions.into(),
|
lib: functions.into(),
|
||||||
@ -96,7 +96,7 @@ impl AST {
|
|||||||
Self {
|
Self {
|
||||||
source: Identifier::new_const(),
|
source: Identifier::new_const(),
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
doc: SmartString::new_const(),
|
doc: crate::SmartString::new_const(),
|
||||||
body: StmtBlock::new(statements, Position::NONE, Position::NONE),
|
body: StmtBlock::new(statements, Position::NONE, Position::NONE),
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
lib: functions.into(),
|
lib: functions.into(),
|
||||||
@ -146,7 +146,7 @@ impl AST {
|
|||||||
Self {
|
Self {
|
||||||
source: Identifier::new_const(),
|
source: Identifier::new_const(),
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
doc: SmartString::new_const(),
|
doc: crate::SmartString::new_const(),
|
||||||
body: StmtBlock::NONE,
|
body: StmtBlock::NONE,
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
lib: crate::Module::new().into(),
|
lib: crate::Module::new().into(),
|
||||||
@ -213,7 +213,7 @@ impl AST {
|
|||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub(crate) fn doc_mut(&mut self) -> &mut SmartString {
|
pub(crate) fn doc_mut(&mut self) -> &mut crate::SmartString {
|
||||||
&mut self.doc
|
&mut self.doc
|
||||||
}
|
}
|
||||||
/// Set the documentation.
|
/// Set the documentation.
|
||||||
@ -221,7 +221,7 @@ impl AST {
|
|||||||
/// Only available under `metadata`.
|
/// Only available under `metadata`.
|
||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn set_doc(&mut self, doc: impl Into<SmartString>) {
|
pub(crate) fn set_doc(&mut self, doc: impl Into<crate::SmartString>) {
|
||||||
self.doc = doc.into();
|
self.doc = doc.into();
|
||||||
}
|
}
|
||||||
/// Get the statements.
|
/// Get the statements.
|
||||||
|
Loading…
Reference in New Issue
Block a user