-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add #[rustc_error]
annotation, which causes trans to signal an error
#22278
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
Conversation
if found on the `main()` function. This lets you write tests that live in `compile-fail` but are expected to compile successfully. This is handy when you have many small variations on a theme that you want to keep together, and you are just testing the type checker, not the runtime semantics.
I didn't bother with a feature gate because:
|
// error in trans. This is used to write compile-fail tests | ||
// that actually test that compilation succeeds without | ||
// reporting an error. | ||
if ty::has_attr(ccx.tcx(), local_def(node_id), "rustc_error") { |
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.
I am not clear on why you are limiting use of this attribute to fn main()
, and having it no-op elsewhere.
I would have had it error everywhere, entry or not, especially since the fact that it errors is the basis of the argument for why it does not need a feature gate.
@bors r+ b597cbe rollup |
b597cbe
to
fb05f28
Compare
@bors rollup |
(niko addressed my feedback with commit b597cbe, but then that did not bootstrap, so he dropped it off again. maybe i will look at that later.) |
I tried to make it work everywhere but that required just a bit more work so screw it. I still think my reasoning is sound. If you use it elsewhere, that's fine, but if you use it on main, you'll get an error. We are free to remove it later if we want. In any case, we currently claim all attribute names so... |
(For future reference, the problem was that method def-ids cause |
…sakis Add `#[rustc_error]` annotation, which causes trans to signal an error if found on the `main()` function. This lets you write tests that live in `compile-fail` but are expected to compile successfully. This is handy when you have many small variations on a theme that you want to keep together, and you are just testing the type checker, not the runtime semantics. r? @pnkfelix
I would prefer if we not add new attributes without gates or RFCs. This is a language feature. |
@brson I disagree, for the reasons listed here: #22278 (comment) That said, I just want to write my tests, so if you'd rather they have a feature gate, that's fine too. |
(Going through an RFC seems like overkill.) |
(Though, I think that the plan to only allow a white-listed set of attributes kind of covers the feature-gate, as well.) |
Meh. Upon further reflection I decided @brson is probably right. I'll open another PR feature-gating this and a couple of other similar "introspection" annotations -- this can get folded into the more general feature-gate at some later time. |
…sakis Add `#[rustc_error]` annotation, which causes trans to signal an error if found on the `main()` function. This lets you write tests that live in `compile-fail` but are expected to compile successfully. This is handy when you have many small variations on a theme that you want to keep together, and you are just testing the type checker, not the runtime semantics. r? @pnkfelix
See #22336 |
…sakis Add `#[rustc_error]` annotation, which causes trans to signal an error if found on the `main()` function. This lets you write tests that live in `compile-fail` but are expected to compile successfully. This is handy when you have many small variations on a theme that you want to keep together, and you are just testing the type checker, not the runtime semantics. r? @pnkfelix
…sakis Add `#[rustc_error]` annotation, which causes trans to signal an error if found on the `main()` function. This lets you write tests that live in `compile-fail` but are expected to compile successfully. This is handy when you have many small variations on a theme that you want to keep together, and you are just testing the type checker, not the runtime semantics. r? @pnkfelix
Add
#[rustc_error]
annotation, which causes trans to signal an errorif found on the
main()
function. This lets you write tests that livein
compile-fail
but are expected to compile successfully. This ishandy when you have many small variations on a theme that you want to
keep together, and you are just testing the type checker, not the
runtime semantics.
r? @pnkfelix