Skip to content

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

Closed

Description

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

...or 2 arguments? 😐

fn main() {
    env!("testestest", "eh??"); //~ ERROR eh??
}

Activity

  1. 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[/+] on Feb 7, 2018
  2. kennytm commented on Feb 7, 2018

    @kennytm
    Member

    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.

  3. added
    T-libs-api
    A-docs
    C-bug
    on Feb 7, 2018
  4. ExpHP commented on Feb 8, 2018

    @ExpHP
    ContributorAuthor

    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?).

  5. sfackler commented on Feb 8, 2018

    @sfackler
    Member

    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?

  6. ExpHP commented on Feb 8, 2018

    @ExpHP
    ContributorAuthor

    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.

  7. added a commit that references this issue on May 26, 2018
    ee18e92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsC-bugT-libs-api

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions