-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Use ufcs in derive(Debug) #81294
Merged
bors
merged 5 commits into
rust-lang:master
from
pnkfelix:issue-81211-use-ufcs-in-derive-debug
Feb 3, 2021
Merged
Use ufcs in derive(Debug) #81294
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2307d08
Use UFCS instead of method calls in `derive(Debug)`. See issue 81211 …
pnkfelix ff4665f
Regression tests for issue 81211.
pnkfelix 532332f
Test exploring the interactions between all of the different kinds of…
pnkfelix a7745d9
placate tidy.
pnkfelix 1783c47
bless the coverage-spanview output. Cc #81688.
pnkfelix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just remove the
expr_method_call
function entirely (or perma-deprecate it so ppl searching for it get an explanation of why they should use ufcs)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I considered this as well. Probably a good idea, especially if this is the last use of it. I'll try to look into that.