Skip to content
Draft
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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ exclude = [
"rust/ql/integration-tests",
]

[workspace.package]
edition = "2024"

[workspace.lints.rust]
redundant_imports = "warn"

Expand Down
2 changes: 1 addition & 1 deletion cpp/extractor/bmn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bmn"
version = "0.1.0"
edition = "2024"
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
12 changes: 6 additions & 6 deletions misc/bazel/3rdparty/rust_workspace_deps/crates.bzl

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

2 changes: 1 addition & 1 deletion python/extractor/yeast-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "yeast-python"
version = "0.1.0"
authors = ["Taus <tausbn@github.com>"]
edition = "2024"
edition.workspace = true

[dependencies]
anyhow = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion ql/buramu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "buramu"
version = "0.1.0"
edition = "2021"
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion ql/buramu/tree-sitter-blame/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.0.1"
keywords = ["incremental", "parsing", "blame"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-blame"
edition = "2021"
edition.workspace = true
license = "MIT"

build = "bindings/rust/build.rs"
Expand Down
2 changes: 1 addition & 1 deletion ql/buramu/tree-sitter-blame/bindings/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use tree_sitter_language::LanguageFn;

extern "C" {
unsafe extern "C" {
fn tree_sitter_blame() -> *const ();
}

Expand Down
2 changes: 1 addition & 1 deletion ql/extractor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "codeql-extractor-ql"
version = "0.1.0"
authors = ["GitHub"]
edition = "2021"
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion ruby/extractor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "codeql-extractor-ruby"
description = "CodeQL Ruby extractor"
version = "0.1.0"
authors = ["GitHub"]
edition = "2024"
edition.workspace = true

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion rust/ast-generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ast-generator"
version = "0.1.0"
edition = "2024"
edition.workspace = true
license = "MIT"

[lints]
Expand Down
2 changes: 1 addition & 1 deletion rust/autobuild/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "codeql-autobuilder-rust"
version = "0.1.0"
edition = "2024"
edition.workspace = true

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion rust/extractor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "codeql-rust"
version = "0.1.0"
edition = "2024"
edition.workspace = true
license = "MIT"

[lints]
Expand Down
2 changes: 1 addition & 1 deletion shared/extractor-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "extractor-common"
description = "Code shared between the extractors."
version = "0.1.0"
edition = "2024"
edition.workspace = true

[lints]
workspace = true
2 changes: 1 addition & 1 deletion shared/tree-sitter-extractor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "codeql-extractor"
version = "0.2.0"
edition = "2024"
edition.workspace = true
authors = ["GitHub"]

[lints]
Expand Down
2 changes: 1 addition & 1 deletion shared/yeast-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "yeast-macros"
version = "0.1.0"
edition = "2021"
edition.workspace = true

[lib]
proc-macro = true
Expand Down
10 changes: 6 additions & 4 deletions shared/yeast-macros/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ named:
let [Template::Node(assignment)] = templates.as_slice() else {
panic!("expected one output node");
};
let [Field::Named {
value: Template::Node(structural),
..
}] = assignment.fields.as_slice()
let [
Field::Named {
value: Template::Node(structural),
..
},
] = assignment.fields.as_slice()
else {
panic!("expected one structural child");
};
Expand Down
2 changes: 1 addition & 1 deletion shared/yeast-macros/src/lower.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use proc_macro2::{Ident, Span, TokenStream, TokenTree};
use quote::{quote, quote_spanned, ToTokens};
use quote::{ToTokens, quote, quote_spanned};
use std::cell::RefCell;
use std::sync::atomic::{AtomicUsize, Ordering};
use syn::spanned::Spanned;
Expand Down
14 changes: 7 additions & 7 deletions shared/yeast-macros/src/rule_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,16 @@ fn parse_replacement(input: TokenStream) -> Result<Replacement> {
return Ok(Replacement::Rust { annotation, body });
}

if let Some(TokenTree::Group(group)) = tokens.peek() {
if group.delimiter() == Delimiter::Brace {
return Err(syn::Error::new(
group.span(),
"bare `{...}` rule bodies are no longer accepted; \
if let Some(TokenTree::Group(group)) = tokens.peek()
&& group.delimiter() == Delimiter::Brace
{
return Err(syn::Error::new(
group.span(),
"bare `{...}` rule bodies are no longer accepted; \
use the annotation form `=> kind [? | *] { ... }` \
(where the kind names the output node's schema kind, \
optionally suffixed with `?` or `*` for cardinality)",
));
}
));
}

let templates = crate::template_parse::parse_templates(tokens.collect())?;
Expand Down
14 changes: 7 additions & 7 deletions shared/yeast-macros/src/template_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ fn parse_node(group: &proc_macro2::Group) -> Result<Node> {
};
return Err(error);
}
if let Some(TokenTree::Punct(punctuation)) = tokens.peek() {
if punctuation.as_char() == '?' {
return Err(syn::Error::new_spanned(
punctuation.clone(),
"`?` is not valid on a `location` field",
));
}
if let Some(TokenTree::Punct(punctuation)) = tokens.peek()
&& punctuation.as_char() == '?'
{
return Err(syn::Error::new_spanned(
punctuation.clone(),
"`?` is not valid on a `location` field",
));
}
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion shared/yeast-schema/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "yeast-schema"
version = "0.1.0"
edition = "2021"
edition.workspace = true

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion shared/yeast-schema/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::{BTreeMap, BTreeSet};

use crate::{FieldId, KindId, CHILD_FIELD};
use crate::{CHILD_FIELD, FieldId, KindId};

#[derive(Clone, Debug)]
pub struct NodeType {
Expand Down
2 changes: 1 addition & 1 deletion shared/yeast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "yeast"
version = "0.1.0"
edition = "2021"
edition.workspace = true

[lints]
workspace = true
Expand Down
7 changes: 3 additions & 4 deletions shared/yeast/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ impl<'a, C> BuildCtx<'a, C> {
.output
.get_node(id)
.is_some_and(|node| node.source_range().is_none())
&& let Some(source_range) = self.source_range
{
if let Some(source_range) = self.source_range {
self.output
.extend_source_range(id, source_range.empty_at_start());
}
self.output
.extend_source_range(id, source_range.empty_at_start());
}
if !has_explicit_source_range {
self.created_nodes_without_source_range.insert(id);
Expand Down
48 changes: 23 additions & 25 deletions shared/yeast/src/dump.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Write;

use crate::{schema::Schema, Ast, Node, NodeContent, TreeId, CHILD_FIELD};
use crate::{Ast, CHILD_FIELD, Node, NodeContent, TreeId, schema::Schema};

#[derive(Clone, Copy)]
struct TypeCheckContext<'a> {
Expand Down Expand Up @@ -249,12 +249,11 @@ fn dump_node<Id: TreeId>(
}
}

if let Some(context) = type_check {
if let Some(err) =
if let Some(context) = type_check
&& let Some(err) =
type_error_for_node(context.schema, node, context.expected, context.parent_field)
{
write!(out, " <-- ERROR: {err}").unwrap();
}
{
write!(out, " <-- ERROR: {err}").unwrap();
}

writeln!(out).unwrap();
Expand Down Expand Up @@ -392,20 +391,20 @@ fn dump_node<Id: TreeId>(
}
});
for &child_id in children {
if let Some(child) = ast.get_node(child_id) {
if child.is_named() {
let external = is_external_child(node, child);
dump_node(
ast,
child_id,
source,
options,
indent + 1,
child_type_check,
external,
out,
);
}
if let Some(child) = ast.get_node(child_id)
&& child.is_named()
{
let external = is_external_child(node, child);
dump_node(
ast,
child_id,
source,
options,
indent + 1,
child_type_check,
external,
out,
);
}
}
}
Expand Down Expand Up @@ -455,12 +454,11 @@ fn dump_node_inline<Id: TreeId>(
}
}

if let Some(context) = type_check {
if let Some(err) =
if let Some(context) = type_check
&& let Some(err) =
type_error_for_node(context.schema, node, context.expected, context.parent_field)
{
write!(out, " <-- ERROR: {err}").unwrap();
}
{
write!(out, " <-- ERROR: {err}").unwrap();
}

writeln!(out).unwrap();
Expand Down
14 changes: 3 additions & 11 deletions shared/yeast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::BTreeMap;
extern crate self as yeast;

use serde::Serialize;
use serde_json::{json, Value};
use serde_json::{Value, json};

pub mod build;
pub mod captures;
Expand Down Expand Up @@ -1009,20 +1009,12 @@ impl<Id: TreeId> Ast<Id> {

pub fn id_for_node_kind(&self, kind: &str) -> Option<KindId> {
let id = self.schema.id_for_node_kind(kind).unwrap_or(0);
if id == 0 {
None
} else {
Some(id)
}
if id == 0 { None } else { Some(id) }
}

pub fn id_for_unnamed_node_kind(&self, kind: &str) -> Option<KindId> {
let id = self.schema.id_for_unnamed_node_kind(kind).unwrap_or(0);
if id == 0 {
None
} else {
Some(id)
}
if id == 0 { None } else { Some(id) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion shared/yeast/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{build::BuildCtx, captures::Captures, Ast, TreeId};
use crate::{Ast, TreeId, build::BuildCtx, captures::Captures};

#[doc(hidden)]
pub trait QueryTarget: TreeId {
Expand Down
2 changes: 1 addition & 1 deletion shared/yeast/src/visitor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use tree_sitter::{Language, Tree};

use crate::{Ast, Id, Node, NodeContent, CHILD_FIELD};
use crate::{Ast, CHILD_FIELD, Id, Node, NodeContent};

#[derive(Debug)]
struct VisitorNode {
Expand Down
Loading
Loading