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

emit error with span for empty asserts #56491

Merged
merged 1 commit into from Dec 11, 2018
Merged

Conversation

euclio
Copy link
Contributor

@euclio euclio commented Dec 4, 2018

Fixes #55547.

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 4, 2018
@euclio
Copy link
Contributor Author

euclio commented Dec 4, 2018

r? @estebank

@rust-highfive rust-highfive assigned estebank and unassigned aturon Dec 4, 2018
@@ -24,6 +24,12 @@ pub fn expand_assert<'cx>(
tts: &[TokenTree],
) -> Box<dyn MacResult + 'cx> {
let mut parser = cx.new_parser_from_tts(tts);

if parser.token == token::Eof {
cx.span_err(sp, "requires a boolean expression");
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the change!

Could you change this to something closer to

cx.struct_span_err(sp, "macro call requires boolean expression as argument")
    .span_label(sp, "boolean expression required")
    .emit();

Ideally you'd add a Applicability::MaybeIncorrect suggestion as well showing what the correct code would be, but that'd be overkill for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 4, 2018
--> $DIR/assert.rs:2:5
|
LL | assert!(); //~ ERROR requires a boolean expression
| ^^^^^^^^^^ boolean expression required
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to point at the (empty) argument list, but this is already quite an improvement.

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 10, 2018

📌 Commit a367cec has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 10, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 10, 2018
bors added a commit that referenced this pull request Dec 10, 2018
Rollup of 5 pull requests

Successful merges:

 - #56491 (emit error with span for empty asserts)
 - #56633 (Fix right arrow size for crate filter)
 - #56641 (fix span for invalid number of parameters in trait method)
 - #56656 (Fix typo)
 - #56661 (Add regression test for ICE)

Failed merges:

r? @ghost
@bors bors merged commit a367cec into rust-lang:master Dec 11, 2018
@euclio euclio deleted the assert-error branch December 11, 2018 00:24
euclio added a commit to euclio/rust that referenced this pull request Jan 2, 2019
This commit completely removes usage of the `panictry!` macro from
outside libsyntax. The macro causes parse errors to be fatal, so using
it in libsyntax_ext caused parse failures *within* a syntax extension to
be fatal, which is probably not intended.

Furthermore, this commit adds spans to diagnostics emitted by empty
extensions if they were missing, à la rust-lang#56491.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jan 3, 2019
make `panictry!` private to libsyntax

This commit completely removes usage of the `panictry!` macro from
outside libsyntax. The macro causes parse errors to be fatal, so using
it in libsyntax_ext caused parse failures *within* a syntax extension to
be fatal, which is probably not intended.

Furthermore, this commit adds spans to diagnostics emitted by empty
extensions if they were missing, à la rust-lang#56491.
bors added a commit that referenced this pull request Jan 4, 2019
make `panictry!` private to libsyntax

This commit completely removes usage of the `panictry!` macro from
outside libsyntax. The macro causes parse errors to be fatal, so using
it in libsyntax_ext caused parse failures *within* a syntax extension to
be fatal, which is probably not intended.

Furthermore, this commit adds spans to diagnostics emitted by empty
extensions if they were missing, à la #56491.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants