Skip to content

Commit

Permalink
upgrade rust to latest version (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarTawfik authored Jun 20, 2024
1 parent 962cfc4 commit 369ee30
Show file tree
Hide file tree
Showing 38 changed files with 128 additions and 127 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-lemons-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/slang": patch
---

upgrade to rust `1.79.0`.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"rust-analyzer.imports.granularity.group": "module",
"rust-analyzer.imports.prefix": "crate",
"rust-analyzer.rustfmt.extraArgs": [
"+nightly-2024-02-21" // __RUST_NIGHTLY_VERSION_MARKER__ (keep in sync)
"+nightly-2024-06-17" // __RUST_NIGHTLY_VERSION_MARKER__ (keep in sync)
],
"rust-analyzer.server.path": "${workspaceFolder}/scripts/bin/rust-analyzer",
"search.exclude": {
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace.package]
version = "0.15.1"
rust-version = "1.76.0" # __RUST_STABLE_VERSION_MARKER__ (keep in sync)
rust-version = "1.79.0" # __RUST_STABLE_VERSION_MARKER__ (keep in sync)
edition = "2021"
publish = false

Expand Down Expand Up @@ -159,11 +159,13 @@ rest_pat_in_fully_bound_structs = "warn" # Prefer not to use `..` in fully bound
verbose_file_reads = "warn" # Prefer simpler and more concise `fs::read_to_string`
# Pedantic
pedantic = "warn" # Warn about pedantic lints, except...
assigning_clones = { level = "allow", priority = 1 } # `clone_from()` is less readable, and is rarely used/implemented
match_same_arms = { level = "allow", priority = 1 } # It's often clearer to have the same arm twice
missing_errors_doc = { level = "allow", priority = 1 } # Most of our code is internal; let's not clutter the docs until...
missing_panics_doc = { level = "allow", priority = 1 } # ... we care about the public documentation in our shipped crates
module_name_repetitions = { level = "allow", priority = 1 } # It seems we prefer it this way; we'd need to discuss that
must_use_candidate = { level = "allow", priority = 1 } # Overzealous, we'd have to `[must_use]` a lot of things
needless_raw_string_hashes = { level = "allow", priority = 1 } # It is easier to use hashes consistently on all tests/examples in a file
redundant_closure_for_method_calls = { level = "allow", priority = 1 } # Not always clearer, let's not pepper `allow`s whenever needed
# Nursery
collection_is_never_read = "warn" # Lint against collections not used after creation
Expand Down
4 changes: 2 additions & 2 deletions bin/hermit.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ env = {

// Rust:
"RUST_BACKTRACE": "full",
"RUST_STABLE_VERSION": "1.76.0", // __RUST_STABLE_VERSION_MARKER__ (keep in sync)
"RUST_NIGHTLY_VERSION": "nightly-2024-02-21", // __RUST_NIGHTLY_VERSION_MARKER__ (keep in sync)
"RUST_STABLE_VERSION": "1.79.0", // __RUST_STABLE_VERSION_MARKER__ (keep in sync)
"RUST_NIGHTLY_VERSION": "nightly-2024-06-17", // __RUST_NIGHTLY_VERSION_MARKER__ (keep in sync)
"RUSTC_WRAPPER": "${HERMIT_ENV}/bin/sccache",
"SCCACHE_DIR": "${HERMIT_ENV}/.hermit/sccache",

Expand Down
1 change: 0 additions & 1 deletion crates/codegen/ebnf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ Inflector = { workspace = true }

[lints]
workspace = true

1 change: 0 additions & 1 deletion crates/codegen/language/definition/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ thiserror = { workspace = true }

[lints]
workspace = true

1 change: 0 additions & 1 deletion crates/codegen/language/internal_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ syn = { workspace = true }

[lints]
workspace = true

1 change: 0 additions & 1 deletion crates/codegen/language/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ codegen_language_definition = { workspace = true }

[lints]
workspace = true

1 change: 0 additions & 1 deletion crates/codegen/language/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ trybuild = { workspace = true }

[lints]
workspace = true

11 changes: 0 additions & 11 deletions crates/codegen/runtime/cargo/src/runtime/language/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@ pub(crate) trait Lexer {
/// Returns valid grouping delimiters in the given lexical context.
fn delimiters<LexCtx: IsLexicalContext>() -> &'static [(TerminalKind, TerminalKind)];

/// Peeks the next terminal, including trivia. Does not advance the input.
fn peek_terminal<LexCtx: IsLexicalContext>(
&self,
input: &mut ParserContext<'_>,
) -> Option<ScannedTerminal> {
let start = input.position();
let terminal = self.next_terminal::<LexCtx>(input);
input.set_position(start);
terminal
}

/// Peeks the next significant (i.e. non-trivia) terminal. Does not advance the input.
fn peek_terminal_with_trivia<LexCtx: IsLexicalContext>(
&self,
Expand Down
7 changes: 1 addition & 6 deletions crates/codegen/runtime/generator/src/parser/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
// We should remove it and replace the grammar construction in the super `parser`
// module with the one from the new DSLv2 in the `constructor` module.

use std::collections::{BTreeSet, HashMap};
use std::collections::HashMap;

use codegen_language_definition::model::Identifier;
use semver::Version;

pub mod constructor;
pub mod parser_definition;
Expand All @@ -21,10 +20,6 @@ pub use scanner_definition::*;
pub use visitor::*;

pub struct Grammar {
pub name: String,
pub versions: BTreeSet<Version>,
pub leading_trivia_parser: TriviaParserDefinitionRef,
pub trailing_trivia_parser: TriviaParserDefinitionRef,
pub elements: HashMap<Identifier, GrammarElement>,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Defines a translation of DSL v2 model into [`Grammar`], which is used for generating the parser and the CST.
use std::cell::OnceCell;
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::collections::{BTreeMap, HashMap};
use std::ops::Deref;
use std::rc::Rc;

Expand Down Expand Up @@ -101,10 +101,6 @@ impl Grammar {
.map(|(name, elem)| (name.clone(), elem.clone()));

Grammar {
name: lang.name.to_string(),
versions: BTreeSet::from_iter(lang.versions.clone()),
leading_trivia_parser: Rc::clone(&leading_trivia),
trailing_trivia_parser: Rc::clone(&trailing_trivia),
elements: resolved_items
.chain(
[leading_trivia, trailing_trivia]
Expand Down
4 changes: 3 additions & 1 deletion crates/codegen/runtime/npm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ description = "TypeScript runtime copied over by codegen"
[build-dependencies]
anyhow = { workspace = true }
codegen_runtime_generator = { workspace = true }
infra_utils = { workspace = true }

[lints]
workspace = true
1 change: 0 additions & 1 deletion crates/codegen/spec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ serde = { workspace = true }

[lints]
workspace = true

1 change: 0 additions & 1 deletion crates/codegen/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ infra_utils = { workspace = true }

[lints]
workspace = true

2 changes: 1 addition & 1 deletion crates/infra/cli/src/commands/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct RunController {

#[derive(Clone, Debug, PartialEq, ValueEnum)]
enum BinaryName {
/// Runs the public 'slang_solidity' crate shipped to Cargo users.
/// Runs the public `slang_solidity` crate shipped to Cargo users.
#[clap(name = "slang_solidity")]
SlangSolidity,
/// Runs the Solidity parser against source files from the Sanctuary repositories.
Expand Down
1 change: 0 additions & 1 deletion crates/infra/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ toml = { workspace = true }

[lints]
workspace = true

3 changes: 3 additions & 0 deletions crates/metaslang/cst/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ categories = ["compilers", "parsing", "parser-implementations"]
nom = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }

[lints]
workspace = true
6 changes: 3 additions & 3 deletions crates/metaslang/cst/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<T: KindTypes> Cursor<T> {
if let Node::<T>::Nonterminal(nonterminal_node) = &self.node {
Some(Rc::new(PathAncestor {
parent: self.parent.clone(),
nonterminal_node: nonterminal_node.clone(),
nonterminal_node: Rc::clone(nonterminal_node),
child_number: self.child_number,
text_offset: self.text_offset,
}))
Expand All @@ -50,7 +50,7 @@ impl<T: KindTypes> Cursor<T> {

fn set_from_ancestor_node(&mut self, ancestor: &Rc<PathAncestor<T>>) {
self.parent = ancestor.parent.clone();
self.node = Node::<T>::Nonterminal(ancestor.nonterminal_node.clone());
self.node = Node::<T>::Nonterminal(Rc::clone(&ancestor.nonterminal_node));
self.child_number = ancestor.child_number;
self.text_offset = ancestor.text_offset;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ impl<T: KindTypes> Cursor<T> {
fn next(&mut self) -> Option<Self::Item> {
if let Some(a) = self.a.take() {
self.a = a.parent.clone();
Some(a.nonterminal_node.clone())
Some(Rc::clone(&a.nonterminal_node))
} else {
None
}
Expand Down
18 changes: 12 additions & 6 deletions crates/metaslang/cst/src/query/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,23 @@ impl<T: KindTypes + 'static> ASTNode<T> {

fn create_matcher(&self, cursor: Cursor<T>) -> MatcherRef<T> {
match self {
Self::Capture(matcher) => Box::new(CaptureMatcher::<T>::new(matcher.clone(), cursor)),
Self::Capture(matcher) => {
Box::new(CaptureMatcher::<T>::new(Rc::clone(matcher), cursor))
}
Self::NodeMatch(matcher) => {
Box::new(NodeMatchMatcher::<T>::new(matcher.clone(), cursor))
Box::new(NodeMatchMatcher::<T>::new(Rc::clone(matcher), cursor))
}
Self::Sequence(matcher) => {
Box::new(SequenceMatcher::<T>::new(Rc::clone(matcher), cursor))
}
Self::Sequence(matcher) => Box::new(SequenceMatcher::<T>::new(matcher.clone(), cursor)),
Self::Alternatives(matcher) => {
Box::new(AlternativesMatcher::<T>::new(matcher.clone(), cursor))
Box::new(AlternativesMatcher::<T>::new(Rc::clone(matcher), cursor))
}
Self::Optional(matcher) => {
Box::new(OptionalMatcher::<T>::new(Rc::clone(matcher), cursor))
}
Self::Optional(matcher) => Box::new(OptionalMatcher::<T>::new(matcher.clone(), cursor)),
Self::OneOrMore(matcher) => {
Box::new(OneOrMoreMatcher::<T>::new(matcher.clone(), cursor))
Box::new(OneOrMoreMatcher::<T>::new(Rc::clone(matcher), cursor))
}
Self::Ellipsis => Box::new(EllipsisMatcher::<T>::new(cursor)),
}
Expand Down
7 changes: 4 additions & 3 deletions crates/metaslang/cst/src/query/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ pub struct Query<T: KindTypes> {

impl<T: KindTypes> Query<T> {
pub fn parse(text: &str) -> Result<Self, QueryError> {
let ast_node = ASTNode::parse(text)?;

let mut capture_quantifiers = BTreeMap::new();
fn collect_capture_quantifiers<T: KindTypes>(
ast_node: &ASTNode<T>,
quantifier: CaptureQuantifier,
Expand Down Expand Up @@ -89,6 +86,10 @@ impl<T: KindTypes> Query<T> {
Ok(())
}

let ast_node = ASTNode::parse(text)?;

let mut capture_quantifiers = BTreeMap::new();

collect_capture_quantifiers(&ast_node, CaptureQuantifier::One, &mut capture_quantifiers)?;

Ok(Self {
Expand Down
7 changes: 2 additions & 5 deletions crates/metaslang/cst/src/text_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ impl TextIndex {
('\r', Some('\n')) => {
// Ignore for now, we will increment the line number whe we process the \n
}
('\n', _)
| ('\r', _)
| (/* line separator */ '\u{2028}', _)
| (/* paragraph separator */ '\u{2029}', _) => {
('\n' | '\r' | '\u{2028}' | '\u{2029}', _) => {
self.line += 1;
self.column = 0;
}
Expand Down Expand Up @@ -69,7 +66,7 @@ impl<T: AsRef<str>> From<T> for TextIndex {
let mut iter = s.as_ref().chars().peekable();
while let Some(c) = iter.next() {
let n = iter.peek();
result.advance(c, n)
result.advance(c, n);
}
result
}
Expand Down
5 changes: 4 additions & 1 deletion crates/metaslang/graph_builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ string-interner = { workspace = true, features = [
thiserror = { workspace = true }

[dev-dependencies]
indoc = { workspace = true }
env_logger = { workspace = true }
indoc = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/metaslang/graph_builder/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use std::collections::HashSet;
use std::path::Path;

use metaslang_cst::query::CaptureQuantifier::{self, *};
use metaslang_cst::query::CaptureQuantifier::{self, One, OneOrMore, ZeroOrMore, ZeroOrOne};
use metaslang_cst::query::Query;
use metaslang_cst::KindTypes;
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion crates/metaslang/graph_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ use string_interner as _;
#[cfg(feature = "cli")]
use {anyhow as _, clap as _, env_logger as _, tree_sitter_config as _, tree_sitter_loader as _};
#[cfg(test)]
use {indoc as _ /*, tree_sitter_python as _ */};
use {env_logger as _, indoc as _, strum as _, strum_macros as _};

#[cfg(doc)]
pub mod reference;
Expand Down
2 changes: 1 addition & 1 deletion crates/metaslang/graph_builder/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::iter::Peekable;
use std::path::Path;
use std::str::Chars;

use metaslang_cst::query::CaptureQuantifier::{self, *};
use metaslang_cst::query::CaptureQuantifier::{self, One, OneOrMore, ZeroOrMore, ZeroOrOne};
use metaslang_cst::query::{Query, QueryError};
use metaslang_cst::KindTypes;
use regex::Regex;
Expand Down
10 changes: 6 additions & 4 deletions crates/metaslang/graph_builder/tests/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use metaslang_graph_builder::functions::Functions;
use metaslang_graph_builder::{
ExecutionConfig, ExecutionError, Identifier, NoCancellation, Variables,
};
use {log as _, regex as _, serde_json as _, smallvec as _, string_interner as _, thiserror as _};

#[derive(
Clone,
Expand Down Expand Up @@ -65,14 +66,15 @@ fn execute(dsl_source: &str) -> Result<String, ExecutionError> {
fn check_execution(dsl_source: &str, expected_graph: &str) {
match execute(dsl_source) {
Ok(actual_graph) => assert_eq!(actual_graph, expected_graph),
Err(e) => panic!("Could not execute file: {}", e),
Err(e) => panic!("Could not execute file: {e}"),
}
}

fn fail_execution(dsl_source: &str) {
if execute(dsl_source).is_ok() {
panic!("Execution succeeded unexpectedly");
}
assert!(
execute(dsl_source).is_err(),
"Execution succeeded unexpectedly"
);
}

#[test]
Expand Down
8 changes: 6 additions & 2 deletions crates/metaslang/graph_builder/tests/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
use indoc::indoc;
use metaslang_graph_builder::graph::{Graph, Value};
use metaslang_graph_builder::Identifier;
use {
env_logger as _, log as _, regex as _, serde_json as _, smallvec as _, string_interner as _,
thiserror as _,
};

#[derive(
Clone,
Expand Down Expand Up @@ -50,8 +54,8 @@ fn can_iterate_graph_nodes() {
let node0 = graph.add_graph_node();
let node1 = graph.add_graph_node();
let node2 = graph.add_graph_node();
let nodes = graph.iter_nodes().collect::<Vec<_>>();
assert_eq!(nodes, vec![node0, node1, node2]);
let all = graph.iter_nodes().collect::<Vec<_>>();
assert_eq!(all, vec![node0, node1, node2]);
}

#[test]
Expand Down
Loading

0 comments on commit 369ee30

Please sign in to comment.