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

Add a way for macros to check and report errors #3174

Closed
eholk opened this issue Aug 10, 2012 · 11 comments
Closed

Add a way for macros to check and report errors #3174

eholk opened this issue Aug 10, 2012 · 11 comments
Labels
A-syntaxext Area: Syntax extensions E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.

Comments

@eholk
Copy link
Contributor

eholk commented Aug 10, 2012

It'd be helpful to have something like macro_error! or static_assert!, that evaluates a condition and possible reports an error at compile time.

In my HTML parser macro, it'd allow the macro to make sure closing tags actually close what they should.

@bblum
Copy link
Contributor

bblum commented Aug 11, 2012

+1 for static_assert :)

@BrendanEich
Copy link

Yay static_assert!

@emberian
Copy link
Member

emberian commented May 3, 2013

See https://botbot.me/irc.mozilla.org/rust/msg/2999973/ and following conversation. static_assert, static_warn etc would be very useful when building for a platform lacking certain things.

@emberian
Copy link
Member

static_assert added as attribute in #6670, but it doesn't fix this, this would require CTFE. Setting far future.

@eholk
Copy link
Contributor Author

eholk commented Jul 15, 2013

I don't actually think we need compile time function evaluation (CTFE) for what I originally had in mind. I was just thinking a macro like macro_error!(message) that when evaluated creates a compile error with the supplied message. By itself, it's not super useful, but it can be used as a piece of other macros. For example, say you had a macro that had to have an even number of macros. You could have the pattern that matches the single argument case expand into macro_error!, which would tell the programmer they misused the macro and what they should do instead.

@eholk
Copy link
Contributor Author

eholk commented Jul 15, 2013

Oh... I just read what my initial report said, and that wasn't what my most recent comment was. Still, I think the way to factor this is with a macro_error! macro and then some kind of conditional macro, and the combination would give my original request. The macro_error! part shouldn't be hard to implement at all.

@emberian
Copy link
Member

@eholk well macros are a form of CTFE I think?

@eholk
Copy link
Contributor Author

eholk commented Jul 18, 2013

@cmr, I suppose so, given that they are Turing complete. I'd say Scheme's syntax-case macros count as CTFE, since they are really just arbitrary fragments of Scheme code that produce syntax, but syntax-rules macros (which are more like what Rust has) don't have that same feel to me since they are just pattern matching and substitution, but you can't evaluate arbitrary Rust code as part of the expansion.

@catamorphism
Copy link
Contributor

(bug triage) Milestone looks right.

@steveklabnik
Copy link
Member

https://github.com/huonw/compile_msg looks like it might be a solution to this issue?

@emberian
Copy link
Member

Yup!

RalfJung pushed a commit to RalfJung/rust that referenced this issue Nov 25, 2023
miri script: fix RUSTC_GIT error message

Making this a flag is tricky since our command-line parsing is pretty crude.

Fixes rust-lang/miri#3173
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Bumps [tests/perf/s2n-quic](https://github.com/aws/s2n-quic) from
`1436af7` to `6dd41e0`.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/aws/s2n-quic/commit/6dd41e09195bc22dbac93a48f8ab35f8063726dc"><code>6dd41e0</code></a>
build: fix clippy warnings for 1.78 (<a
href="https://github.com/aws/s2n-quic/issues/2199">#2199</a>)</li>
<li><a
href="https://github.com/aws/s2n-quic/commit/de5c33e800ffff14c235ed0ae7d695222f84dcca"><code>de5c33e</code></a>
refactor(s2n-quic-core): improve reassembler error handling (<a
href="https://github.com/aws/s2n-quic/issues/2197">#2197</a>)</li>
<li><a
href="https://github.com/aws/s2n-quic/commit/b085808f4c898f6d4d4e68b14d6a762170fb19b1"><code>b085808</code></a>
chore(s2n-quic-crypto): remove custom aesgcm implementation (<a
href="https://github.com/aws/s2n-quic/issues/2186">#2186</a>)</li>
<li><a
href="https://github.com/aws/s2n-quic/commit/7188ce4081096256267e44d63f532a40d2c7df64"><code>7188ce4</code></a>
feat(dc): DcSupportedVersions transport parameter (<a
href="https://github.com/aws/s2n-quic/issues/2193">#2193</a>)</li>
<li>See full diff in <a
href="https://github.com/aws/s2n-quic/compare/1436af712b6e73edc11640dc7c3cae23e456c0a8...6dd41e09195bc22dbac93a48f8ab35f8063726dc">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.
Projects
None yet
Development

No branches or pull requests

6 participants