Hi On Wed, May 6, 2026 at 3:01 PM Markus Armbruster <[email protected]> wrote: > > FYI, I just posted patches to get rid of QAPI type String:
ok, I'll review it. (fwiw, I am working on adding qapi-type and better qom-prop qapi interop api) > > Subject: [PATCH 0/4] qapi/net: Some doc improvement and cleanup > Date: Wed, 6 May 2026 12:54:17 +0200 > Message-ID: <[email protected]> > > https://lore.kernel.org/qemu-devel/[email protected]/ > > > Markus Armbruster <[email protected]> writes: > > [...] > > >> +def rs_name(name: str) -> str: > >> + """ > >> + Map @name to a valid, possibly raw Rust identifier. > >> + """ > >> + name = re.sub(r'[^A-Za-z0-9_]', '_', name) > >> + if name[0].isnumeric(): > > > > .isdigit()? It's what c_name() uses... > > > >> + name = '_' + name > > > > In review of v1, I pointed to "The Rust Reference" > > > > Identifiers starting with an underscore are typically used to > > indicate an identifier that is intentionally unused, and will > > silence the unused warning in rustc. > > > > https://doc.rust-lang.org/reference/identifiers.html > > > > You replied "In this case it doesn't really matter: public items (such > > as QAPI enum entries, or struct fields) do not raise the unused warning > > anyway." > > > > What gives us confidence rs_name() will only be used where it doesn't > > really matter? > > > >> + # based from the list: > >> + # https://doc.rust-lang.org/reference/keywords.html > >> + if name in ('Self', 'abstract', 'as', 'async', > >> + 'await', 'become', 'box', 'break', > >> + 'const', 'continue', 'crate', 'do', > >> + 'dyn', 'else', 'enum', 'extern', > >> + 'false', 'final', 'fn', 'for', > >> + 'if', 'impl', 'in', 'let', > >> + 'loop', 'macro', 'match', 'mod', > >> + 'move', 'mut', 'override', 'priv', > >> + 'pub', 'ref', 'return', 'self', > >> + 'static', 'struct', 'super', 'trait', > >> + 'true', 'try', 'type', 'typeof', > >> + 'union', 'unsafe', 'unsized', 'use', > >> + 'virtual', 'where', 'while', 'yield'): > >> + name = 'r#' + name > > > > TIL... > > > >> + # avoid some clashes with the standard library > >> + if name in ('String',): > >> + name = 'Qapi' + name > > > > This hides the unwise use of 'String' in qapi/net.json from Rust. I'd > > rather rename that one. > > [...] > >
