Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Implement ---version command line option #304

Closed

Description

@tetsuharuohzeki

We cannot know what version is running without --version. This is pretty important to trouble shooting.

Activity

  1. tetsuharuohzeki commented on May 10, 2017

    @tetsuharuohzeki
    Author

    related issue rust-lang/rust#41197

  2. tetsuharuohzeki commented on May 10, 2017

    @tetsuharuohzeki
    Author

    Which should we use to implement this?

  3. tetsuharuohzeki commented on May 10, 2017

    @tetsuharuohzeki
    Author

    Which should we use to implement this?

    @nrc @jonathandturner

    How do you think about it?

  4. nrc commented on May 10, 2017

    @nrc
    Member

    You could use getopts if you like - I would personally just manually check for --version and start using getopts if/when command line options get more complicated

  5. tetsuharuohzeki commented on May 10, 2017

    @tetsuharuohzeki
    Author

    I faced to these problems 😢

    1. If I add getopts to Cargo.toml's,_

    then rustc happening following compile error:

    error[E0053]: method `early_callback` has an incompatible type for trait
       --> src/build.rs:524:13
        |
    524 | /             fn early_callback(&mut self,
    525 | |                               matches: &getopts::Matches,
    526 | |                               sopts: &config::Options,
    527 | |                               cfg: &ast::CrateConfig,
    ...   |
    531 | |                 self.default_calls.early_callback(matches, sopts, cfg, descriptions, output)
    532 | |             }
        | |_____________^ expected struct `getopts::Matches`, found a different struct `getopts::Matches`
        |
        = note: expected type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &getopts::Matches, &build::rustc::session::config::Options, &std::collections::HashSet<(build::syntax::ast::Symbol, std::option::Option<build::syntax::ast::Symbol>)>, &build::errors::registry::Registry, build::rustc::session::config::ErrorOutputType) -> build::rustc_driver::Compilation` (struct `getopts::Matches`)
                   found type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &getopts::Matches, &build::rustc::session::config::Options, &std::collections::HashSet<(build::syntax::ast::Symbol, std::option::Option<build::syntax::ast::Symbol>)>, &build::errors::registry::Registry, build::rustc::session::config::ErrorOutputType) -> build::rustc_driver::Compilation` (struct `getopts::Matches`)
    note: Perhaps two different versions of crate `getopts` are being used?
       --> src/build.rs:524:13
        |
    524 | /             fn early_callback(&mut self,
    525 | |                               matches: &getopts::Matches,
    526 | |                               sopts: &config::Options,
    527 | |                               cfg: &ast::CrateConfig,
    ...   |
    531 | |                 self.default_calls.early_callback(matches, sopts, cfg, descriptions, output)
    532 | |             }
        | |_____________^
    
    error[E0053]: method `no_input` has an incompatible type for trait
       --> src/build.rs:534:13
        |
    534 | /             fn no_input(&mut self,
    535 | |                         matches: &getopts::Matches,
    536 | |                         sopts: &config::Options,
    537 | |                         cfg: &ast::CrateConfig,
    ...   |
    542 | |                 self.default_calls.no_input(matches, sopts, cfg, odir, ofile, descriptions)
    543 | |             }
        | |_____________^ expected struct `getopts::Matches`, found a different struct `getopts::Matches`
        |
        = note: expected type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &getopts::Matches, &build::rustc::session::config::Options, &std::collections::HashSet<(build::syntax::ast::Symbol, std::option::Option<build::syntax::ast::Symbol>)>, &std::option::Option<std::path::PathBuf>, &std::option::Option<std::path::PathBuf>, &build::errors::registry::Registry) -> std::option::Option<(build::rustc::session::config::Input, std::option::Option<std::path::PathBuf>)>` (struct `getopts::Matches`)
                   found type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &getopts::Matches, &build::rustc::session::config::Options, &std::collections::HashSet<(build::syntax::ast::Symbol, std::option::Option<build::syntax::ast::Symbol>)>, &std::option::Option<std::path::PathBuf>, &std::option::Option<std::path::PathBuf>, &build::errors::registry::Registry) -> std::option::Option<(build::rustc::session::config::Input, std::option::Option<std::path::PathBuf>)>` (struct `getopts::Matches`)
    note: Perhaps two different versions of crate `getopts` are being used?
       --> src/build.rs:534:13
        |
    534 | /             fn no_input(&mut self,
    535 | |                         matches: &getopts::Matches,
    536 | |                         sopts: &config::Options,
    537 | |                         cfg: &ast::CrateConfig,
    ...   |
    542 | |                 self.default_calls.no_input(matches, sopts, cfg, odir, ofile, descriptions)
    543 | |             }
        | |_____________^
    
    error[E0053]: method `late_callback` has an incompatible type for trait
       --> src/build.rs:545:13
        |
    545 | /             fn late_callback(&mut self,
    546 | |                              matches: &getopts::Matches,
    547 | |                              sess: &Session,
    548 | |                              input: &Input,
    ...   |
    552 | |                 self.default_calls.late_callback(matches, sess, input, odir, ofile)
    553 | |             }
        | |_____________^ expected struct `getopts::Matches`, found a different struct `getopts::Matches`
        |
        = note: expected type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &getopts::Matches, &build::rustc::session::Session, &build::rustc::session::config::Input, &std::option::Option<std::path::PathBuf>, &std::option::Option<std::path::PathBuf>) -> build::rustc_driver::Compilation` (struct `getopts::Matches`)
                   found type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &getopts::Matches, &build::rustc::session::Session, &build::rustc::session::config::Input, &std::option::Option<std::path::PathBuf>, &std::option::Option<std::path::PathBuf>) -> build::rustc_driver::Compilation` (struct `getopts::Matches`)
    note: Perhaps two different versions of crate `getopts` are being used?
       --> src/build.rs:545:13
        |
    545 | /             fn late_callback(&mut self,
    546 | |                              matches: &getopts::Matches,
    547 | |                              sess: &Session,
    548 | |                              input: &Input,
    ...   |
    552 | |                 self.default_calls.late_callback(matches, sess, input, odir, ofile)
    553 | |             }
        | |_____________^
    
    error[E0053]: method `build_controller` has an incompatible type for trait
       --> src/build.rs:555:13
        |
    555 | /             fn build_controller(&mut self,
    556 | |                                 sess: &Session,
    557 | |                                 matches: &getopts::Matches)
    558 | |                                 -> CompileController<'a> {
    ...   |
    575 | |                 result
    576 | |             }
        | |_____________^ expected struct `getopts::Matches`, found a different struct `getopts::Matches`
        |
        = note: expected type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &build::rustc::session::Session, &getopts::Matches) -> build::rustc_driver::driver::CompileController<'a>` (struct `getopts::Matches`)
                   found type `fn(&mut build::BuildQueue::rustc::RlsRustcCalls, &build::rustc::session::Session, &getopts::Matches) -> build::rustc_driver::driver::CompileController<'a>` (struct `getopts::Matches`)
    note: Perhaps two different versions of crate `getopts` are being used?
       --> src/build.rs:555:13
        |
    555 | /             fn build_controller(&mut self,
    556 | |                                 sess: &Session,
    557 | |                                 matches: &getopts::Matches)
    558 | |                                 -> CompileController<'a> {
    ...   |
    575 | |                 result
    576 | |             }
        | |_____________^
    
    error: aborting due to 4 previous errors
    
    error: Could not compile `rls`.
    

    2. If I use getopts which is an indirect dependency,_

    error[E0432]: unresolved import `getopts::Options`
     --> src/version.rs:1:15
      |
    1 | use getopts::{Options, Matches};
      |               ^^^^^^^ no `Options` in the root
    
    error: aborting due to previous error
    
    error: Could not compile `rls`.
    

    I'll just check --version flag manually.

  6. Nashenas88 commented on May 10, 2017

    @Nashenas88
    Contributor

    That looks like there's two different versions of getopts. What I've done to solve this kind of issue is install cargo tree and then run cargo tree | grep getopts which should show you all versions being compiled. If you change the getopts version to match the existing ones used by the dependencies, then this should compile.

  7. tetsuharuohzeki commented on May 10, 2017

    @tetsuharuohzeki
    Author

    @Nashenas88

    This indirect dependency getopts is v0.2.14 and is introduced rustfmt v0.8.3 (https://github.com/rust-lang-nursery/rustfmt#7a257732).

    However, build::RlsRustcCalls::early_callback is the implementation of self::rustc_driver::CompilerCalls. So its getopts is specified in librustc_driver. It could not suceed to compile even if I specify a arbitrary version in Cargo.toml.


    What is the better way to resolve this complex puzzle?

  8. nrc commented on May 10, 2017

    @nrc
    Member

    What is the better way to resolve this complex puzzle?

    I would not use getopts and parse the command line arguments manually (long term we might need to do something else).

  9. tetsuharuohzeki commented on May 11, 2017

    @tetsuharuohzeki
    Author

    Fixed by #308

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions