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

env! has a completely undocumented optional second argument for setting the error message #48044

Closed
ExpHP opened this issue Feb 7, 2018 · 4 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ExpHP
Copy link
Contributor

ExpHP commented Feb 7, 2018

fn main() {
    env!(); //~ ERROR env! takes 1 or 2 arguments
}

...or 2 arguments? 😐

fn main() {
    env!("testestest", "eh??"); //~ ERROR eh??
}
@ExpHP ExpHP changed the title env! has a completely undocumented optional second argument for setting the "not defined" error env! has a completely undocumented optional second argument for setting the error message Feb 7, 2018
@kennytm
Copy link
Member

kennytm commented Feb 7, 2018

It was introduced by @sfackler in c3825c8 in Rust 0.8 (along with option_env!). The relevant test case still exists today. I can't find any 2-argument env! calls other than the test cases.

@kennytm kennytm added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. labels Feb 7, 2018
@ExpHP
Copy link
Contributor Author

ExpHP commented Feb 8, 2018

I guess the question is: Is removing this an option that is even on the table? Or is the only option at this point to document it?

I wonder how reliable crater would be at finding usages? It does seem to me that the place where this is most likely to be used is in a build script, and there certainly are crates on crates.io with build scripts, but I'd imagine that most have external system dependencies (would crater even test those?).

@sfackler
Copy link
Member

sfackler commented Feb 8, 2018

Why would we want to go through the whole process of cratering and trying to figure out if it's okay to remove when we could just document it as a thing that exists?

@ExpHP
Copy link
Contributor Author

ExpHP commented Feb 8, 2018

I only tossed it out as a theoretical, i.e. "is removing it an option to even consider?" (i.e. can we just fix the docs, or should we wait?)

In order for that to be the case, it would need to be feasible, and there would need to be motivation for it.

My remark was about feasibility, but you're right about the motivation. The feature clearly isn't hurting anybody, so I can't see why anybody would want it to be removed.

kennytm added a commit to kennytm/rust that referenced this issue May 26, 2018
…dreavus

Add documentation about env! second argument

Fixes rust-lang#48044.

r? @QuietMisdreavus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. 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

3 participants