Skip to content

§15.4.7 says :? is 'available for all types', but fn values, closures, dyn Trait, ranges and va_list have no Debug form; Rc/Arc/HashSet's generated form prints raw addresses #1564

Closed

Description

@ehartford

Surfaced by the D61 implementation (#1480). The table and the D61 text define a form for numbers, bool, str, structs, enums, Option/Result, Vec/array/slice, HashMap and BTreeMap; the text says every other type uses the generated (structural) form.

What the implementation does today:

  • a fn value, closure, dyn Trait, range or va_list under :? is a compile error naming the type (cannot format a value of type ... with :? — §15.4.7 gives it no Debug form) — no placeholder, per the no-silent-fallback rule; a Result whose Err type has no form still unwraps, its panic message just omits the payload.
  • a raw pointer prints its address (decimal, as emit-c already did; the LLVM backend used to read it as a C string).
  • Rc[T], Arc[T], HashSet[T], Handle[T] and other std handles print their generated struct form, which is a raw address (HashSet { ptr: 4298... }): not a placeholder, but not useful and not run-stable.
  • Box[T] is transparent (formats its payload), which the table does not say either; it is what recursion through Box needs and what Rust does.

A ruling is needed on: (a) whether Available for all types should hold for fn/dyn/range (and with what text), (b) rows for sets and the reference-counted pointers (Rust: {a, b} and transparent), (c) confirming Box transparency. Until then the D61 implementation errors on the first group and prints the generated form for the second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions