Skip to content

Automatic fix for nonstandard_macro_braces fails #17830

Open

Description

@djc

Summary

For this issue:

warning: use of irregular braces for `format!` macro
   --> crates/resolver/src/hosts.rs:246:9
    |
246 |         format! {"{server_path}/crates/resolver/tests"}
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `format!("{server_path}/crates/resolver/tests");`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.99.0/index.html#nonstandard_macro_braces
    = note: `#[warn(clippy::nonstandard_macro_braces)]` on by default

--fix produced this diff:

diff --git a/crates/resolver/src/hosts.rs b/crates/resolver/src/hosts.rs
index b314f4665..92ce94c0d 100644
--- a/crates/resolver/src/hosts.rs
+++ b/crates/resolver/src/hosts.rs
@@ -243,7 +243,7 @@ mod tests {
 
     fn tests_dir() -> String {
         let server_path = env::var("TDNS_WORKSPACE_ROOT").unwrap_or_else(|_| "../..".to_owned());
-        format! {"{server_path}/crates/resolver/tests"}
+        format!("{server_path}/crates/resolver/tests");
     }
 

resulting in this compilation failure:

error[E0308]: mismatched types
   --> crates/resolver/src/hosts.rs:244:23
    |
244 |     fn tests_dir() -> String {
    |        ---------      ^^^^^^ expected `String`, found `()`
    |        |
    |        implicitly returns `()` as its body has no tail or `return` expression
245 |         let server_path = env::var("TDNS_WORKSPACE_R...
246 |         format!("{server_path}/crates/resolver/tests");
    |                                                       - help: remove this semicolon to return this value

Original code:

https://github.com/hickory-dns/hickory-dns/blob/ec87f21341219d6be18f1cf1fe90ec2f0e975653/crates/resolver/src/hosts.rs#L246

With stable clippy from Rust 1.99.

Activity

  1. added
    C-bugCategory: Clippy is not doing the correct thing
    on Oct 1, 2026
  2. added
    good first issueThese issues are a good way to get started with Clippy
    L-suggestionLint: Improving, adding or fixing lint suggestions
    I-suggestion-causes-bugIssue: The suggestion compiles but changes the code to behave in an unintended way
    on Oct 1, 2026
  3. djc commented on Oct 1, 2026

    @djc
    ContributorAuthor

    I-suggestion-causes-bug is described as "suggestion compiles", but that's not the case here, FWIW.

  4. added
    I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied
    and removed
    I-suggestion-causes-bugIssue: The suggestion compiles but changes the code to behave in an unintended way
    on Oct 1, 2026
  5. CommanderStorm commented on Oct 1, 2026

    @CommanderStorm
    Contributor

    ah thanks ^^

  6. codediebere commented on Oct 1, 2026

    @codediebere
    Contributor

    uhmmmm... I'm thinking of giving this a shot.
    Can I go ahead?

  7. CommanderStorm commented on Oct 1, 2026

    @CommanderStorm
    Contributor

    sure, that is why I marked it as a good first issue ^^

    FYI, to communicate this to other contributors, you can @rustbot claim

  8. codediebere commented on Oct 1, 2026

    @codediebere
    Contributor

    Alright.. Thank you!

  9. codediebere commented on Oct 1, 2026

    @codediebere
    Contributor

    @rustbot claim

  10. jny0444 commented on Oct 14, 2026

    @jny0444

    @rustbot claim

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions