Skip to content
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

implement RFC 1229 #28845

Merged
merged 1 commit into from
Oct 18, 2015
Merged

implement RFC 1229 #28845

merged 1 commit into from
Oct 18, 2015

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Oct 5, 2015

This PR turns statically known erroneous code (e.g. numeric overflow) into a warning and continues normal code-generation to emit the same code that would have been generated without check_const detecting that the result can be computed at compile-time.

It's not done yet, as I don't know how to properly emit a lint from trans. I can't seem to extract the real lint level of the item the erroneous expression is in. It's an unconditional warning now.

r? @pnkfelix

cc @nikomatsakis

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@pnkfelix
Copy link
Member

pnkfelix commented Oct 5, 2015

(I'm going to take the liberty of editing the description to include a link to the RFC and tracking issue, if any.)

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 5, 2015

hmm... apparently it still errors with signal 11: https://travis-ci.org/rust-lang/rust/builds/83678318#L5336

fixed, llvm assertions were off

@bors
Copy link
Contributor

bors commented Oct 10, 2015

☔ The latest upstream changes (presumably #28920) made this pull request unmergeable. Please resolve the merge conflicts.

const eval errors outside of true constant enviroments are not reported anymore, but instead forwarded to a lint.
@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 13, 2015

I created a bad llvm dummy value in case of miscompilation. It's now fixed. The next step is to move the checks to check_const, so the lint-system can be used for reporting and the errors are reported early.

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 14, 2015

note: with next step I mean a future PR. This one is ready to go.

})
.collect::<Vec<Result<_, ConstEvalFailure>>>()
.into_iter()
.collect::<Result<Vec<_>,ConstEvalFailure>>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, some how i feel like i've never seen this pattern before, (and yet it feels like something I would see more often...)

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 16, 2015

(I am essentially surprised that we are not either causing an ICE here, or folding this case into the Runtime(_) one immediately above.)

doing the same as Runtime will hit this branch, which is considered a bug: https://github.com/oli-obk/rust/blob/rfc1229/src/librustc_trans/trans/expr.rs#L970-L973

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 16, 2015

Update: or is the idea that we will see an error emitted downstream in the compiler's control flow? I wish we had some way to encode that in the source; I can understand not wanting to emit an error, but maybe we should at least ensure the error count is incremented?

Since in the future trans should NEVER report an error, this is not much of a concern. Once I manage to report these errors in check_const, all the error-locations here will be turned into bugs (even those that currently don't do anything, as they should be unreachable!)

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 18, 2015

📌 Commit 09d3adf has been approved by pnkfelix

@bors
Copy link
Contributor

bors commented Oct 18, 2015

⌛ Testing commit 09d3adf with merge 3f2ad61...

bors added a commit that referenced this pull request Oct 18, 2015
This PR turns statically known erroneous code (e.g. numeric overflow) into a warning and continues normal code-generation to emit the same code that would have been generated without `check_const` detecting that the result can be computed at compile-time.

<del>It's not done yet, as I don't know how to properly emit a lint from trans. I can't seem to extract the real lint level of the item the erroneous expression is in.</del> It's an unconditional warning now.

r? @pnkfelix 

cc @nikomatsakis 

* [RFC 1229 text](https://github.com/rust-lang/rfcs/blob/master/text/1229-compile-time-asserts.md)
* RFC PR: rust-lang/rfcs#1229
* tracking issue: #28238
@bors bors merged commit 09d3adf into rust-lang:master Oct 18, 2015
@oli-obk oli-obk deleted the rfc1229 branch January 14, 2016 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants