[GIT,PULL] Rust for 6.2

Message ID 20221211005609.270457-1-ojeda@kernel.org
State New
Headers
Series [GIT,PULL] Rust for 6.2 |

Pull-request

https://github.com/Rust-for-Linux/linux tags/rust-6.2

Message

Miguel Ojeda Dec. 11, 2022, 12:56 a.m. UTC
  From: Miguel Ojeda <ojeda@kernel.org>

Hi Linus,

This is the first Rust PR after the merge.

It contains a set of new functionality to start the upstreaming of
the rest of the pieces we had. There are no changes to the C side.

The commits have been in linux-next for a week, though most of the
code has been there for months. No conflicts expected.

Please pull for v6.2 -- thanks!

Cheers,
Miguel

The following changes since commit f0c4d9fc9cc9462659728d168387191387e903cc:

  Linux 6.1-rc4 (2022-11-06 15:07:11 -0800)

are available in the Git repository at:

  https://github.com/Rust-for-Linux/linux tags/rust-6.2

for you to fetch changes up to b9ecf9b9ac5969d7b7ea786ce5c76e24246df2c5:

  rust: types: add `Opaque` type (2022-12-04 01:59:16 +0100)

----------------------------------------------------------------
Rust changes for v6.2

The first set of changes after the merge, the major ones being:

- String and formatting: new types `CString`, `CStr`, `BStr` and
  `Formatter`; new macros `c_str!`, `b_str!` and `fmt!`.

- Errors: the rest of the error codes from `errno-base.h`, as well as
  some `From` trait implementations for the `Error` type.

- Printing: the rest of the `pr_*!` levels and the continuation one
  `pr_cont!`, as well as a new sample.

- `alloc` crate: new constructors `try_with_capacity()` and
  `try_with_capacity_in()` for `RawVec` and `Vec`.

- Procedural macros: new macros `#[vtable]` and `concat_idents!`, as
  well as better ergonomics for `module!` users.

- Asserting: new macros `static_assert!`, `build_error!` and
  `build_assert!`, as well as a new crate `build_error` to support them.

- Vocabulary types: new types `Opaque` and `Either`.

- Debugging: new macro `dbg!`.

----------------------------------------------------------------
Björn Roy Baron (1):
      rust: macros: add `concat_idents!` proc macro

Finn Behrens (1):
      rust: error: declare errors using macro

Gary Guo (9):
      rust: macros: add `#[vtable]` proc macro
      rust: macros: take string literals in `module!`
      rust: str: add `BStr` type
      rust: str: add `b_str!` macro
      rust: str: add `CStr` type
      rust: str: implement several traits for `CStr`
      rust: str: add `c_str!` macro
      rust: add `build_error` crate
      rust: build_assert: add `build_{error,assert}!` macros

Miguel Ojeda (7):
      rust: prelude: split re-exports into groups
      rust: print: add more `pr_*!` levels
      rust: print: add `pr_cont!` macro
      rust: samples: add `rust_print` example
      rust: alloc: add `RawVec::try_with_capacity_in()` constructor
      rust: alloc: add `Vec::try_with_capacity{,_in}()` constructors
      rust: static_assert: add `static_assert!` macro

Milan Landaverde (1):
      rust: str: add `CStr` unit tests

Niklas Mohrin (1):
      rust: std_vendor: add `dbg!` macro based on `std`'s one

Viktor Garske (1):
      rust: error: add codes from `errno-base.h`

