Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

derive: snippet support #11

Closed
Tracked by #10
zkat opened this issue Aug 16, 2021 · 0 comments · Fixed by #18
Closed
Tracked by #10

derive: snippet support #11

zkat opened this issue Aug 16, 2021 · 0 comments · Fixed by #18

Comments

@zkat
Copy link
Owner

zkat commented Aug 16, 2021

The current derive macro supports code, help, and derive, but doesn't really handle the snippet part of miette. Extend the macro so that you can write stuff like this:

#[derive(Debug, Error, Diagnostic)]
#[diagnostic(code(math::bad_arithmetic))]
#[error("Tried to add a {bad_type} to a {good_type}")]
pub struct MyErr {
  good_type: Type,
  bad_type: Type,
  bad_var: Var,
  src: PathBuf,

  // The overall span of code that will be rendered.
  #[context(src, "This region is where things went wrong")]
  ctx: SourceSpan,

  // A highlight (basically something to underline)
  #[highlight(ctx, "This is a {bad_type}")]
  bad_var_span: SourceSpan,

  // Can have multiple highlights.
  #[highlight(ctx, "This is a {good_type}")]
  good_var_span: SourceSpan,
}
This was referenced Aug 16, 2021
@zkat zkat closed this as completed in #18 Aug 17, 2021
zkat added a commit that referenced this issue Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant