mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-11-10 20:48:12 +00:00
Merge patch series "syn support"
This patch series introduces support for `syn` (and its dependencies):
Syn is a parsing library for parsing a stream of Rust tokens into a
syntax tree of Rust source code.
Currently this library is geared toward use in Rust procedural
macros, but contains some APIs that may be useful more generally.
It is the most downloaded Rust crate (according to crates.io), and it
is also used by the Rust compiler itself. Having such support allows to
greatly simplify writing complex macros such as `pin-init`. We will use
it in the `macros` crate too.
Benno has already prepared the `pin-init` version based on this, and on
top of that, we will be able to simplify the `macros` crate too. I think
Jesung is working on updating the `TryFrom` and `Into` upcoming derive
macros to use `syn` too.
The series starts with a few preparation commits (two fixes were already
merged in mainline that were discovered by this series), then each crate
is added. Finally, support for using the new crates from our `macros`
crate is introduced.
This has been a long time coming, e.g. even before Rust for Linux was
merged into the Linux kernel, Gary and Benno have wanted to use `syn`.
The first iterations of this, from 2022 and 2023 (with `serde` too,
another popular crate), are at:
https://github.com/Rust-for-Linux/linux/pull/910
https://github.com/Rust-for-Linux/linux/pull/1007
After those, we considered picking these from the distributions where
possible. However, after discussing it, it is not really worth the
complexity: vendoring makes things less complex and is less fragile.
In particular, we avoid having to support and test several versions,
we avoid having to introduce Cargo just to properly fetch the right
versions from the registry, we can easily customize the crates if needed
(e.g. dropping the `unicode_idents` dependency like it is done in this
series) and we simplify the configuration of the build for users for
which the "default" paths/registries would not have worked.
Moreover, nowadays, the ~57k lines introduced are not that much compared
to years ago (it dwarfed the actual Rust kernel code). Moreover, back
then it wasn't clear the Rust experiment would be a success, so it would
have been a bit pointless/risky to add many lines for nothing. Our macro
needs were also smaller in the early days.
So, finally, in Kangrejos 2025 we discussed going with the original,
simpler approach. Thus here it is the result.
There should not be many updates needed for these, and even if there
are, they should not be too big, e.g. +7k -3k lines across the 3 crates
in the last year.
Note that `syn` does not have all the features enabled, since we do not
need them so far, but they can easily be enabled just adding them to the
list.
Link: https://patch.msgid.link/20251124151837.2184382-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
commit
54e3eae855
82 changed files with 57906 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
7
Makefile
7
Makefile
147
rust/Makefile
147
rust/Makefile
1456
rust/quote/lib.rs
1456
rust/quote/lib.rs
838
rust/syn/attr.rs
838
rust/syn/attr.rs
426
rust/syn/data.rs
426
rust/syn/data.rs
4175
rust/syn/expr.rs
4175
rust/syn/expr.rs
File diff suppressed because it is too large
Load diff
138
rust/syn/ext.rs
138
rust/syn/ext.rs
127
rust/syn/file.rs
127
rust/syn/file.rs
File diff suppressed because it is too large
Load diff
2308
rust/syn/gen/eq.rs
2308
rust/syn/gen/eq.rs
3904
rust/syn/gen/fold.rs
3904
rust/syn/gen/fold.rs
File diff suppressed because it is too large
Load diff
2878
rust/syn/gen/hash.rs
2878
rust/syn/gen/hash.rs
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
1479
rust/syn/generics.rs
1479
rust/syn/generics.rs
3492
rust/syn/item.rs
3492
rust/syn/item.rs
File diff suppressed because it is too large
Load diff
1013
rust/syn/lib.rs
1013
rust/syn/lib.rs
1862
rust/syn/lit.rs
1862
rust/syn/lit.rs
227
rust/syn/mac.rs
227
rust/syn/mac.rs
429
rust/syn/meta.rs
429
rust/syn/meta.rs
221
rust/syn/op.rs
221
rust/syn/op.rs
1421
rust/syn/parse.rs
1421
rust/syn/parse.rs
957
rust/syn/pat.rs
957
rust/syn/pat.rs
968
rust/syn/path.rs
968
rust/syn/path.rs
486
rust/syn/stmt.rs
486
rust/syn/stmt.rs
1098
rust/syn/token.rs
1098
rust/syn/token.rs
109
rust/syn/tt.rs
109
rust/syn/tt.rs
1273
rust/syn/ty.rs
1273
rust/syn/ty.rs
Loading…
Add table
Add a link
Reference in a new issue