From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 800C2330648 for ; Tue, 17 Mar 2026 09:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773738336; cv=none; b=pur3lbNYSpxsJNbBocy7Gc7WNwsaaE2k8YKYWNMRYTta3iOOfqtg/meIRMfh9Rhk3dXcv163g6YDENHsPnc9oazy0XRc5I8zZttviQhh/V7GroEb9QTH+77OwRU9YkVxIxnKfsnCKzaRO0UDf0Lm6U2qb7YJFSwnRi4KOTDkOgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773738336; c=relaxed/simple; bh=Nac5SCySrUfnjaJGd+Y1c81gZpkBA6lghrWoXG0djrg=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc: References:In-Reply-To; b=jxTyjcPCRscewttEszfmeBRtPMwJfQeggQaLHr3l//ZH8x/v5pJOYQbctWlIXFwivED8tT7iD3T/pSz8wYIC2idrZhvJ/dYe5I7E6K6AD+RAXa1toFmxf7qb3hr0GxoO1faGUL6EROcrDGUTAtQbOr1CmlFVpm8LtQvVOx3mIwo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LoxZoVf4; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LoxZoVf4" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-8297310ce0aso2955741b3a.2 for ; Tue, 17 Mar 2026 02:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773738334; x=1774343134; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=teNErOVssjJSA3ZrFm7FBopN/pWjPWMmAh2R9jtM+io=; b=LoxZoVf4l6eiUMRBY0JErfexMnRHBL6EWrr5HFhm3gAqSoQr4aoJtlM/D2Sk1UL3F/ TqBwrh1rLH04t8phDbOqxEVpMx2goMPfOk/wLGqg6X2qUVd3qB6L2XyTGJGieGuMQ4dc QdEDyoP7Nyq/vPTmL5OXgVHPhKs/+liqlay9pdLK2NRziPKq5Ij56S5gy7fgr1YfovWi k4+zuc3nnNk0HgDp3kq+iZS2rQrp60jKzbWfCUuDSL+0OuMjsgNaEA9zrxABu+PLCyhz DhigbZd7QuN/ZzKXyMYA5KxfcPinE/y3TXk+qr+L9L1a9+w9cK/Ab0XcZzd52u3Wsn+R zikw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773738334; x=1774343134; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=teNErOVssjJSA3ZrFm7FBopN/pWjPWMmAh2R9jtM+io=; b=GeLZH4+cCSQ9P5hJyhasET/c02GpwP2G+XI9tANEA2gkM5zA4v3nr1aIX074WkcTz6 y+lQdDrRfl7ud8Trp/g1NltELHu6JoRR9HRY9j7qkvKEgQTHTnE6nd3SmR7vYEEqfeGY zUVm54J2FzWCYgAuNtd7QA3o+hYjrjVa1EM1Hg3jmZ6mjYwVBhCDKmg56mLbpipJcT3T X/gzhJvFQnamYBJ5Ek7X4HxXZfDPsyx93nI+tRYqujPpZzmBMCqKloJnHgVlj3SwVF3H ncLtu9YEjHDfUzMK9TXUjj6shgZhDiKEo4zjUnLPmgh1tuSLz3D9VWRhvkZ0Z0dvitIE ++8w== X-Forwarded-Encrypted: i=1; AJvYcCUJWUB0p2/vGif4XFj3jYm2iNJv2heaw5jnstRiSUqBeYCm/lryTg/p+OsWyV1vyzjmaGfXFpZwGymqg4I=@vger.kernel.org X-Gm-Message-State: AOJu0YzHClM4Yh9WIV6ESDWI+ZliPtMOl+MANTAbzlF36Mi/Fuil5+70 XL29XYHwepE5pl2+6O8oZlkNhn+7ZHiyX7cNiaccVTmWWLndxYLa+e/7 X-Gm-Gg: ATEYQzwBX3cGkxx3cMwSB0PTkiVEwAwxj4p7d77Hat9PqY8odGu19f4i0xNkiFxHEvK uYpUc1wwv9ZKsqlzdJTnkJXCxJaR6oo+VZLEX+kvpn/C7KvG9sEEImm25SLm+9aJT95CdcvsaN7 UyoxePEf5DVM2tjtoJEiByEzSH2cbkd0CtrOna41p5IvcNBlfvFiFfFiGhfG4BPdxidxAxmTD5q upF7I17jtjT5HFySq9XjbSOErG7az4fa9tA7ysdsEMCki3TzuQdUI3MWi1wIPCGS4yYj4Ubx+Y0 CDfozqf5pBWAp9Q98sUisvSxM/ISP0MzuUkeoEFZwHlnOsjDW19d5+myfbZ0IQZSpJ7yM2LmZUQ qSDE8vM0RtxrMsbs6wUEDB0jJ6L5B/cikw935+4YkNLBwEANd2/yZ7SlavtfI2Gm5A31c+CPyZr U5VS+ytUGZ4xfRR1e6LQ== X-Received: by 2002:a05:6a00:3d13:b0:827:32d7:668f with SMTP id d2e1a72fcca58-82a196f61a5mr15042936b3a.6.1773738333664; Tue, 17 Mar 2026 02:05:33 -0700 (PDT) Received: from localhost ([112.149.32.52]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a072603c0sm15131413b3a.22.2026.03.17.02.05.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Mar 2026 02:05:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 17 Mar 2026 18:05:27 +0900 Message-Id: Subject: Re: [PATCH v3 1/2] scripts: generate_rust_analyzer.py: add versioning infrastructure From: "Jesung Yang" To: "Tamir Duberstein" , "Jesung Yang" Cc: "Miguel Ojeda" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Boqun Feng" , "Eliot Courtney" , , X-Mailer: aerc 0.21.0 References: <20260308-ra-fix-primitive-v3-0-598017bcefd8@gmail.com> <20260308-ra-fix-primitive-v3-1-598017bcefd8@gmail.com> <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> <177367187873.68572.13759534078660151207@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> In-Reply-To: <177367187873.68572.13759534078660151207@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 Mon Mar 16, 2026 at 11:37 PM KST, Tamir Duberstein wrote: > On 2026-03-15 16:01 +0900, Jesung Yang wrote: >> On Tue Mar 10, 2026 at 3:34 AM KST, Tamir Duberstein wrote: >> > On Sun, 08 Mar 2026 08:30:34 +0900, Jesung Yang w= rote: >> [...] >> >> @@ -335,12 +390,90 @@ def generate_crates( >> >> append_crate( >> >> name, >> >> path, >> >> - [core, kernel, pin_init], >> >> + sysroot_deps(core) + [kernel, pin_init], >> >> cfg=3Dgenerated_cfg, >> >> + crate_attrs=3D["no_std"], >> >> ) >> > >> > Can you help me understand this addition? It's not mentioned except in= the >> > cover letter as a diff from v2. >>=20 >> Assuming you're referring to `crate_attrs=3D["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). > > Yes, that's what I was referring to. Still, it's not clear to me why > that is part of this patch. Is it intentional, or incidental? Ah, now I see your point. Yes, this should be in `scripts:=20 generate_rust_analyzer.py: fix IDE support for primitive types` (PATCH [2/2]). >> >> +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) =3D=3D 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. >>=20 >> I think you want something like the following? >>=20 >> @enum.unique >> class RaVersionInfo(enum.Enum): >> V20240311 =3D ( >> datetime.strptime("2024-03-11", "%Y-%m-%d"), >> ra_version=3D(0, 3, 1877), >> rust_version=3D(1, 78, 0), >> ) >> V20251222 =3D ( ... ) >>=20 >> def __init__( >> self, >> release_date: date, >> ra_version: Version, >> rust_version: Version, >> ) -> "RaVersionInfo": >> self.release_date =3D release_date >> self.ra_version =3D ra_version >> self.rust_version =3D rust_version >>=20 >> @staticmethod >> def default() -> "RaVersionInfo": >> return RaVersionInfo.V20240311 >>=20 >> 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. > > That sounds reasonable to me. You can also name the variants in a more > semantically meaningful way like DEFAULT, SUPPORTS_XXX, etc. Sounds good to me. On second thought, I think we can also take advantage of mypy's static exhaustiveness check by introducing `assert_never`. I'll send v4 and let's see if it works for you too. > Finally, `__init__` should return None, not Self. Absolutely, I'll make that change. > Thanks for working on this! My pleasure! Best regards, Jesung