Skip to content

external_subcommand: error[E0425]: cannot find value other in this scope #447

@d-e-s-o

Description

@d-e-s-o

I have the same sample program as over in #424:

use structopt::StructOpt;

macro_rules! Command {
  ( $name:ident, [
    #[$meta:meta] $var:ident($inner:ty)
  ] ) => {
    #[derive(Debug, PartialEq, structopt::StructOpt)]
    enum $name {
      #[$meta] $var($inner),
    }
  };
}

Command! {GitCmd, [
  #[structopt(external_subcommand)]
  Ext(Vec<String>)
]}

fn main() {
  assert_eq!(
    GitCmd::from_iter(&["test", "git", "status"]),
    GitCmd::Ext(vec!["git".to_string(), "status".to_string()]),
  );
}

Now it fails to compile with:

error[E0425]: cannot find value `other` in this scope
  --> src/main.rs:16:11
   |
16 |   Ext(Vec<String>)
   |           ^^^^^^ not found in this scope

Seems to be yet another span issue. Also related is 0852b91, which changes the error from something along the lines of

error: The type must be either `Vec<String>` or `Vec<OsString>` to be used with `external_subcommand`.
   --> main.rs:25:18
    |
25  |             $var$(($inner))?,
    |                    ^^^^^^
    |

to the above. I am using Rust 1.48. I am absolutely positive it worked with earlier Rust versions at some point (in fact, I still have the logs of a successful CI run with 1.42.0), but I can't try with all other Rust versions right now. I experimented with structopt 0.3.17 to 0.3.20, all exhibit either of the issues mentioned above (so the combination of structopt 0.3.17 with structopt-derive 0.4.10 and Rust 1.42.0 is/was known good)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions