[PATCH] D102579: [Demangle][Rust] Parse tuples

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 16 10:55:30 PDT 2021


dblaikie accepted this revision.
dblaikie added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/lib/Demangle/RustDemangle.cpp:450-451
+    }
+    if (I == 1)
+      print(",");
+    print(")");
----------------
tmiasko wrote:
> dblaikie wrote:
> > Looks a bit awkward to print a comma after a single argument (`(_,)`) - is that necessary? (does it disambiguate this with some other case that has only a list of 1 between parentheses?)
> The intention is to match Rust language syntax which requires a comma after one element tuples to disambiguate them from parenthesized types.
Cool - thanks for the context!

And stylistically, that trailing comma is usually written without a space after it, unlike separating commas?

Pity, this could come out more naturally from the algorithm if that was the case (always printing ", " after every type - rather than having to special case)

I guess you could do it this way:
```
for (...) {
  if (I > 0)
    print(" ");
  demangleType();
  print(",");
}
```
Marginally less special casing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102579/new/

https://reviews.llvm.org/D102579



More information about the llvm-commits mailing list