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

Avoid calling the column!() macro in panic #43735

Merged
merged 2 commits into from
Aug 10, 2017
Merged

Conversation

est31
Copy link
Member

@est31 est31 commented Aug 8, 2017

Closes #43057

This "fix" adds a new macro called __rust_unstable_column and to use it instead of the column macro inside panic. The new macro can be shadowed as well as column can, but its very likely that there is no code that does this in practice.

There is no real way to make "unstable" macros that are usable by stable macros, so we do the next best thing and prefix the macro with __rust_unstable to make sure people recognize it is unstable.

r? @alexcrichton

@arielb1 arielb1 added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 8, 2017
@arielb1
Copy link
Contributor

arielb1 commented Aug 8, 2017

There is no real way to make "unstable" macros that are usable by stable macros

Yes there is - macros 2.0, but this is beta-nominated so I'll rather play safe.

Beta-nominating because regression.

@arielb1 arielb1 added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 8, 2017
@@ -8,6 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[macro_export]
// This stability attribute is totally useless.
#[stable(feature = "rust1", since = "1.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe wishful thinking, but if we ever fix macro stability checking it'd be good to have accurate info here. Also for rustdoc purposes.

Copy link
Member Author

Choose a reason for hiding this comment

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

The attribute is useless because a) stability attributes on macros are generally useless, and b) because of the #[cfg(stage0)] below. This won't have any impact on anything presented to users of the compiler. This entire macro definition may be removed if we switch stage0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh OK, missed the #[cfg(stage0)]. So it will never even reach rustdoc. Carry on then.

@alexcrichton
Copy link
Member

Thanks @est31!

Could this be made as "real unstable" via the same mechanism as global_asm perhaps?

@alexcrichton alexcrichton added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Aug 9, 2017
@est31
Copy link
Member Author

est31 commented Aug 9, 2017

@alexcrichton I don't think this will work? Because the cx refers to the leaf crate's context (where the macro is being expanded), so a feature gate like this would require users of the panic macro to have a #![feature()] attribute in their crate root.

@alexcrichton
Copy link
Member

Hm yeah that's true. Perhaps the span could be checked though for allow_internal_unstable?

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 10, 2017

📌 Commit 0c32135 has been approved by alexcrichton

@alexcrichton figured out a way how to do it :)
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 10, 2017

📌 Commit 5cf9f63 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 10, 2017

⌛ Testing commit 5cf9f63 with merge 16268a8...

bors added a commit that referenced this pull request Aug 10, 2017
Avoid calling the column!() macro in panic

Closes #43057

This "fix" adds a new macro called `__rust_unstable_column` and to use it instead of the `column` macro inside panic. The new macro can be shadowed as well as `column` can, but its very likely that there is no code that does this in practice.

There is no real way to make "unstable" macros that are usable by stable macros, so we do the next best thing and prefix the macro with `__rust_unstable` to make sure people recognize it is unstable.

r? @alexcrichton
@bors
Copy link
Contributor

bors commented Aug 10, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 16268a8 to master...

@bors bors merged commit 5cf9f63 into rust-lang:master Aug 10, 2017
@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 12, 2017
bors added a commit that referenced this pull request Aug 13, 2017
Backporting accepted PRs to beta

Backport of:

* #43735
* #43546
* #43513
* #43373
* #43315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

My code fails to build with „unexpected end of macro invocation“ since nightly 2017-07-02
5 participants