-
-
Notifications
You must be signed in to change notification settings - Fork 739
Remove static assert(__traits(compiles, xyz))
from std.conv
#3804
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
Remove static assert(__traits(compiles, xyz))
from std.conv
#3804
Conversation
@@ -4398,7 +4402,7 @@ unittest | |||
@disable this(this); | |||
} | |||
S1 s1 = void; | |||
static assert( __traits(compiles, emplace(&s1, 1))); | |||
emplace(&s1, 1); |
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.
assert(s1.i == 1);
Other than that LGTM |
@@ -4694,7 +4698,7 @@ unittest | |||
} | |||
S1 s = void; | |||
static assert(!__traits(compiles, emplace(&s, 1))); | |||
static assert( __traits(compiles, emplace(&s, &i))); //(works, but deprected) | |||
static assert( __traits(compiles, emplace(&s, &i))); //(works, but deprecated) |
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.
Are these used to quell the deprecation message?
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.
Correct. If I call it outright the deprecation message shows up.
@burner fixed, and the autotester failure was transitory - thx for the review! |
mmmmmm pass pliz pliz pullllllllllllllllllll |
LGTM. Squash and auto-merge? Note that one of these commits snuck its way into your emplace PR, so you should rebase that on master after this is merged. |
…mful Remove `static assert(__traits(compiles, xyz))` from `std.conv`
The pattern
static assert(__traits(compiles, xyz))
arised probably as a converse to its negation, e.g.:However, the pattern should be avoided for two reasons:
static assert(__compiles)
does not show the reason in the error messages. This makes code more difficult to work with gratuitously.This is just the beginning - could someone please eliminate this pattern from all of Phobos? Thanks!