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

Deprecate set_var and remove_var in 1.58.0 #90830

Closed
wants to merge 2 commits into from

Conversation

leo60228
Copy link
Contributor

This is a stopgap solution for #90308 while a decision is made on how the underlying unsoundness should be resolved.

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(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 Nov 12, 2021
@rust-log-analyzer

This comment has been minimized.

@leo60228
Copy link
Contributor Author

Seriously? I ran ./x.py test locally and it was fine...

@joshtriplett joshtriplett added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. I-libs-api-nominated Nominated for discussion during a libs-api team meeting. labels Nov 12, 2021
@joshtriplett
Copy link
Member

While I'm in support of such a deprecation, I'd prefer to 1) make a decision on whether to add an unsafe version to the standard library and 2) do so and stabilize it, so that people have a replacement that's in the standard library.

@Mark-Simulacrum
Copy link
Member

I also think it's not necessarily the right approach to rush a deprecation out here; my impression is that the risk of segfaults (or UB) is real, but does not in practice occur that often.

I would also suggest that just providing a non-deprecated unsafe version is likely to not really motivate people to migrate away from env variables -- I expect almost all code that currently uses set_var probably did so "reluctantly" anyway (for lack of better options) and would likely end up either just sticking with an allow(deprecated) or an unsafe call with a "hope for the best" comment.

At minimum I would suggest we try to assess any std-used env variables and provide alternatives for setting them safely (e.g., RUST_BACKTRACE) from within the standard library interface. It's probably worthwhile to do a simple grep of crates.io at least (or all Crater-seen code) to see if there are other similar variables that would be good to suggest direct setters for (e.g., in other Rust libraries, perhaps even some popular C libraries with Rust bindings).

IOW, I think if we deprecate before there's an effective "what else to do", we don't actually win that much and only hurt ourselves by forcing people to push the problem under the covers (allow, unsafe, etc.) rather than actually fixing it if at all possible.

@leo60228
Copy link
Contributor Author

leo60228 commented Nov 16, 2021 via email

@joshtriplett joshtriplett removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Dec 1, 2021
@Amanieu
Copy link
Member

Amanieu commented Dec 1, 2021

We discussed this in the libs-api meeting today.

We feel that the standard library should first offer an alternative (unsafe) API for manipulating the environment variables before deprecating the existing API. This is also a good opportunity to improve the API of set_var by making it return a Result (see #63456).

The standard library should also provide a proper API for controlling behavior that is currently controlled with environment variables. The main culprit here is RUST_BACKTRACE which should have an API added to control it at run-time.

@Mark-Simulacrum
Copy link
Member

I'm going to mark this as waiting on author, though it may also make sense to mark it as S-blocked as there's several APIs which need to at least land on nightly (and probably ~stabilize) before we can move ahead here, per the libs-api discussion.

@Mark-Simulacrum Mark-Simulacrum 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 7, 2021
@leo60228
Copy link
Contributor Author

Should I close this in favor of #92365?

@bors
Copy link
Contributor

bors commented Jan 2, 2022

☔ The latest upstream changes (presumably #92396) made this pull request unmergeable. Please resolve the merge conflicts.

@leo60228 leo60228 closed this Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants