public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jesung Yang" <y.j3ms.n@gmail.com>
To: "Tamir Duberstein" <tamird@kernel.org>,
	"Jesung Yang" <y.j3ms.n@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] scripts: generate_rust_analyzer.py: add versioning infrastructure
Date: Sun, 15 Mar 2026 16:01:34 +0900	[thread overview]
Message-ID: <DH35VGPQ4P8K.2FOAKEK1K2S3Z@gmail.com> (raw)
In-Reply-To: <177308129157.19064.2462259833624603051@1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa>

On Tue Mar 10, 2026 at 3:34 AM KST, Tamir Duberstein wrote:
> On Sun, 08 Mar 2026 08:30:34 +0900, Jesung Yang <y.j3ms.n@gmail.com> wrote:
[...]
>> @@ -335,12 +390,90 @@ def generate_crates(
>>              append_crate(
>>                  name,
>>                  path,
>> -                [core, kernel, pin_init],
>> +                sysroot_deps(core) + [kernel, pin_init],
>>                  cfg=generated_cfg,
>> +                crate_attrs=["no_std"],
>>              )
>
> Can you help me understand this addition? It's not mentioned except in the
> cover letter as a diff from v2.

Assuming you're referring to `crate_attrs=["no_std"]`, this makes
rust-analyzer treat crates in `driver/` and `samples/` as if
`#![no_std]` were specified in their crate roots (they don't contain
`#![no_std]` themselves).

(Actually, I'm uncertain if this is the part you wanted me to elaborate
on. Please let me know if you need more context.)

>> +def generate_rust_project(
>> +    version_info: RaVersionInfo,
>> +    srctree: pathlib.Path,
>> +    objtree: pathlib.Path,
>> +    sysroot: pathlib.Path,
>> +    sysroot_src: pathlib.Path,
>> +    external_src: Optional[pathlib.Path],
>> +    cfgs: List[str],
>> +    core_edition: str,
>> +) -> RustProject:
>> +    assert len(BASELINES) == 1, "Exhaustiveness check: update if branches!"
>> +
>> +    ctx: RaVersionCtx
>> +
>
> Could we make RaVersionInfo an enum? That would allow mypy to do this check
> (using `match`) rather than relying on this.

I think you want something like the following?

@enum.unique
class RaVersionInfo(enum.Enum):
    V20240311 = (
        datetime.strptime("2024-03-11", "%Y-%m-%d"),
        ra_version=(0, 3, 1877),
        rust_version=(1, 78, 0),
    )
    V20251222 = ( ... )

    def __init__(
        self,
        release_date: date,
        ra_version: Version,
        rust_version: Version,
    ) -> "RaVersionInfo":
        self.release_date = release_date
        self.ra_version = ra_version
        self.rust_version = rust_version

    @staticmethod
    def default() -> "RaVersionInfo":
        return RaVersionInfo.V20240311

At the call site, we can access each field via the dot operator. This
not only removes `BASELINES` and `DEFAULT_BASELINE` but also ensures
that we only match against valid variants, which helps reduce the chance
of human error. But unfortunately, `match` was introduced in Python
3.10, whereas the kernel only requires Python 3.9 [1]. This means we
cannot leverage mypy's exhaushtiveness check yet. Perhaps I could leave
a TODO to remove the assertion and switch to `match` once Python 3.10 is
adopted.

The rest of the feedback sounds reasonable to me.

[1] https://docs.kernel.org/process/changes.html#kernel-documentation

Best regards,
Jesung

  reply	other threads:[~2026-03-15  7:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07 23:30 [PATCH v3 0/2] rust: take advantage of newer rust-analyzer features Jesung Yang via B4 Relay
2026-03-07 23:30 ` [PATCH v3 1/2] scripts: generate_rust_analyzer.py: add versioning infrastructure Jesung Yang via B4 Relay
2026-03-09 18:34   ` Tamir Duberstein
2026-03-15  7:01     ` Jesung Yang [this message]
2026-03-16 14:37       ` Tamir Duberstein
2026-03-17  9:05         ` Jesung Yang
2026-03-07 23:30 ` [PATCH v3 2/2] scripts: generate_rust_analyzer.py: fix IDE support for primitive types Jesung Yang via B4 Relay
2026-03-09 18:34   ` Tamir Duberstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DH35VGPQ4P8K.2FOAKEK1K2S3Z@gmail.com \
    --to=y.j3ms.n@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox