Skip to content

Custom polymorphic logging #2366

Closed
Closed
@catamorphism

Description

@catamorphism

The example I have in mind is:

#debug("%s", ty_to_str(tcx, t));

where t: ty::t. It would be great if I could write:

#debug("%?", tcx, t);

and not have to write out the call to ty_to_str. perhaps there could be an RTS hook to say "for type ty::t, call ty_to_str? I guess this could potentially be very hard since at runtime, tys probably aren't distinguished from ints. Alternately, (though not quite as awesomely), there could be another format string specifier or something for types. Basically, I just want to be able to pretty-print a type in a #fmt call without writing out ty_to_str, because that's a lot of characters :-) (And slightly more seriously, then I have to import ty_to_str, which requires remembering what module it lives in...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsA-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions