forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#81294 - pnkfelix:issue-81211-use-ufcs-in-deri…
…ve-debug, r=oli-obk Use ufcs in derive(Debug) Cc rust-lang#81211. (Arguably this *is* the fix for it.)
- Loading branch information
Showing
6 changed files
with
315 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,8 @@ symbols! { | |
Copy, | ||
Count, | ||
Debug, | ||
DebugStruct, | ||
DebugTuple, | ||
Decodable, | ||
Decoder, | ||
Default, | ||
|
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,40 @@ | ||
// run-pass | ||
#![allow(warnings)] | ||
|
||
#[derive(Debug)] | ||
pub struct Bar { pub t: () } | ||
|
||
impl<T> Access for T {} | ||
pub trait Access { | ||
fn field(&self, _: impl Sized, _: impl Sized) { | ||
panic!("got into Access::field"); | ||
} | ||
|
||
fn finish(&self) -> Result<(), std::fmt::Error> { | ||
panic!("got into Access::finish"); | ||
} | ||
|
||
fn debug_struct(&self, _: impl Sized, _: impl Sized) { | ||
panic!("got into Access::debug_struct"); | ||
} | ||
} | ||
|
||
impl<T> MutAccess for T {} | ||
pub trait MutAccess { | ||
fn field(&mut self, _: impl Sized, _: impl Sized) { | ||
panic!("got into MutAccess::field"); | ||
} | ||
|
||
fn finish(&mut self) -> Result<(), std::fmt::Error> { | ||
panic!("got into MutAccess::finish"); | ||
} | ||
|
||
fn debug_struct(&mut self, _: impl Sized, _: impl Sized) { | ||
panic!("got into MutAccess::debug_struct"); | ||
} | ||
} | ||
|
||
fn main() { | ||
let bar = Bar { t: () }; | ||
assert_eq!("Bar { t: () }", format!("{:?}", bar)); | ||
} |
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,32 @@ | ||
// run-pass | ||
#![allow(warnings)] | ||
|
||
#[derive(Debug)] | ||
pub struct Foo<T>(pub T); | ||
|
||
use std::fmt; | ||
|
||
impl<T> Field for T {} | ||
impl<T> Finish for T {} | ||
impl Dt for &mut fmt::Formatter<'_> {} | ||
|
||
pub trait Field { | ||
fn field(&self, _: impl Sized) { | ||
panic!("got into field"); | ||
} | ||
} | ||
pub trait Finish { | ||
fn finish(&self) -> Result<(), std::fmt::Error> { | ||
panic!("got into finish"); | ||
} | ||
} | ||
pub trait Dt { | ||
fn debug_tuple(&self, _: &str) { | ||
panic!("got into debug_tuple"); | ||
} | ||
} | ||
|
||
fn main() { | ||
let foo = Foo(()); | ||
assert_eq!("Foo(())", format!("{:?}", foo)); | ||
} |
Oops, something went wrong.