Skip to content

Error messaging for non Lit::str doc comments #61

@20jasper

Description

@20jasper

When anything other than a Lit::str is passed to a doc attribute, displaydoc will panic with "not implemented" instead of instructing the user to pass a literal

There are some reasonable usecases for non literals like include_str! to be used in doc attributes. It seems in a prior version, there was a more specific message, as seen in #36

What do y'all think of providing a more specific message instead of using a raw unimplemented! macro? Alternatively, a select list of macros like concat!, include_str! could be evaluated further, though of course this option is far more complex

Minimal reproduction

#[derive(Display)]
#[doc = include_str!("./hi.txt")]
struct Foo;
error: proc-macro derive panicked
 --> tests/ui/non_string_doc_expr.rs:3:10
  |
3 | #[derive(Display)]
  |          ^^^^^^^
  |
  = help: message: not implemented

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions