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

Tracking issue for proc_macro::is_available() #71436

Closed
3 tasks done
dtolnay opened this issue Apr 22, 2020 · 18 comments
Closed
3 tasks done

Tracking issue for proc_macro::is_available() #71436

dtolnay opened this issue Apr 22, 2020 · 18 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Apr 22, 2020

This is a tracking issue for proc_macro::is_available().
The feature gate for the issue is #![feature(proc_macro_is_available)].

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also uses as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

none yet

Implementation history

@dtolnay dtolnay added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Apr 22, 2020
@jonas-schievink jonas-schievink added the B-unstable Blocker: Implemented in the nightly compiler and unstable. label Apr 22, 2020
@Aaron1011 Aaron1011 added the A-proc-macros Area: Procedural macros label May 21, 2020
@Aaron1011
Copy link
Member

Is anything blocking stabilization of this feature? It seems pretty uncontroversial - if the proc_macro crate ever gained the ability to be used outside of a procedural macro, this function could just unconditionally return true.

@dtolnay
Copy link
Member Author

dtolnay commented Jun 12, 2020

One non-uncontroversial part is how to react if proc_macro might not be all-or-nothing in the future. For example if the whole token API is made to work outside a proc macro, but the diagnostics API via Span (warn, error, note, etc) would not be available.

@KodrAus KodrAus added the Libs-Tracked Libs issues that are tracked on the team's project board. label Jul 29, 2020
@bjorn3
Copy link
Member

bjorn3 commented Jun 25, 2021

If the token api is made to work outside a proc macro, but the diagnostics api is not, I think users of proc_macro can just access the token api without checking is_available and maybe only check the rustc version. Usage of the diagnostics api should then still be behind a is_available check. Basically if it always works, is_available shouldn't be used, but if it only works inside a proc macro, is_available should be used.

@bjorn3
Copy link
Member

bjorn3 commented Jun 25, 2021

I would really like for this feature to be stabilized. proc_macro2 is currently unusable with cg_clif outside of proc macros, as it checks if a proc macro function panics when being called. cg_clif doesn't yet support unwinding on panics. Also if the function proc_macro2 checks becomes available outside of a proc macro, that will break proc_macro2 usage outside of proc macros, so the sooner it migrates to is_available the better.

@smklein
Copy link
Contributor

smklein commented Jul 15, 2021

I would really like for this feature to be stabilized. proc_macro2 is currently unusable with cg_clif outside of proc macros, as it checks if a proc macro function panics when being called. cg_clif doesn't yet support unwinding on panics. Also if the function proc_macro2 checks becomes available outside of a proc macro, that will break proc_macro2 usage outside of proc macros, so the sooner it migrates to is_available the better.

Does the workaround described here not work for you? I'm running into a similar use-case, but the proc_macro2::fallback::force() function is a sufficient escape-hatch for now

@bjorn3
Copy link
Member

bjorn3 commented Jul 15, 2021

That doesn't help when you don't control the source. proc-macro2 is used by a dependency of the user's project most of the time. And even if it isn't, I can't except users of cg_clif to always add proc_macro2::fallback::force() to their build scripts. I would like something that works out of the box.

@m-ou-se

This comment has been minimized.

@rfcbot

This comment has been minimized.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Sep 8, 2021
@m-ou-se

This comment has been minimized.

@m-ou-se

This comment has been minimized.

@rfcbot

This comment has been minimized.

@rfcbot rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Sep 8, 2021
@m-ou-se m-ou-se added disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Sep 8, 2021
@m-ou-se
Copy link
Member

m-ou-se commented Sep 8, 2021

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Sep 8, 2021

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@jhpratt
Copy link
Member

jhpratt commented Sep 8, 2021

I still share the concern that some APIs (but not all) may, in the future, be permitted to be used in any context, not just proc macros. Wouldn't #[cfg(accessible(...))] encompass this and at the same time be more powerful, flexible, and forward-thinking?

@bjorn3
Copy link
Member

bjorn3 commented Sep 9, 2021

#[cfg(accessible(...))] only tests if the api exists at all in the current rustc version. It doesn't test if you can actually call it without getting a panic in the current context. For dependencies it is impossible to know if it will be run as part of a proc-macro or not. In addition a proc-macro may want to spawn a thread, in which case the thread isn't allowed to call into libproc_macro.

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Sep 29, 2021
@rfcbot
Copy link

rfcbot commented Sep 29, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Sep 29, 2021
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Oct 9, 2021
@rfcbot
Copy link

rfcbot commented Oct 9, 2021

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 10, 2021
…lable, r=petrochenkov

Stabilize proc_macro::is_available

Tracking issue: rust-lang#71436

The FCP for the stabilization of `proc_macro::is_available` has completed.
@m-ou-se m-ou-se closed this as completed Oct 12, 2021
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Oct 21, 2021
bors bot added a commit to tock/tock that referenced this issue Dec 9, 2021
2915: Update rust-toolchain to 2021-12-04 r=ppannuto a=lschuermann

### Pull Request Overview

This pull request updates the Rust toolchain to version `1.59.0-nightly (efec54529 2021-12-04)`. The motivation for this change is that the `litex-sim-ci` breaks when compiling `elf2tab` on the previous toolchain version:

```
error[E0658]: use of unstable library feature 'proc_macro_is_available'
  --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.33/src/detection.rs:28:21
   |
28 |     let available = proc_macro::is_available();
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #71436 <rust-lang/rust#71436> for more information
   = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `elf2tab v0.8.0`, intermediate artifacts can be found at `/tmp/cargo-installl05bA0`
```

Now, I'm not entirely sure as to why this happens. We haven't upgraded either of the Rust toolchain or `elf2tab`, and -- as far as I understand -- `cargo install elf2tab` should use the `Cargo.lock` file, so dependencies shouldn't change.

In any case, this update seems to fix it. Besides the failing `litex-sim-ci` workflow, it seems like a good idea to pin a `rustc` version on which vital tools such as `elf2tab` properly compile. I can also reproduce the `elf2tab` build failure locally while the `rust-toolchain` of the Tock repository is used.


### Testing Strategy

This pull request was tested by CI.


### TODO or Help Wanted

N/A


### Documentation Updated

- [x] ~Updated the relevant files in `/docs`,~ or no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Leon Schuermann <leon@is.currently.online>
penberg added a commit to penberg/manticore-dev that referenced this issue Dec 12, 2021
The build currently fails as follows:

  error[E0658]: use of unstable library feature 'proc_macro_is_available'
    --> /home/penberg/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.33/src/detection.rs:28:21
     |
  28 |     let available = proc_macro::is_available();
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: see issue #71436 <rust-lang/rust#71436> for more information
     = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable

  For more information about this error, try `rustc --explain E0658`.
  error: could not compile `proc-macro2` due to previous error

The problem is that the "null_terminated" crate depends on the "utf"
with a relaxed "0.1" version, which causes cargo to pull a version that
is incompatible with our toolchain.

Fix up the dependency by relying on the old "0.1.5" version explicitly.
Xanewok added a commit to paritytech/cachepot that referenced this issue Dec 16, 2021
Fixes the following error:
error[E0658]: use of unstable library feature 'proc_macro_is_available'
  --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.33/src/detection.rs:28:21
   |
28 |     let available = proc_macro::is_available();
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #71436 <rust-lang/rust#71436> for more information
   = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` due to previous error
Xanewok added a commit to paritytech/cachepot that referenced this issue Dec 16, 2021
Fixes the following error:
error[E0658]: use of unstable library feature 'proc_macro_is_available'
  --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.33/src/detection.rs:28:21
   |
28 |     let available = proc_macro::is_available();
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #71436 <rust-lang/rust#71436> for more information
   = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` due to previous error
montekki pushed a commit to paritytech/cachepot that referenced this issue Dec 20, 2021
Fixes the following error:
error[E0658]: use of unstable library feature 'proc_macro_is_available'
  --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.33/src/detection.rs:28:21
   |
28 |     let available = proc_macro::is_available();
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #71436 <rust-lang/rust#71436> for more information
   = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` due to previous error
@bjorn3
Copy link
Member

bjorn3 commented Jun 22, 2023

You should update proc-macro2 (if you depend on it) and update to the latest rustc version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants