Skip to content

Commit 19d618a

Browse files
authored
replace stack-graphs fork with workspace metaslang_stack_graphs (#1447)
- added `README` and `LICENSE` - disabled optional unused features - enabled crate to be published along other `metaslang_*` crates
1 parent 0e3cc5d commit 19d618a

14 files changed

Lines changed: 1899 additions & 83 deletions

File tree

Cargo.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ members = [
2929
"crates/metaslang/bindings",
3030
"crates/metaslang/cst",
3131
"crates/metaslang/graph_builder",
32+
"crates/metaslang/stack_graphs",
3233

3334
"crates/solidity/inputs/language",
3435

@@ -72,8 +73,9 @@ language_v2_macros = { path = "crates/language-v2/macros", version = "1.3.0" }
7273
language_v2_tests = { path = "crates/language-v2/tests", version = "1.3.0" }
7374

7475
metaslang_bindings = { path = "crates/metaslang/bindings", version = "1.3.0" }
75-
metaslang_graph_builder = { path = "crates/metaslang/graph_builder", version = "1.3.0" }
7676
metaslang_cst = { path = "crates/metaslang/cst", version = "1.3.0" }
77+
metaslang_graph_builder = { path = "crates/metaslang/graph_builder", version = "1.3.0" }
78+
metaslang_stack_graphs = { path = "crates/metaslang/stack_graphs", version = "1.3.0" }
7779

7880
solidity_language = { path = "crates/solidity/inputs/language", version = "1.3.0" }
7981

@@ -100,13 +102,18 @@ ariadne = { version = "0.2.0" }
100102
# Currently 'bencher' backend API is under development/unstable.
101103
# They recommend always running with the latest CLI version from 'main' until it is stabilized.
102104
bencher_cli = { git = "https://github.com/bencherdev/bencher", branch = "main" }
105+
bitvec = { version = "1.0.1" }
103106
cargo-edit = { version = "0.12.3" }
104107
cargo-nextest = { version = "0.9.72" }
105108
clap = { version = "4.5.40", features = ["derive", "wrap_help"] }
106109
clap_complete = { version = "4.5.54" }
107110
console = { version = "0.15.11" }
111+
controlled-option = { version = "0.4.1" }
108112
derive-new = { version = "0.6.0" }
113+
either = { version = "1.6.0" }
114+
enumset = { version = "1.1.0" }
109115
env_logger = { version = "0.11.6" }
116+
fxhash = { version = "0.2.0" }
110117
iai-callgrind = { version = "0.12.3" }
111118
iai-callgrind-runner = { version = "0.12.3" }
112119
ignore = { version = "0.4.23" }
@@ -115,7 +122,9 @@ indicatif = { version = "0.17.12", features = ["in_memory"] }
115122
indoc = { version = "2.0.6" }
116123
Inflector = { version = "0.11.4" }
117124
itertools = { version = "0.13.0" }
125+
libc = { version = "0.2.0" }
118126
log = { version = "0.4.27" }
127+
lsp-positions = { version = "0.3.0" }
119128
markdown = { version = "0.3.0" }
120129
nom = { version = "7.1.3" }
121130
num-format = { version = "0.4.4" }
@@ -133,7 +142,6 @@ serde_json = { version = "1.0.140", features = ["preserve_order"] }
133142
similar-asserts = { version = "1.7.0" }
134143
smallvec = { version = "1.15.0", features = ["union"] }
135144
solar = { version = "0.1.3", package = "solar-compiler" }
136-
stack-graphs = { git = "https://github.com/NomicFoundation/stack-graphs", branch = "nomic" }
137145
streaming-iterator = { version = "0.1.9" }
138146
string-interner = { version = "0.17.0", features = [
139147
"std",

crates/infra/cli/src/toolchains/public_api/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub enum UserFacingCrate {
1111
// Sorted by dependency order (from dependencies to dependents):
1212
metaslang_cst,
1313
metaslang_graph_builder,
14+
metaslang_stack_graphs,
1415
metaslang_bindings,
1516
slang_solidity,
1617
slang_solidity_cli,
@@ -51,6 +52,7 @@ fn has_library_target(crate_name: UserFacingCrate) -> bool {
5152
match crate_name {
5253
UserFacingCrate::metaslang_cst => true,
5354
UserFacingCrate::metaslang_graph_builder => true,
55+
UserFacingCrate::metaslang_stack_graphs => true,
5456
UserFacingCrate::metaslang_bindings => true,
5557
UserFacingCrate::slang_solidity => true,
5658
UserFacingCrate::slang_solidity_cli => false,

crates/metaslang/bindings/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ categories = ["compilers", "parsing", "parser-implementations"]
2121
[dependencies]
2222
metaslang_cst = { workspace = true }
2323
metaslang_graph_builder = { workspace = true }
24+
metaslang_stack_graphs = { workspace = true }
2425
semver = { workspace = true }
25-
stack-graphs = { workspace = true }
2626
thiserror = { workspace = true }
2727

2828
[dev-dependencies]

crates/metaslang/bindings/src/builder/loader/cancellation.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ pub trait CancellationFlag: Sync {
2525
#[error("Cancelled at \"{0}\"")]
2626
pub struct CancellationError(pub &'static str);
2727

28-
impl stack_graphs::CancellationFlag for &dyn CancellationFlag {
29-
fn check(&self, at: &'static str) -> Result<(), stack_graphs::CancellationError> {
30-
CancellationFlag::check(*self, at).map_err(|err| stack_graphs::CancellationError(err.0))
28+
impl metaslang_stack_graphs::CancellationFlag for &dyn CancellationFlag {
29+
fn check(&self, at: &'static str) -> Result<(), metaslang_stack_graphs::CancellationError> {
30+
CancellationFlag::check(*self, at)
31+
.map_err(|err| metaslang_stack_graphs::CancellationError(err.0))
3132
}
3233
}
3334

crates/metaslang/bindings/src/builder/loader/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ use metaslang_graph_builder::ast::File as GraphBuilderFile;
289289
use metaslang_graph_builder::functions::Functions;
290290
use metaslang_graph_builder::graph::{Edge, Graph, GraphNode, GraphNodeRef, Value};
291291
use metaslang_graph_builder::{ExecutionConfig, ExecutionError, Variables};
292-
use stack_graphs::arena::Handle;
293-
use stack_graphs::graph::{File, Node, NodeID, StackGraph};
292+
use metaslang_stack_graphs::arena::Handle;
293+
use metaslang_stack_graphs::graph::{File, Node, NodeID, StackGraph};
294294
use thiserror::Error;
295295

296296
use crate::builder::{DefinitionBindingInfo, ReferenceBindingInfo};
@@ -547,8 +547,8 @@ pub enum BuildError {
547547
InvalidParent(GraphNodeRef),
548548
}
549549

550-
impl From<stack_graphs::CancellationError> for BuildError {
551-
fn from(value: stack_graphs::CancellationError) -> Self {
550+
impl From<metaslang_stack_graphs::CancellationError> for BuildError {
551+
fn from(value: metaslang_stack_graphs::CancellationError) -> Self {
552552
Self::Cancelled(value.0)
553553
}
554554
}
@@ -564,7 +564,7 @@ impl From<ExecutionError> for BuildError {
564564

565565
impl<KT: KindTypes + 'static> Loader<'_, KT> {
566566
fn load(&mut self, cancellation_flag: &dyn CancellationFlag) -> Result<(), BuildError> {
567-
let cancellation_flag: &dyn stack_graphs::CancellationFlag = &cancellation_flag;
567+
let cancellation_flag: &dyn metaslang_stack_graphs::CancellationFlag = &cancellation_flag;
568568

569569
// By default graph ids are used for stack graph local_ids. A remapping is computed
570570
// for local_ids that already exist in the graph---all other graph ids are mapped to

crates/metaslang/bindings/src/builder/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ use metaslang_cst::kinds::KindTypes;
1010
use metaslang_cst::nodes::NodeId;
1111
use metaslang_graph_builder::ast::File;
1212
use metaslang_graph_builder::functions::Functions;
13+
use metaslang_stack_graphs::graph::{NodeID as GraphNodeId, StackGraph};
1314
use semver::Version;
14-
use stack_graphs::graph::{NodeID as GraphNodeId, StackGraph};
1515

16-
pub type GraphHandle = stack_graphs::arena::Handle<stack_graphs::graph::Node>;
17-
pub(crate) type FileHandle = stack_graphs::arena::Handle<stack_graphs::graph::File>;
16+
pub type GraphHandle = metaslang_stack_graphs::arena::Handle<metaslang_stack_graphs::graph::Node>;
17+
pub(crate) type FileHandle =
18+
metaslang_stack_graphs::arena::Handle<metaslang_stack_graphs::graph::File>;
1819

1920
pub use crate::graph::BindingGraph;
2021

crates/metaslang/bindings/src/graph/resolver.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use std::collections::{HashMap, HashSet};
22
use std::iter::once;
33

44
use metaslang_cst::kinds::KindTypes;
5-
use stack_graphs::arena::Handle;
6-
use stack_graphs::graph::{Degree, Edge, StackGraph};
7-
use stack_graphs::partial::{PartialPath, PartialPaths};
8-
use stack_graphs::stitching::{
5+
use metaslang_stack_graphs::arena::Handle;
6+
use metaslang_stack_graphs::graph::{Degree, Edge, StackGraph};
7+
use metaslang_stack_graphs::partial::{PartialPath, PartialPaths};
8+
use metaslang_stack_graphs::stitching::{
99
Database, ForwardCandidates, ForwardPartialPathStitcher, StitcherConfig, ToAppendable,
1010
};
11-
use stack_graphs::{CancellationError, NoCancellation};
11+
use metaslang_stack_graphs::{CancellationError, NoCancellation};
1212

1313
use crate::builder::{ExtendedStackGraph, GraphHandle};
1414

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ignore = ["src/"] # __NOMIC_FOUNDATION_FORK__ (disable formatting to minimize changes to the fork)
Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,56 @@
11
[package]
2-
name = "stack-graphs"
3-
version = "0.14.1"
4-
description = "Name binding for arbitrary programming languages"
5-
homepage = "https://github.com/github/stack-graphs/tree/main/stack-graphs"
6-
repository = "https://github.com/github/stack-graphs/"
7-
readme = "README.md"
8-
license = "MIT OR Apache-2.0"
2+
version.workspace = true
3+
rust-version.workspace = true
4+
edition.workspace = true
5+
publish = true
6+
7+
name = "metaslang_stack_graphs"
8+
description = "Stack graphs utilities used in Slang"
9+
homepage = "https://nomicfoundation.github.io/slang/"
10+
repository = "https://github.com/NomicFoundation/slang/"
911
authors = [
10-
"GitHub <opensource+stack-graphs@github.com>",
11-
"Douglas Creager <dcreager@dcreager.net>"
12+
"Slang Team <slang@nomic.foundation>",
13+
"Nomic Foundation <packages@nomic.foundation>",
1214
]
13-
edition = "2018"
1415

15-
[features]
16-
bincode = ["dep:bincode", "lsp-positions/bincode"]
17-
copious-debugging = []
18-
serde = ["dep:serde", "serde_with", "lsp-positions/serde"]
19-
storage = ["bincode", "rusqlite"]
20-
visualization = ["serde", "serde_json"]
16+
readme = "README.md"
17+
license = "MIT"
18+
keywords = ["stack-graphs"]
19+
categories = ["compilers"]
2120

22-
[lib]
23-
# All of our tests are in the tests/it "integration" test executable.
24-
test = false
21+
# __NOMIC_FOUNDATION_FORK__ (disable optional features not used in Slang)
22+
# [features]
23+
# bincode = ["dep:bincode", "lsp-positions/bincode"]
24+
# copious-debugging = []
25+
# serde = ["dep:serde", "serde_with", "lsp-positions/serde"]
26+
# storage = ["bincode", "rusqlite"]
27+
# visualization = ["serde", "serde_json"]
2528

2629
[dependencies]
27-
bincode = { version = "2.0.0-rc.3", optional = true }
28-
bitvec = "1.0.1"
29-
controlled-option = "0.4.1"
30-
either = "1.6"
31-
enumset = "1.1"
32-
fxhash = "0.2"
33-
itertools = "0.10.2"
34-
libc = "0.2"
35-
lsp-positions = { version = "0.3", path = "../lsp-positions" } # explicit version is required to be able to publish crate
36-
rusqlite = { version = "0.28", optional = true, features = ["bundled", "functions"] }
37-
serde = { version = "1.0", optional = true, features = ["derive"] }
38-
serde_json = { version = "1.0", optional = true }
39-
serde_with = { version = "3.1", optional = true }
40-
smallvec = { version = "1.6", features = ["union"] }
41-
thiserror = { version = "1.0" }
42-
43-
[dev-dependencies]
44-
assert-json-diff = "2"
45-
maplit = "1.0"
46-
pretty_assertions = "0.7"
47-
serde_json = { version = "1.0" }
48-
49-
[package.metadata.docs.rs]
50-
all-features = true
30+
bitvec = { workspace = true }
31+
controlled-option = { workspace = true }
32+
either = { workspace = true }
33+
enumset = { workspace = true }
34+
fxhash = { workspace = true }
35+
itertools = { workspace = true }
36+
libc = { workspace = true }
37+
lsp-positions = { workspace = true }
38+
smallvec = { workspace = true, features = ["union"] }
39+
thiserror = { workspace = true }
40+
41+
# __NOMIC_FOUNDATION_FORK__ (disable optional dependencies not used in Slang)
42+
# [dependencies]
43+
# bincode = { version = "2.0.0-rc.3", optional = true }
44+
# rusqlite = { version = "0.28", optional = true, features = ["bundled", "functions"] }
45+
# serde = { version = "1.0", optional = true, features = ["derive"] }
46+
# serde_json = { version = "1.0", optional = true }
47+
# serde_with = { version = "3.1", optional = true }
48+
49+
[lints.rust]
50+
unexpected_cfgs = "allow" # __NOMIC_FOUNDATION_FORK__ (disable warning about non-existing features, disabled above)
51+
52+
[lints.rustdoc]
53+
all = "allow" # __NOMIC_FOUNDATION_FORK__ (disable lints to minimize changes to the fork)
54+
55+
[lints.clippy]
56+
all = "allow" # __NOMIC_FOUNDATION_FORK__ (disable lints to minimize changes to the fork)

0 commit comments

Comments
 (0)