Skip to content

Commit

Permalink
Merge branch 'main' into feature/required-label
Browse files Browse the repository at this point in the history
  • Loading branch information
mjoerussell committed Jan 23, 2025
2 parents 3f28258 + be914d9 commit 68614b2
Show file tree
Hide file tree
Showing 24 changed files with 750 additions and 62 deletions.
26 changes: 1 addition & 25 deletions crates/infra/cli/src/commands/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use infra_utils::terminal::Terminal;
use rayon::iter::{ParallelBridge, ParallelIterator};
use strum::IntoEnumIterator;

use crate::toolchains::mkdocs::Mkdocs;
use crate::toolchains::wasm::WasmPackage;
use crate::utils::{ClapExtensions, OrderedCommand};

Expand All @@ -26,12 +25,8 @@ impl CheckController {
enum CheckCommand {
/// Run 'cargo check' for all crates, features, and targets.
Cargo,
/// Run `cargo doc` to generate Rustdoc documentation and check for any broken links.
Rustdoc,
/// Check NPM packages for any outdated codegen steps.
Npm,
/// Check mkdocs documentation for any build issues or broken links.
Mkdocs,
}

impl OrderedCommand for CheckCommand {
Expand All @@ -40,34 +35,19 @@ impl OrderedCommand for CheckCommand {

match self {
CheckCommand::Cargo => check_cargo(),
CheckCommand::Rustdoc => check_rustdoc(),
CheckCommand::Npm => check_npm(),
CheckCommand::Mkdocs => check_mkdocs(),
};

Ok(())
}
}

fn check_cargo() {
// 'cargo clippy' will run both 'cargo check', and 'clippy' lints:
Command::new("cargo")
.arg("clippy")
.arg("check")
.flag("--workspace")
.flag("--all-features")
.flag("--all-targets")
.flag("--no-deps")
.add_build_rustflags()
.run();
}

fn check_rustdoc() {
Command::new("cargo")
.arg("doc")
.flag("--workspace")
.flag("--all-features")
.flag("--no-deps")
.flag("--document-private-items")
.add_build_rustflags()
.run();
}
Expand All @@ -77,7 +57,3 @@ fn check_npm() {
.par_bridge()
.for_each(|package| package.build().unwrap());
}

fn check_mkdocs() {
Mkdocs::check();
}
37 changes: 37 additions & 0 deletions crates/infra/cli/src/commands/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ use std::path::Path;

use anyhow::Result;
use clap::{Parser, ValueEnum};
use infra_utils::cargo::CargoWorkspaceCommands;
use infra_utils::commands::Command;
use infra_utils::github::GitHub;
use infra_utils::paths::{FileWalker, PathExtensions};
use infra_utils::terminal::Terminal;

use crate::toolchains::mkdocs::Mkdocs;
use crate::toolchains::pipenv::PipEnv;
use crate::utils::{ClapExtensions, OrderedCommand};

Expand All @@ -24,6 +26,12 @@ impl LintController {

#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, ValueEnum)]
enum LintCommand {
/// Run `cargo clippy` to check for any Rust lints.
Clippy,
/// Run `cargo doc` to generate Rustdoc documentation and check for any broken links.
Rustdoc,
/// Check mkdocs documentation for any build issues or broken links.
Mkdocs,
/// Check for spelling issues in Markdown files.
Cspell,
/// Format all non-Rust source files.
Expand All @@ -49,6 +57,9 @@ impl OrderedCommand for LintCommand {
Terminal::step(format!("lint {name}", name = self.clap_name()));

match self {
LintCommand::Clippy => run_clippy(),
LintCommand::Rustdoc => run_rustdoc(),
LintCommand::Mkdocs => run_mkdocs(),
LintCommand::Cspell => run_cspell(),
LintCommand::Prettier => run_prettier(),
LintCommand::MarkdownLinkCheck => run_markdown_link_check()?,
Expand All @@ -64,6 +75,32 @@ impl OrderedCommand for LintCommand {
}
}

fn run_clippy() {
Command::new("cargo")
.arg("clippy")
.flag("--workspace")
.flag("--all-features")
.flag("--all-targets")
.flag("--no-deps")
.add_build_rustflags()
.run();
}

fn run_rustdoc() {
Command::new("cargo")
.arg("doc")
.flag("--workspace")
.flag("--all-features")
.flag("--no-deps")
.flag("--document-private-items")
.add_build_rustflags()
.run();
}

fn run_mkdocs() {
Mkdocs::check();
}

fn run_cspell() {
Command::new("cspell")
.arg("lint")
Expand Down
4 changes: 1 addition & 3 deletions crates/metaslang/bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ description = "Computes semantic language bindings from parsed source code"
homepage = "https://nomicfoundation.github.io/slang/"
repository = "https://github.com/NomicFoundation/slang/"
authors = [
"Slang Team <[email protected]>",
"Nomic Foundation <[email protected]>",
"Antony Blakey <[email protected]>",
"Igor Matuszewski <[email protected]>",
"Omar Tawfik <[email protected]>",
]

readme = "README.md"
Expand Down
4 changes: 1 addition & 3 deletions crates/metaslang/cst/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ description = "A generic library for building, navigating and querying concrete
homepage = "https://nomicfoundation.github.io/slang/"
repository = "https://github.com/NomicFoundation/slang/"
authors = [
"Slang Team <[email protected]>",
"Nomic Foundation <[email protected]>",
"Antony Blakey <[email protected]>",
"Igor Matuszewski <[email protected]>",
"Omar Tawfik <[email protected]>",
]

readme = "README.md"
Expand Down
4 changes: 1 addition & 3 deletions crates/metaslang/graph_builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ description = "Construct graphs from parsed source code"
homepage = "https://nomicfoundation.github.io/slang/"
repository = "https://github.com/NomicFoundation/slang/"
authors = [
"Slang Team <[email protected]>",
"Nomic Foundation <[email protected]>",
"Antony Blakey <[email protected]>",
"Igor Matuszewski <[email protected]>",
"Omar Tawfik <[email protected]>",
]

readme = "README.md"
Expand Down
68 changes: 63 additions & 5 deletions crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -1033,13 +1033,19 @@ inherit .star_extension
;;; Mappings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; When there's a parsing error (like a name in parameters for versions below 0.8.18)
;;; we still need the basics to get bindings working
@mapping [MappingType] {
node @mapping.lexical_scope
node @mapping.output
node @mapping.pop_begin
node @mapping.pop_end
}

@mapping [MappingType
[MappingKey [MappingKeyType @key_type ([IdentifierPath] | [ElementaryType])]]
[MappingValue @value_type [TypeName]]
] {
node @mapping.lexical_scope
node @mapping.output

; Define the pushing path of the mapping type
; ValueType <- top of the symbol stack
; KeyType
Expand Down Expand Up @@ -1081,12 +1087,33 @@ inherit .star_extension
node pop_mapping
attr (pop_mapping) pop_symbol = "%Mapping"

let @mapping.pop_begin = @value_type.pop_begin
edge @mapping.pop_begin -> @value_type.pop_begin
edge @value_type.pop_end -> @key_type.pop_begin
edge @key_type.pop_end -> pop_mapping
let @mapping.pop_end = pop_mapping
edge pop_mapping -> @mapping.pop_end

node @mapping.defs
}

@mapping [MappingType
@key [MappingKey [MappingKeyType] @key_name [Identifier]]
[MappingValue]
] {
node @key.def
attr (@key.def) node_definition = @key_name
attr (@key.def) definiens_node = @key
edge @key.def -> @mapping.defs
}

@mapping [MappingType
[MappingKey]
@value [MappingValue [TypeName] @value_name [Identifier]]
] {
node @value.def
attr (@value.def) node_definition = @value_name
attr (@value.def) definiens_node = @value
edge @value.def -> @mapping.defs
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Arrays types
Expand Down Expand Up @@ -2050,6 +2077,36 @@ inherit .star_extension
edge @enum.def -> type
edge type -> type_enum_type
edge type_enum_type -> @enum.lexical_scope

; value_ref_typeof allows for an enum value to access the
; functions associated to this type
node @enum.value_ref_typeof
attr (@enum.value_ref_typeof) push_symbol = "@typeof"
node value_ref_type
attr (value_ref_type) push_symbol = (source-text @name)
edge @enum.value_ref_typeof -> value_ref_type
edge value_ref_type -> @enum.lexical_scope

; Path to link min and max to the enum's scope (#1158)
; It resolves paths of the form `type(<enum>).min.<something>`
if (version-matches ">= 0.6.8") {
node typeof
attr (typeof) pop_symbol = "@typeof"

node built_in_member
attr (built_in_member) pop_symbol = "."
node min_built_in
attr (min_built_in) pop_symbol = "min"
node max_built_in
attr (max_built_in) pop_symbol = "max"

edge type -> typeof
edge typeof -> built_in_member
edge built_in_member -> min_built_in
edge built_in_member -> max_built_in
edge min_built_in -> @enum.value_ref_typeof
edge max_built_in -> @enum.value_ref_typeof
}
}

@enum [EnumDefinition
Expand All @@ -2059,6 +2116,7 @@ inherit .star_extension
attr (def) node_definition = @item
attr (def) definiens_node = @item

edge def -> @enum.value_ref_typeof
edge @enum.members -> def
}

Expand Down
4 changes: 1 addition & 3 deletions crates/solidity/outputs/cargo/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ description = "This crate contains the 'slang_solidity' CLI/cargo binary. Please
homepage = "https://nomicfoundation.github.io/slang/"
repository = "https://github.com/NomicFoundation/slang/"
authors = [
"Slang Team <[email protected]>",
"Nomic Foundation <[email protected]>",
"Antony Blakey <[email protected]>",
"Igor Matuszewski <[email protected]>",
"Omar Tawfik <[email protected]>",
]

readme = "README.md"
Expand Down
4 changes: 1 addition & 3 deletions crates/solidity/outputs/cargo/crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ description = "A modular set of compiler APIs empowering the next generation of
homepage = "https://nomicfoundation.github.io/slang/"
repository = "https://github.com/NomicFoundation/slang/"
authors = [
"Slang Team <[email protected]>",
"Nomic Foundation <[email protected]>",
"Antony Blakey <[email protected]>",
"Igor Matuszewski <[email protected]>",
"Omar Tawfik <[email protected]>",
]

readme = "README.md"
Expand Down
Loading

0 comments on commit 68614b2

Please sign in to comment.