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

Improve -Z unstable-options diagnostics and avoid an ICE #23274

Merged
merged 1 commit into from
Mar 12, 2015

Conversation

rprichard
Copy link
Contributor

  • Consumers of handle_options assume the unstable options are defined in
    the getopts::Matches value if -Z unstable-options is set, but that's not
    the case if there weren't any actual unstable options. Fix this by
    always reparsing options when -Z unstable-options is set.

  • If both argument parsing attempts fail, print the error from the second
    attempt rather than the first. The error from the first is very poor
    whenever unstable options are present. e.g.:

    $ rustc hello.rs -Z unstable-options --show-span
    error: Unrecognized option: 'show-span'.
    $ rustc hello.rs -Z unstable-options --pretty --pretty
    error: Unrecognized option: 'pretty'.
    $ rustc hello.rs -Z unstable-options --pretty --bad-option
    error: Unrecognized option: 'pretty'.

  • On the second parse, add a separate pass to reject unstable options if
    -Z unstable-options wasn't specified.

Fixes #21715.
r? @pnkfelix

 * Consumers of handle_options assume the unstable options are defined in
   the getopts::Matches value if -Z unstable-options is set, but that's not
   the case if there weren't any actual unstable options. Fix this by
   always reparsing options when -Z unstable-options is set.

 * If both argument parsing attempts fail, print the error from the second
   attempt rather than the first. The error from the first is very poor
   whenever unstable options are present. e.g.:

       $ rustc hello.rs -Z unstable-options --show-span
       error: Unrecognized option: 'show-span'.
       $ rustc hello.rs -Z unstable-options --pretty --pretty
       error: Unrecognized option: 'pretty'.
       $ rustc hello.rs -Z unstable-options --pretty --bad-option
       error: Unrecognized option: 'pretty'.

 * On the second parse, add a separate pass to reject unstable options if
   -Z unstable-options wasn't specified.

Fixes rust-lang#21715.
r? @pnkfelix
@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 11, 2015

@bors r=pnkfelix 61004f8

@pnkfelix
Copy link
Member

@bors rollup

@rprichard
Copy link
Contributor Author

One thing I should mention: if the user attempts to use an unstable option without -Z unstable-options, and uses it incorrectly, they will get an error message regarding the misuse:

$ rustc hello.rs --show-span
error: Argument to option 'show-span' missing.

Ideally, I think they'd instead see this error:

$ rustc hello.rs --show-span=expr
error: use of unstable option 'show-span' requires -Z unstable-options

I don't see how to fix this, though, and the new behavior seemed better to me.

Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 12, 2015
  * Consumers of handle_options assume the unstable options are defined in
   the getopts::Matches value if -Z unstable-options is set, but that's not
   the case if there weren't any actual unstable options. Fix this by
   always reparsing options when -Z unstable-options is set.

 * If both argument parsing attempts fail, print the error from the second
   attempt rather than the first. The error from the first is very poor
   whenever unstable options are present. e.g.:

       $ rustc hello.rs -Z unstable-options --show-span
       error: Unrecognized option: 'show-span'.
       $ rustc hello.rs -Z unstable-options --pretty --pretty
       error: Unrecognized option: 'pretty'.
       $ rustc hello.rs -Z unstable-options --pretty --bad-option
       error: Unrecognized option: 'pretty'.

 * On the second parse, add a separate pass to reject unstable options if
   -Z unstable-options wasn't specified.

Fixes rust-lang#21715.
r? @pnkfelix
@bors bors merged commit 61004f8 into rust-lang:master Mar 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: -Z unstable-options without extra argument
3 participants