Wedson Almeida Filho (7):
      rust: error: add `From` implementations for `Error`
      rust: prelude: add `error::code::*` constant items
      rust: str: add `Formatter` type
      rust: str: add `CString` type
      rust: str: add `fmt!` macro
      rust: types: add `Either` type
      rust: types: add `Opaque` type

 lib/Kconfig.debug                 |  16 ++
 rust/Makefile                     |  22 +-
 rust/alloc/raw_vec.rs             |  33 ++-
 rust/alloc/vec/mod.rs             |  89 +++++++
 rust/build_error.rs               |  31 +++
 rust/exports.c                    |   5 +
 rust/kernel/build_assert.rs       |  82 ++++++
 rust/kernel/error.rs              |  90 ++++++-
 rust/kernel/lib.rs                |   9 +
 rust/kernel/prelude.rs            |  20 +-
 rust/kernel/print.rs              | 214 +++++++++++++++-
 rust/kernel/static_assert.rs      |  34 +++
 rust/kernel/std_vendor.rs         | 163 ++++++++++++
 rust/kernel/str.rs                | 523 +++++++++++++++++++++++++++++++++++++-
 rust/kernel/types.rs              |  37 +++
 rust/macros/concat_idents.rs      |  23 ++
 rust/macros/helpers.rs            |  24 +-
 rust/macros/lib.rs                | 108 +++++++-
 rust/macros/module.rs             |  10 +-
 rust/macros/vtable.rs             |  95 +++++++
 samples/rust/Kconfig              |  10 +
 samples/rust/Makefile             |   1 +
 samples/rust/rust_minimal.rs      |   8 +-
 samples/rust/rust_print.rs        |  54 ++++
 scripts/generate_rust_analyzer.py |   8 +-
 25 files changed, 1667 insertions(+), 42 deletions(-)
 create mode 100644 rust/build_error.rs
 create mode 100644 rust/kernel/build_assert.rs
 create mode 100644 rust/kernel/static_assert.rs
 create mode 100644 rust/kernel/std_vendor.rs
 create mode 100644 rust/kernel/types.rs
 create mode 100644 rust/macros/concat_idents.rs
 create mode 100644 rust/macros/vtable.rs
 create mode 100644 samples/rust/rust_print.rs
  

Comments

Linus Torvalds Dec. 13, 2022, 1:18 a.m. UTC | #1
On Sat, Dec 10, 2022 at 4:56 PM <ojeda@kernel.org> wrote:
>
> - String and formatting: new types `CString`, `CStr`, `BStr` and
>   `Formatter`; new macros `c_str!`, `b_str!` and `fmt!`.

Heh. You have an unusual habit of using the back-tick instead of the
regular single quote character. It's not wrong, just surprising. I
ended up just replacing it with the regular single quote.

Maybe I'm biased against it, because I grew up with it being a dead
key, and while my current keyboard has it very easily accessible, in
many situations it's actually very inconvenient (ie it ends up being a
dead key to generate acute grave on many European keyboard layouts).

Anyway, not a big deal. Just odd enough for me to react to that thing.

At least you didn't do the thing where you are trying to match it with
the tick going the *other* way (which doesn't even exist in ASCII and
requires UTF-8), which is literally impossible to type without going
through strange contortions.

Or, worse yet, do the crazy traditional "pair apostrophe with
backtick" that also looks very ugly in most fonts because the two
characters aren't even visually symmetrical in modern fonts and often
have different weights.

So it's unusual, and I edited it in the commit message, but it's not
one of the actively horrid options.

              Linus
  
pr-tracker-bot@kernel.org Dec. 13, 2022, 1:39 a.m. UTC | #2
The pull request you sent on Sun, 11 Dec 2022 01:56:09 +0100:

> https://github.com/Rust-for-Linux/linux tags/rust-6.2

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/96f42635684739cb563aa48d92d0d16b8dc9bda8

Thank you!
  
Miguel Ojeda Dec. 13, 2022, 11:25 a.m. UTC | #3
On Tue, Dec 13, 2022 at 2:18 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> Heh. You have an unusual habit of using the back-tick instead of the
> regular single quote character. It's not wrong, just surprising. I
> ended up just replacing it with the regular single quote.

As Nick pointed out, it is indeed Markdown. Rust code uses it e.g. for
function docs, so we use it for commit messages too and so on, which
makes it nice to copy-paste content from one part to the other etc.

When I wrote the tag message, I wondered whether to use the single
quotes, since I knew you keep consistent merge messages, but didn't
know if that included editing quotes. Thus I decided to just give it a
go and see what you edited or not for the next time.

> Maybe I'm biased against it, because I grew up with it being a dead
> key, and while my current keyboard has it very easily accessible, in
> many situations it's actually very inconvenient (ie it ends up being a
> dead key to generate acute grave on many European keyboard layouts).

Yeah, I share that pain in the usual Spanish layout... Until Markdown
started to become popular, I never used that key.

Since it is essentially a "normalized" plain text format (i.e. close
to what one would write anyway), I started using it for my notes at
some point given the growing support in text editors and websites, and
eventually in my emails too.

Cheers,
Miguel