Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the unused &mut dependency_graph throughout sway-core #826

Merged
merged 3 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions forc/src/ops/forc_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use sway_core::{
use sway_types::JsonABI;

use anyhow::Result;
use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};

pub fn build(command: BuildCommand) -> Result<(Vec<u8>, JsonABI), String> {
Expand Down Expand Up @@ -70,7 +69,6 @@ pub fn build(command: BuildCommand) -> Result<(Vec<u8>, JsonABI), String> {
.print_intermediate_asm(print_intermediate_asm)
.print_ir(print_ir);

let mut dependency_graph = HashMap::new();
let namespace = create_module();

let mut source_map = SourceMap::new();
Expand All @@ -83,7 +81,6 @@ pub fn build(command: BuildCommand) -> Result<(Vec<u8>, JsonABI), String> {
dependency_name,
dependency_details,
namespace,
&mut dependency_graph,
silent_mode,
offline_mode,
)?;
Expand All @@ -109,7 +106,6 @@ pub fn build(command: BuildCommand) -> Result<(Vec<u8>, JsonABI), String> {
&manifest.project.name,
namespace,
build_config,
&mut dependency_graph,
&mut source_map,
silent_mode,
)?;
Expand Down Expand Up @@ -172,7 +168,6 @@ fn compile_dependency_lib<'manifest>(
dependency_name: &'manifest str,
dependency_lib: &mut Dependency,
namespace: NamespaceRef,
dependency_graph: &mut HashMap<String, HashSet<String>>,
silent_mode: bool,
offline_mode: bool,
) -> Result<JsonABI, String> {
Expand Down Expand Up @@ -261,7 +256,6 @@ fn compile_dependency_lib<'manifest>(
dependency_name,
dependency_lib,
dep_namespace,
dependency_graph,
silent_mode,
offline_mode,
)?;
Expand All @@ -275,7 +269,6 @@ fn compile_dependency_lib<'manifest>(
&manifest_of_dep.project.name,
dep_namespace,
build_config,
dependency_graph,
silent_mode,
)?;

Expand All @@ -289,10 +282,9 @@ fn compile_library(
proj_name: &str,
namespace: NamespaceRef,
build_config: BuildConfig,
dependency_graph: &mut HashMap<String, HashSet<String>>,
silent_mode: bool,
) -> Result<(NamespaceRef, JsonABI), String> {
let res = sway_core::compile_to_ast(source, namespace, &build_config, dependency_graph);
let res = sway_core::compile_to_ast(source, namespace, &build_config);
match res {
CompileAstResult::Success {
parse_tree,
Expand Down Expand Up @@ -325,11 +317,10 @@ fn compile(
proj_name: &str,
namespace: NamespaceRef,
build_config: BuildConfig,
dependency_graph: &mut HashMap<String, HashSet<String>>,
source_map: &mut SourceMap,
silent_mode: bool,
) -> Result<(Vec<u8>, JsonABI), String> {
let ast_res = sway_core::compile_to_ast(source, namespace, &build_config, dependency_graph);
let ast_res = sway_core::compile_to_ast(source, namespace, &build_config);
let (json_abi, tree_type, warnings) = match &ast_res {
CompileAstResult::Success {
parse_tree,
Expand Down Expand Up @@ -372,10 +363,9 @@ fn compile_to_asm(
proj_name: &str,
namespace: NamespaceRef,
build_config: BuildConfig,
dependency_graph: &mut HashMap<String, HashSet<String>>,
silent_mode: bool,
) -> Result<FinalizedAsm, String> {
let res = sway_core::compile_to_asm(source, namespace, build_config, dependency_graph);
let res = sway_core::compile_to_asm(source, namespace, build_config);
match res {
CompilationResult::Success { asm, warnings } => {
print_on_success(silent_mode, proj_name, &warnings, TreeType::Script {});
Expand Down
12 changes: 3 additions & 9 deletions sway-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use build_config::BuildConfig;
use control_flow_analysis::{ControlFlowGraph, Graph};
use pest::iterators::Pair;
use pest::Parser;
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::sync::Arc;

pub use semantic_analysis::{
Expand Down Expand Up @@ -244,7 +244,6 @@ pub(crate) fn compile_inner_dependency(
initial_namespace: NamespaceRef,
build_config: BuildConfig,
dead_code_graph: &mut ControlFlowGraph,
dependency_graph: &mut HashMap<String, HashSet<String>>,
) -> CompileResult<InnerDependencyCompileResult> {
let mut warnings = Vec::new();
let mut errors = Vec::new();
Expand Down Expand Up @@ -274,7 +273,6 @@ pub(crate) fn compile_inner_dependency(
&parse_tree.tree_type,
&build_config,
dead_code_graph,
dependency_graph,
),
return err(warnings, errors),
warnings,
Expand Down Expand Up @@ -309,7 +307,6 @@ pub fn compile_to_ast(
input: Arc<str>,
initial_namespace: crate::semantic_analysis::NamespaceRef,
build_config: &BuildConfig,
dependency_graph: &mut HashMap<String, HashSet<String>>,
) -> CompileAstResult {
let mut warnings = Vec::new();
let mut errors = Vec::new();
Expand All @@ -333,7 +330,6 @@ pub fn compile_to_ast(
&parse_tree.tree_type,
&build_config.clone(),
&mut dead_code_graph,
dependency_graph,
),
return CompileAstResult::Failure { errors, warnings },
warnings,
Expand Down Expand Up @@ -367,9 +363,8 @@ pub fn compile_to_asm(
input: Arc<str>,
initial_namespace: crate::semantic_analysis::NamespaceRef,
build_config: BuildConfig,
dependency_graph: &mut HashMap<String, HashSet<String>>,
) -> CompilationResult {
let ast_res = compile_to_ast(input, initial_namespace, &build_config, dependency_graph);
let ast_res = compile_to_ast(input, initial_namespace, &build_config);
ast_to_asm(ast_res, &build_config)
}

Expand Down Expand Up @@ -514,10 +509,9 @@ pub fn compile_to_bytecode(
input: Arc<str>,
initial_namespace: crate::semantic_analysis::NamespaceRef,
build_config: BuildConfig,
dependency_graph: &mut HashMap<String, HashSet<String>>,
source_map: &mut SourceMap,
) -> BytecodeCompilationResult {
let asm_res = compile_to_asm(input, initial_namespace, build_config, dependency_graph);
let asm_res = compile_to_asm(input, initial_namespace, build_config);
asm_to_bytecode(asm_res, source_map)
}

Expand Down
1 change: 0 additions & 1 deletion sway-core/src/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,6 @@ mod tests {
&TreeType::Script,
&build_config,
&mut dead_code_graph,
&mut std::collections::HashMap::new(),
)
.unwrap(&mut warnings, &mut errors)
}
Expand Down
2 changes: 0 additions & 2 deletions sway-core/src/semantic_analysis/ast_node/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ impl TypedCodeBlock {
self_type,
build_config,
dead_code_graph,
dependency_graph,
opts,
..
} = arguments;
Expand All @@ -46,7 +45,6 @@ impl TypedCodeBlock {
self_type,
build_config,
dead_code_graph,
dependency_graph,
mode: Mode::NonAbi,
opts,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ impl TypedFunctionDeclaration {
build_config,
dead_code_graph,
mode,
dependency_graph,
mut opts,
..
} = arguments;
Expand Down Expand Up @@ -137,7 +136,6 @@ impl TypedFunctionDeclaration {
self_type,
build_config,
dead_code_graph,
dependency_graph,
mode: Mode::NonAbi,
opts,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub(crate) fn instantiate_enum(
self_type: TypeId,
build_config: &BuildConfig,
dead_code_graph: &mut ControlFlowGraph,
dependency_graph: &mut HashMap<String, HashSet<String>>,
opts: TCOpts,
) -> CompileResult<TypedExpression> {
let mut warnings = vec![];
Expand Down Expand Up @@ -75,7 +74,6 @@ pub(crate) fn instantiate_enum(
self_type,
build_config,
dead_code_graph,
dependency_graph,
mode: Mode::NonAbi,
opts,
}),
Expand Down
Loading