Skip to content

Commit

Permalink
chore: increase Rust version to 1.82.0 (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante authored Jan 25, 2025
1 parent dda5543 commit 62e55e8
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 62 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
- name: install Rust
uses: actions-rs/toolchain@v1
with:
# If you update this, also update build.mjs
toolchain: nightly-2023-11-16
# Sync with rust-toolchain.toml
toolchain: 1.82
override: true
- run: rustup component add clippy rustfmt
components: rustfmt, clippy
- name: lint
run: cargo clippy --features test_ci --exclude grit-wasm-bindings --workspace --locked -- -D warnings
- name: format
run: cargo fmt --all -- --check
run: cargo fmt -- --check
13 changes: 7 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- name: install Rust
uses: actions-rs/toolchain@v1
with:
# If you update this, also update build.mjs
toolchain: nightly-2023-11-16
# Sync with rust-toolchain.toml
toolchain: 1.82
override: true
- name: install Terraform
run: |
Expand Down Expand Up @@ -62,8 +62,7 @@ jobs:
--exclude google-cloud-auth \
--exclude google-cloud-googleapis \
--exclude google-cloud-gax \
--exclude google-cloud-pubsub \
-- -Z unstable-options
--exclude google-cloud-pubsub
test-rust-wasm:
name: Rust wasm
timeout-minutes: 15
Expand All @@ -79,7 +78,8 @@ jobs:
- name: install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
# Sync with rust-toolchain.toml
toolchain: 1.82
override: true
- name: install wasm-pack
run: |
Expand All @@ -103,7 +103,8 @@ jobs:
- name: install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-11-16
# Sync with rust-toolchain.toml
toolchain: 1.82
override: true
- name: build
run: |
Expand Down
3 changes: 3 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,6 @@ grit_beta = [
# "grit_tracing",
]
grit_timing = []
# Copied from otel
experimental_metadata_attributes = []
logs_level_enabled = []
15 changes: 6 additions & 9 deletions crates/cli/src/commands/patterns_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,12 @@ pub async fn get_marzano_pattern_test_results(
let mut actual_sample = sample.clone();
debug!("Sample: {:?}, result {:?}", sample, result);

match &result.actual_output {
Some(output) => {
debug!(
"Sample output: {:?}, {:?}",
result.message, result.expected_output
);
actual_sample.output = Some(output.clone())
}
None => (),
if let Some(output) = &result.actual_output {
debug!(
"Sample output: {:?}, {:?}",
result.message, result.expected_output
);
actual_sample.output = Some(output.clone())
}

let wrapped = WrappedResult {
Expand Down
2 changes: 2 additions & 0 deletions crates/cli/src/result_formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ pub enum FormattedResult {
AnalysisLog(AnalysisLog),
Match(Match),
InputFile(InputFile),
#[allow(unused)]
DoneFile(DoneFile),
AllDone(AllDone),
#[allow(unused)]
PatternInfo(PatternInfo),
Rewrite(Rewrite),
CreateFile(CreateFile),
Expand Down
5 changes: 0 additions & 5 deletions crates/cli/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use colored::Colorize;
use indicatif::ProgressBar;
use log::info;
use marzano_auth::info::AuthInfo;
use marzano_gritmodule::config::REPO_CONFIG_DIR_NAME;
use marzano_util::runtime::{ExecutionContext, LanguageModelAPI};

use serde::Deserialize;
Expand Down Expand Up @@ -138,7 +137,6 @@ pub struct Updater {
pub manifest_path: PathBuf,
pub install_path: PathBuf,
bin_path: PathBuf,
pub global_grit_path: PathBuf,
pub binaries: HashMap<String, AppManifest>,
#[cfg(feature = "updater")]
last_checked_update: Option<NaiveDateTime>,
Expand Down Expand Up @@ -168,7 +166,6 @@ impl Updater {
return Ok(Self {
manifest_path,
bin_path: install_path.join("bin"),
global_grit_path: install_path.join(REPO_CONFIG_DIR_NAME),
install_path,
binaries: manifest.binaries,
#[cfg(feature = "updater")]
Expand All @@ -181,12 +178,10 @@ impl Updater {

let bin_path = install_path.join("bin");

let global_grit_path = install_path.join(REPO_CONFIG_DIR_NAME);
let updater = Self {
manifest_path: install_path.join(MANIFEST_FILE),
install_path,
bin_path,
global_grit_path,
binaries: HashMap::new(),
#[cfg(feature = "updater")]
last_checked_update: None,
Expand Down
1 change: 1 addition & 0 deletions crates/cli/src/ux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub enum Format {

#[derive(Debug, serde::Deserialize)]
pub struct Table {
#[allow(unused)]
pub format: Format,
pub headers: Option<Vec<String>>,
pub data: Vec<Vec<String>>,
Expand Down
1 change: 1 addition & 0 deletions crates/cli_bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ marzano-gritmodule = { path = "../gritmodule" }

[features]
default = ["marzano-cli/default", "grit_tracing"]
ai_builtins = []
grit_tracing = [
"marzano-cli/grit_tracing",
"opentelemetry",
Expand Down
22 changes: 10 additions & 12 deletions crates/core/src/optimizer/hoist_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,13 @@ impl<Q: QueryContext> FilenamePatternExtractor<Q> for Predicate<Q> {
match &m.val {
grit_pattern_matcher::pattern::Container::Variable(var) => {
if var.is_file_name() {
match &m.pattern {
Some(pattern) => {
// This is the key line of this entire file
if is_safe_to_hoist(pattern)? {
return Ok(Some(pattern.clone()));
} else {
return Ok(None);
}
if let Some(pattern) = &m.pattern {
// This is the key line of this entire file
if is_safe_to_hoist(pattern)? {
return Ok(Some(pattern.clone()));
} else {
return Ok(None);
}
None => {}
}
}
}
Expand All @@ -244,10 +241,11 @@ impl<Q: QueryContext> FilenamePatternExtractor<Q> for Predicate<Q> {
| grit_pattern_matcher::pattern::Container::FunctionCall(_) => {}
};

match &m.pattern {
Some(pattern) => extract_filename_pattern(pattern),
if let Some(pattern) = &m.pattern {
extract_filename_pattern(pattern)
} else {
// TODO: is this right? Why do we ever have an empty pattern?
None => Ok(None),
Ok(None)
}
}
Predicate::Accumulate(_) | Predicate::Assignment(_) | Predicate::Return(_) => {
Expand Down
24 changes: 11 additions & 13 deletions crates/core/src/optimizer/hoist_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,15 @@ impl<Q: QueryContext> BodyPatternExtractor<Q> for Predicate<Q> {
match &m.val {
grit_pattern_matcher::pattern::Container::Variable(var) => {
if var.is_program() || var.is_probably_match() {
match &m.pattern {
Some(pattern) => {
// This is the key line of this entire file
if is_safe_to_hoist(pattern)? {
let body_pattern = extract_body_pattern(pattern, true)?;

if let Some(body_pattern) = body_pattern {
return Ok(Some(body_pattern));
}
if let Some(pattern) = &m.pattern {
// This is the key line of this entire file
if is_safe_to_hoist(pattern)? {
let body_pattern = extract_body_pattern(pattern, true)?;

if let Some(body_pattern) = body_pattern {
return Ok(Some(body_pattern));
}
}
None => {}
}
}
}
Expand All @@ -358,10 +355,11 @@ impl<Q: QueryContext> BodyPatternExtractor<Q> for Predicate<Q> {
| grit_pattern_matcher::pattern::Container::FunctionCall(_) => {}
};

match &m.pattern {
Some(pattern) => extract_body_pattern(pattern, false),
if let Some(pattern) = &m.pattern {
extract_body_pattern(pattern, false)
} else {
// TODO: is this right? Why do we ever have an empty pattern?
None => Ok(None),
Ok(None)
}
}
Predicate::Accumulate(_) | Predicate::Assignment(_) | Predicate::Return(_) => {
Expand Down
12 changes: 6 additions & 6 deletions crates/core/src/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ impl Problem {
continue;
}
if let Some(name) = message.file_name() {
if let Ok(path) = PathBuf::from_str(name) {
if let Some(done_file) =
done_files.get_mut(path.to_string_lossy().as_ref())
{
done_file.has_results = Some(true);
}
// .unwrap() is safe, because from_str is infallible
let path = PathBuf::from_str(name).unwrap();
if let Some(done_file) =
done_files.get_mut(path.to_string_lossy().as_ref())
{
done_file.has_results = Some(true);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/externals/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ impl ExternalFunction {
// Currently the JS PDK requires WASI to be enabled; this is not really secure
let mut plugin = Plugin::new(manifest, [], true)?;

plugin.call("register_function", js_function_body)?;
plugin.call(
plugin.call::<&[u8], ()>("register_function", js_function_body)?;
plugin.call::<&[u8], ()>(
"register_parameter_names",
serde_json::to_vec(&param_names)?,
serde_json::to_vec(&param_names)?.as_slice(),
)?;

Ok(Self {
Expand Down
5 changes: 5 additions & 0 deletions crates/grit-pattern-matcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ grit-util = { path = "../grit-util", version = "0.5.1" }
itertools = { version = "0.10.5" }
rand = { version = "0.8.5" }
regex = { version = "1.7.3" }

[features]
default = []
grit_tracing = []
embeddings = []
5 changes: 1 addition & 4 deletions crates/gritmodule/src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@ impl From<&LocalRepo> for ModuleRepo {
fn from(local_repo: &LocalRepo) -> Self {
let remote = local_repo.remote().unwrap_or_default();

match ModuleRepo::from_remote(&remote) {
Ok(module_repo) => module_repo,
Err(_) => Default::default(),
}
ModuleRepo::from_remote(&remote).unwrap_or_default()
}
}

Expand Down
5 changes: 5 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
# The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy.
# https://rust-lang.github.io/rustup/concepts/profiles.html
profile = "default"
channel = "1.82.0"

0 comments on commit 62e55e8

Please sign in to comment.