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

Make assert! ensure the macro is parsed completely #60039

Merged
merged 2 commits into from
Apr 29, 2019

Conversation

rasendubi
Copy link
Contributor

Fixes #60024

@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 @alexcrichton (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. Due to 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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 17, 2019
@jonas-schievink
Copy link
Contributor

Is there any reason why assert! is built into the compiler instead of just being defined normally in libcore?

@petrochenkov
Copy link
Contributor

@jonas-schievink
It was moved from libcore to compiler as a first step in implementing #44838 (the second step never happened though).

@alexcrichton
Copy link
Member

Thanks @rasendubi! To be double extra sure I think we'll want to run this through crater to ensure we don't break too many crates by accident, so...

@bors: try

@bors
Copy link
Contributor

bors commented Apr 17, 2019

⌛ Trying commit dfc0861 with merge 78b0bd8441ef961f6475e3d47fe3bca38cb83432...

@bors
Copy link
Contributor

bors commented Apr 17, 2019

☀️ Try build successful - checks-travis
Build commit: 78b0bd8441ef961f6475e3d47fe3bca38cb83432

@alexcrichton
Copy link
Member

@craterbot run start=master#efe2f32a6b8217425f361ec7c206910c611c03ee end=try#78b0bd8441ef961f6475e3d47fe3bca38cb83432 mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-60039 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 19, 2019
@craterbot
Copy link
Collaborator

🚧 Experiment pr-60039 is now running on agent aws-2.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Apr 19, 2019
@rasendubi
Copy link
Contributor Author

The crater agent is unreachable for a day now. Is that normal?

Last heartbeat: 2019-04-20 06:26:03 UTC

@estebank
Copy link
Contributor

CC @pietroalbini ^^

@craterbot
Copy link
Collaborator

🚨 Experiment pr-60039 has encountered an error: docker is not running
🛠️ If the error is fixed use the retry command.

🆘 Can someone from the infra team check in on this? @rust-lang/infra
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@pietroalbini
Copy link
Member

@craterbot retry

The Crater machine crashed, now it should work again.

@craterbot
Copy link
Collaborator

🛠️ Experiment pr-60039 queued again.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚧 Experiment pr-60039 is now running on agent aws-2.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-60039 is completed!
📊 18 regressed and 1 fixed (60951 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Apr 24, 2019
@alexcrichton
Copy link
Member

That looks like an unfortuante amount of breakage :(

Given all that I think that the best thing to do might be to switch this to a warning, and then perhaps send some PRs to upstream crates to fix the issues? After awhile we can then switch to an error

@estebank
Copy link
Contributor

estebank commented Apr 24, 2019

@alexcrichton a significant amount of these (8) seem to be coming from mop-structs having the equivalent of assert!(a == b "error message") (note missing comma), which we could explicitly detect and unconditionally warn on. q1tsim and carrier have the same kind of error.

static-linkedlist has assert!(error;).

bluenrg, cargo-generate (and it's transitive error) and b-r-oleary.passwords were a bit more bizarre on first look without context, but looking a bit deeper I see they are similar to static-linkedlist:

https://github.com/danielgallagher0/bluenrg/blob/a47f1f57277995937e1cf6ae8c8f58d8e7254187/tests/l2cap.rs#L64-L69

https://github.com/ashleygwilliams/cargo-generate/blob/54a85ed98ee4ad06c8228dd60ac070ff483291dd/tests/integration/basics.rs#L447-L450

https://github.com/b-r-oleary/passwords/blob/c85100139d8301f72c6948b672e98247571c8a51/src/generators/phrase.rs#L195-L200

I think if we accept trailing ; and trailing &'static strs in assert, potentially linting about these, we can merge the fix.

On the plus side none of the errors seems to be intentional misuse of the "feature".

rasendubi added a commit to rasendubi/rs-static-linkedlist that referenced this pull request Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/carrier-legacy that referenced this pull request Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to add missing comma.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/passwords that referenced this pull request Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/wrench that referenced this pull request Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to remove extra tokens.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/cody that referenced this pull request Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to add missing comma.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
rasendubi added a commit to rasendubi/bonaventure that referenced this pull request Apr 25, 2019
There is a bug in rustc that allows adding invalid trailing tokens to
the `assert!` macro call. They are currently ignored but are going to
produce errors in the future.

Fix assert! macro usage to add missing comma.

For more information, see
rust-lang/rust#60024 and
rust-lang/rust#60039
@craterbot
Copy link
Collaborator

🎉 Experiment pr-60039-1 is completed!
📊 1 regressed and 0 fixed (60951 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Apr 27, 2019
@rasendubi
Copy link
Contributor Author

The one regression reported by crater does not seem relevant to the change. From logs:

[INFO] [stderr] error[E0061]: this function takes 2 parameters but 0 parameters were supplied
[INFO] [stderr]   --> src/bin/main.rs:29:24
[INFO] [stderr]    |
[INFO] [stderr] 29 |     let mut computer = Computer::new();
[INFO] [stderr]    |                        ^^^^^^^^^^^^^^^ expected 2 parameters
[INFO] [stderr] 
[INFO] [stderr] error[E0061]: this function takes 2 parameters but 1 parameter was supplied
[INFO] [stderr]   --> src/bin/main.rs:43:15
[INFO] [stderr]    |
[INFO] [stderr] 43 |         match tokenize(&buffer) {
[INFO] [stderr]    |               ^^^^^^^^^^^^^^^^^ expected 2 parameters
[INFO] [stderr] 
[INFO] [stderr] error: aborting due to 2 previous errors

@alexcrichton
Copy link
Member

@bors: r+

This looks like a great compromise, thanks @rasendubi!

@bors
Copy link
Contributor

bors commented Apr 29, 2019

📌 Commit f29e9a5 has been approved by alexcrichton

@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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 29, 2019
@bors
Copy link
Contributor

bors commented Apr 29, 2019

⌛ Testing commit f29e9a5 with merge 96d565b...

bors added a commit that referenced this pull request Apr 29, 2019
Make assert! ensure the macro is parsed completely

Fixes #60024
@bors bors mentioned this pull request Apr 29, 2019
@bors
Copy link
Contributor

bors commented Apr 29, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: alexcrichton
Pushing 96d565b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 29, 2019
@bors bors merged commit f29e9a5 into rust-lang:master Apr 29, 2019
@rasendubi
Copy link
Contributor Author

This is my first contribution to rust (besides some minor docs improvements). Thank you guys for all the support! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

assert! allows invalid trailing tokens in expression
10 participants