Repository: rust-lang/rustfmt (rust)

Issue:
Bug/quirk: newline inconsistencies in argument list
It seems odd that these are inconsistent, especially since trace and debug are both five letter words:

```rust
use log::{debug, trace};

pub fn main() {
    trace!(
        "get some longer length in here yes yes {} {}",
        "hello",
        "world"
    );
    debug!(
        "get some longer length in here yes yes {} {}",
        "hello", "world"
    );
}
```

Notice the newline present in the `trace` arguments, but not in the `debug` arguments. Other functions seem to follow the same format as the former; perhaps this is something specific with `debug`? Not sure why that would be :shrug: 

Versions tested:
- stable: `rustfmt 1.6.0-stable (a28077b 2023-12-04)`
- nightly: `rustfmt 1.7.0-nightly (3d0e6be 2023-12-21)`

Pull request description:
Fix trace! args overflow
Fixes #5987

Patch:
diff --git a/src/comment.rs b/src/comment.rs
index f7cd7cef..44b3eb80 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -173,10 +173,7 @@ pub(crate) fn combine_strs_with_missing_comments(
 ) -> Option<String> {
     trace!(
         "combine_strs_with_missing_comments `{}` `{}` {:?} {:?}",
-        prev_str,
-        next_str,
-        span,
-        shape
+        prev_str, next_str, span, shape
     );
 
     let mut result =
diff --git a/src/overflow.rs b/src/overflow.rs
index d81bf24d..11060f46 100644
--- a/src/overflow.rs
+++ b/src/overflow.rs
@@ -8,8 +8,8 @@ use rustc_ast::{ast, ptr};
 use rustc_span::Span;
 
 use crate::closures;
-use crate::config::lists::*;
 use crate::config::Version;
+use crate::config::{lists::*, Config};
 use crate::expr::{
     can_be_overflowed_expr, is_every_expr_simple, is_method_call, is_nested_call, is_simple_expr,
     rewrite_cond,
@@ -60,6 +60,13 @@ const SPECIAL_CASE_MACROS: &[(&str, usize)] = &[
     ("debug_assert_ne!", 2),
 ];
 
+/// Additional special case macros for version 2; these are separated to avoid breaking changes in
+/// version 1.
+const SPECIAL_CASE_MACROS_V2: &[(&str, usize)] = &[
+    // From the `log` crate.
+    ("trace!", 0),
+];
+
 const SPECIAL_CASE_ATTR: &[(&str, usize)] = &[
     // From the `failure` crate.
     ("fail", 0),
@@ -182,12 +189,17 @@ impl<'a> OverflowableItem<'a> {
         }
     }
 
-    fn special_cases(&self) -> &'static [(&'static str, usize)] {
-        match self {
+    fn special_cases(&self, config: &Config) -> impl Iterator<Item = &(&'static str, usize)> {
+        let base_cases = match self {
             OverflowableItem::MacroArg(..) => SPECIAL_CASE_MACROS,
             OverflowableItem::NestedMetaItem(..) => SPECIAL_CASE_ATTR,
             _ => &[],
-        }
+        };
+        let additional_cases = match (self, config.version()) {
+            (OverflowableItem::MacroArg(..), Version::Two) => SPECIAL_CASE_MACROS_V2,
+            _ => &[],
+        };
+        base_cases.iter().chain(additional_cases)
     }
 }
 
@@ -551,7 +563,7 @@ impl<'a> Context<'a> {
 
                     if tactic == DefinitiveListTactic::Vertical {
                         if let Some((all_simple, num_args_before)) =
-                            maybe_get_args_offset(self.ident, &self.items)
+                            maybe_get_args_offset(self.ident, &self.items, &self.context.config)
                         {
                             let one_line = all_simple
                                 && definitive_tactic(
@@ -771,11 +783,11 @@ fn no_long_items(list: &[ListItem], short_array_element_width_threshold: usize)
 pub(crate) fn maybe_get_args_offset(
     callee_str: &str,
     args: &[OverflowableItem<'_>],
+    config: &Config,
 ) -> Option<(bool, usize)> {
     if let Some(&(_, num_args_before)) = args
         .get(0)?
-        .special_cases()
-        .iter()
+        .special_cases(config)
         .find(|&&(s, _)| s == callee_str)
     {
         let all_simple = args.len() > num_args_before


Test patch:
diff --git a/tests/source/issue-5987/two.rs b/tests/source/issue-5987/two.rs
new file mode 100644
index 00000000..e20026b5
--- /dev/null
+++ b/tests/source/issue-5987/two.rs
@@ -0,0 +1,13 @@
+// rustfmt-version: Two
+
+fn main() {
+    trace!(
+        "get some longer length in here yes yes {} {}",
+        "hello",
+        "world"
+    );
+    debug!(
+        "get some longer length in here yes yes {} {}",
+        "hello", "world"
+    );
+}
diff --git a/tests/target/issue-5987/one.rs b/tests/target/issue-5987/one.rs
new file mode 100644
index 00000000..3c995ed2
--- /dev/null
+++ b/tests/target/issue-5987/one.rs
@@ -0,0 +1,13 @@
+// rustfmt-version: One
+
+fn main() {
+    trace!(
+        "get some longer length in here yes yes {} {}",
+        "hello",
+        "world"
+    );
+    debug!(
+        "get some longer length in here yes yes {} {}",
+        "hello", "world"
+    );
+}
diff --git a/tests/target/issue-5987/two.rs b/tests/target/issue-5987/two.rs
new file mode 100644
index 00000000..8fd92fc1
--- /dev/null
+++ b/tests/target/issue-5987/two.rs
@@ -0,0 +1,12 @@
+// rustfmt-version: Two
+
+fn main() {
+    trace!(
+        "get some longer length in here yes yes {} {}",
+        "hello", "world"
+    );
+    debug!(
+        "get some longer length in here yes yes {} {}",
+        "hello", "world"
+    );
+}