-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Compile_fail for regular tests #11468
Comments
Cargo doesn't know how to parse source code. Without the support from rustc, Cargo can do nothing on attributes unfortunately. Apart from that, could you describe your expectation and scenario about I would appreciate if you share more contexts. Thank you. |
A common crate for testing proc macros is trybuild |
@weihanglo My direct interest was in using this to assert that certain code does not pass type checking due to variance, but I think that only really makes sense for invariant types. For those one could write tests to assert that they are neither covariant nor contravariant. |
Another alternative is to use a doctest, which is compiled as a separate file and supports the I think it is unlikely that this could be supported with an attribute, as I suspect it would be nearly impossible for rustc to "allow" a subsection of code to fail to compile. Can you provide an example of the kind of test that you would want to assert a specific kind of variance? |
There are several invariant types in std that could have tests written for them, like so:
|
Would be great to be able to annotate regular tests as failing to compile.
Originally posted by @faulesocke in rust-lang/rust#12335 (comment)
The text was updated successfully, but these errors were encountered: