Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Issue 2581943005: Explicitly delete some Callback constructors to improve errors.

Created:
4 years ago by dcheng
Modified:
4 years ago
CC:
chromium-reviews, vmpstr+watch_chromium.org, danakj, tzik
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Explicitly delete some Callback constructors to improve errors. In general, this seems to improve the compile errors by pointing them directly at the source of the problem, rather than spamming the output with things like the list of all candidate overloads that didn't match. Approaches using static_assert() were also considered to improve readability even further; however, this causes type traits like std::is_constructible, std::is_assignable, and std::is_convertible to incorrectly return true when it should return false. On clang: - the error for copying OnceCallback now points directly at the deleted copy constructor. - the error for converting OnceCallback to RepeatingCallback now points directly at the deleted conversion constructor, rather than printing out all the candidates that failed to match. BUG=675328

Patch Set 1 #

Patch Set 2 : MSVC doesn't implement type traits correctly. #

Total comments: 7

Patch Set 3 : include clang-cl but exclude msvc #

Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -2 lines) Patch
M base/bind_unittest.cc View 1 2 2 chunks +4 lines, -0 lines 0 comments Download
M base/callback.h View 1 chunk +7 lines, -2 lines 0 comments Download
M base/callback_internal.h View 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 25 (16 generated)
dcheng
WDYT? The error for conversions is much better, but the error for copying is only ...
4 years ago (2016-12-19 11:07:40 UTC) #11
brucedawson
I am a huge fan of verbose commit text so if I think your commit ...
4 years ago (2016-12-19 19:16:00 UTC) #13
dcheng
https://codereview.chromium.org/2581943005/diff/20001/base/bind_unittest.cc File base/bind_unittest.cc (right): https://codereview.chromium.org/2581943005/diff/20001/base/bind_unittest.cc#newcode1319 base/bind_unittest.cc:1319: #if !defined(COMPILER_MSVC) On 2016/12/19 19:16:00, brucedawson wrote: > On ...
4 years ago (2016-12-19 20:18:11 UTC) #15
brucedawson
> Do you think adding a comment above the explicitly deleted methods would be > ...
4 years ago (2016-12-19 20:50:03 UTC) #18
dcheng
On 2016/12/19 20:50:03, brucedawson wrote: > > Do you think adding a comment above the ...
4 years ago (2016-12-19 20:54:42 UTC) #19
danakj
You could revert the reformating for review then reformat after to land? Also.. randomly.. could ...
4 years ago (2016-12-19 20:56:50 UTC) #20
dcheng
On 2016/12/19 20:56:50, danakj_OOO_and_slow wrote: > You could revert the reformating for review then reformat ...
4 years ago (2016-12-19 21:00:48 UTC) #21
brucedawson
On 2016/12/19 21:00:48, dcheng wrote: > On 2016/12/19 20:56:50, danakj_OOO_and_slow wrote: > > You could ...
4 years ago (2016-12-19 21:14:31 UTC) #22
dcheng
4 years ago (2016-12-19 21:27:45 UTC) #23
On 2016/12/19 21:14:31, brucedawson wrote:
> On 2016/12/19 21:00:48, dcheng wrote:
> > On 2016/12/19 20:56:50, danakj_OOO_and_slow wrote:
> > > You could revert the reformating for review then reformat after to land?
> 
> One option would be to just ignore the confusing diff - maybe nobody will ever
> look at it.
> 
> In general however I sometimes get confused when a CL contains semantic and
> non-semantic differences, since it takes extra effort to distinguish them.
Doing
> the white-space changes from git cl format to otherwise unchanged lines (that
is
> what's happening, right?) would ideally be done in a prior or subsequent CL to
> avoid this confusion.

Fair enough. Note that in this case, I believe the diff algorithm is going to
select the "incorrect" lines no matter what, since the first two new lines of
the new hunk exactly match the original two lines that were there. The
reformatting just affects whether it selects the rest of the std::enable_if or
not.

> 
> But anyway, lgtm.

Powered by Google App Engine
This is Rietveld 408576698