Commit Graph

3658 Commits

Author SHA1 Message Date
Paolo Tranquilli
ef06b555c1 Rust: accept test changes 2024-09-10 11:29:54 +02:00
Paolo Tranquilli
437b671035 Merge branch 'rust-experiment' into aibaars/rust-experiment
Also fixed conflicts and applied linting (can be done via
`rust/lint.py` or `pre-commit` configuration).
2024-09-10 10:24:49 +02:00
Paolo Tranquilli
38c25f96e5 Rust: add linting pre-commit hook 2024-09-10 10:22:45 +02:00
Paolo Tranquilli
37afad2f70 Merge pull request #17410 from github/redsun82/rust-ci
Rust: set up `codeql` CI
2024-09-10 10:04:24 +02:00
Arthur Baars
42b1112be6 Rust: add default Element::toString 2024-09-09 15:05:04 +02:00
Arthur Baars
20ca8801e6 Revert "Rust: PrintAstNode: tolerate elements without toString"
This reverts commit 85e51bf0ec.
2024-09-09 15:01:32 +02:00
Arthur Baars
61592a3256 Rust: fix locations
In QL locations are 1-based inclusive ranges. The locations is rust are 0-based
and the end position is exclusive.

To patch things up, subtract 1 from the end offset and add 1 to all line and column numbers.
2024-09-09 14:56:37 +02:00
Paolo Tranquilli
6f36ea9188 Merge branch 'main' into rust-experiment
Conflicts:
  shared/tree-sitter-extractor/src/trap.rs
2024-09-09 14:15:34 +02:00
Arthur Baars
86215b4f02 Rename IfLet to IfStmt 2024-09-09 13:33:17 +02:00
Arthur Baars
85e51bf0ec Rust: PrintAstNode: tolerate elements without toString 2024-09-09 13:29:49 +02:00
Arthur Baars
b40476423b Rust: schema.py add '| child' markers 2024-09-09 13:29:45 +02:00
Arthur Baars
6acc107021 Prevent a panic on generated labels 2024-09-09 13:25:46 +02:00
Arthur Baars
6e6942b1d7 Rust: initial extractor for expressions and patterns 2024-09-09 13:25:45 +02:00
Arthur Baars
da8750e95e Rust: extract each project only once 2024-09-09 13:25:44 +02:00
Arthur Baars
7c4383975f Filter out trailing empty strings 2024-09-09 13:25:43 +02:00
Paolo Tranquilli
d6b8dd15a9 Rust: add dummy integration test 2024-09-09 12:57:47 +02:00
Paolo Tranquilli
b0ca7935d7 Rust: update generated list file 2024-09-09 12:32:54 +02:00
Paolo Tranquilli
573b8b9373 Merge branch 'rust-experiment' into redsun82/rust-ci 2024-09-09 12:32:02 +02:00
Paolo Tranquilli
56e127849f Rust/Codegen: fix generated list files 2024-09-09 12:31:09 +02:00
Paolo Tranquilli
10a23c0843 Merge branch 'rust-experiment' into redsun82/rust-doctest-gen 2024-09-09 12:20:55 +02:00
Paolo Tranquilli
ee2a8b09f6 Rust: fix formatting 2024-09-09 12:11:50 +02:00
Arthur Baars
ef34d24e53 Merge pull request #17390 from github/aibaars/rust-experiment
Add Expr, Stmt, Pat to schema.py
2024-09-09 11:27:53 +02:00
Paolo Tranquilli
7637393f75 Rust: resolve clippy and rustc warnings 2024-09-09 10:28:50 +02:00
Arthur Baars
c8f73587cc Rust: codegen: fix generated code 2024-09-07 10:32:59 +02:00
Arthur Baars
1a9b2329f4 Add SlicePat::{slice, suffix} 2024-09-06 19:27:35 +02:00
Arthur Baars
406d03edfc Rename IfLet::else_branch to IfLet::else_ 2024-09-06 18:40:03 +02:00
Arthur Baars
e8277015ab Add subclasses for Array 2024-09-06 18:23:01 +02:00
Arthur Baars
69b05e835c Add fields for OffsetOf 2024-09-06 18:17:15 +02:00
Arthur Baars
75113367c9 Add InlineAsm::expr 2024-09-06 18:14:14 +02:00
Arthur Baars
bc6da117d2 Fix type of Closure::arg_types 2024-09-06 17:59:24 +02:00
Paolo Tranquilli
ac9e977baa Rust: remove accidental test source file 2024-09-06 14:29:10 +02:00
Paolo Tranquilli
18c423eb55 Rust: fix formatting of code snippet in docstring 2024-09-06 14:27:57 +02:00
Paolo Tranquilli
6111a7497d Rust: remove accidental schema annotation 2024-09-06 14:26:36 +02:00
Paolo Tranquilli
8c5cc2efdc Rust: generate test code from schema docstrings
This generates test source files from code blocks in class docstrings.

By default the test code is generated as is, but it can optionally:
* be wrapped in a function providing an adequate context using
  `@rust.doc_test_function(name, *, lifetimes=(), return_type="()", **kwargs)`,
  with `kwargs` providing both generic and normal params depending on
  capitalization
* be skipped altogether using `@rust.skip_doc_test`

So for example an annotation like
```python
@rust.doc_test_function("foo",
                        lifetimes=("a",),
                        T="Eq",
                        x="&'a T",
                        y="&'a T",
                        return_type="&'a T")
```
will result in the following wrapper:
```rust
fn foo<'a, T: Eq>(x: &'a T, y: &'a T) -> &'a T {
    // example code here
}
```
2024-09-06 14:24:42 +02:00
Arthur Baars
a33c7703cd Add Label class 2024-09-06 12:42:43 +02:00
Arthur Baars
e14b626917 Add 'BlockBase' class 2024-09-06 12:15:35 +02:00
Paolo Tranquilli
122e5a7598 Rust: remove accidental IDE files 2024-09-06 12:05:11 +02:00
Arthur Baars
ce2fdb3463 Address comments 2024-09-06 11:47:08 +02:00
Paolo Tranquilli
8ecba44ea9 Rust: add experimental bazel target 2024-09-06 09:29:54 +02:00
Arthur Baars
679d81ab00 Rust: extract dummy Function body 2024-09-05 16:59:30 +02:00
Arthur Baars
46d6bbb458 Rust: update generated code 2024-09-05 16:59:29 +02:00
Arthur Baars
76c35bec93 Rust: add Expr, Pat, Stmt to schema 2024-09-05 16:59:28 +02:00
Arthur Baars
0516505033 Rust: update dependencies 2024-09-05 16:58:41 +02:00
Arthur Baars
6fd469c807 Rust: use autodiscovery for sysroot
This should make the rust-analyzer library look for a rust toolchain and
try to start the proc-macro server.
2024-09-05 14:49:37 +02:00
Arthur Baars
d93330bc4c Rust: make printAst work 2024-09-05 14:49:36 +02:00
Arthur Baars
d8eb5d463d Rust: run cargo fmt 2024-09-05 14:45:47 +02:00
Arthur Baars
60b349f7e5 Rust: remove 'take(1)' from crates iterator 2024-09-05 14:45:46 +02:00
Arthur Baars
be16954521 Rust: add autobuild.sh 2024-09-05 14:45:45 +02:00
Arthur Baars
52ef1e382a Add 'version' field to generated Cargo.toml file 2024-09-05 14:45:44 +02:00
Paolo Tranquilli
885e89a927 Rust: first running tests 2024-08-30 17:45:51 +02:00