-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows disabling `fmt::Debug` derive and debug formatting.
- Loading branch information
Showing
13 changed files
with
162 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ compile-flags: -Zdebug-fmt-detail=full | ||
//@ run-pass | ||
#![feature(debug_fmt_detail)] | ||
#![allow(dead_code)] | ||
#![allow(unused)] | ||
|
||
#[derive(Debug)] | ||
struct Foo { | ||
bar: u32, | ||
} | ||
|
||
fn main() { | ||
let s = format!("Still works: {:?} '{:?}'", cfg!(debug_fmt_detail = "full"), Foo { bar: 1 }); | ||
assert_eq!("Still works: true 'Foo { bar: 1 }'", s); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//@ compile-flags: -Zdebug-fmt-detail=none | ||
//@ run-pass | ||
#![feature(debug_fmt_detail)] | ||
#![allow(dead_code)] | ||
#![allow(unused)] | ||
|
||
#[derive(Debug)] | ||
struct Foo { | ||
bar: u32, | ||
} | ||
|
||
#[derive(Debug)] | ||
enum Baz { | ||
Quz, | ||
} | ||
|
||
#[cfg(debug_fmt_detail = "full")] | ||
compile_error!("nope"); | ||
|
||
#[cfg(debug_fmt_detail = "none")] | ||
struct Custom; | ||
|
||
impl std::fmt::Debug for Custom { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.write_str("custom_fmt") | ||
} | ||
} | ||
|
||
fn main() { | ||
let c = Custom; | ||
let s = format!("Debug is '{:?}', '{:#?}', and '{c:?}'", Foo { bar: 1 }, Baz::Quz); | ||
assert_eq!("Debug is '', '', and ''", s); | ||
|
||
let f = 3.0; | ||
let s = format_args!("{:?}x{:#?}y{f:?}", 1234, "can't debug this").to_string(); | ||
assert_eq!("xy", s); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//@ compile-flags: -Zdebug-fmt-detail=shallow | ||
//@ run-pass | ||
#![feature(debug_fmt_detail)] | ||
#![allow(dead_code)] | ||
#![allow(unused)] | ||
|
||
#[derive(Debug)] | ||
struct Foo { | ||
bar: u32, | ||
bomb: Bomb, | ||
} | ||
|
||
#[derive(Debug)] | ||
enum Baz { | ||
Quz, | ||
} | ||
|
||
struct Bomb; | ||
|
||
impl std::fmt::Debug for Bomb { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
panic!() | ||
} | ||
} | ||
|
||
fn main() { | ||
let s = format!("Debug is '{:?}' and '{:#?}'", Foo { bar: 1, bomb: Bomb }, Baz::Quz); | ||
assert_eq!("Debug is 'Foo' and 'Quz'", s); | ||
|
||
let f = 3.0; | ||
let s = format_args!("{:?}{:#?}{f:?}", 1234, cfg!(debug_fmt_detail = "shallow")).to_string(); | ||
assert_eq!("1234true3.0", s); | ||
} |