Musings on rust-analyzer, "!MISSING: command!", rustlings - approachability

Starting small means going rust-lang/rustlings: Small exercises to get you used to reading and writing Rust code! (github.com)

And that then yields a somewhat unpleasant experience with rust-analyzer:

  • open the cloned repo in Visual Studio Code (latest), with rust-analyzer at nightly and latest

  • browse into ./clippy

  • open clippy.rs
    -> "!!MISSING: command!!"

    image

I believe I know why that is the case: There was no wrapping cargo new project - this is a "raw" Rust source file, straight from the repo.

For me, there are two noteworthy things:
a) "!!MISSING: command!!" is Not A Good Diagnostic
b) for squeaking rustlings like myself, it would be awesome to enable "single sole Rust file" support.

Let me fn main() { some(); nonsense(); } #[test] ... and poke around. Given that, the rustlings repo would work out. Now, the counterpoint to that is set by https://github.com/ProgrammingRust/examples - where every single example is fully fleshed out with Cargo.toml. So... ho-humm.

Eh, reply-to-self: The other critical part is that, in vscode,
a) the source file is opened via a folder (or vscode workspace, which implies folders)
b) the folder contains the Cargo.toml

Once it is clear (bloody nose?) that this is absolutely mandatory - i.e. rust-analyzer depends on a project, whereas rustc (CLI) can work OK with just a file - it gets more obvious. Getting there is not ... "ergonomic" (sorry, learning to like the word ;))

It's not a diagnostic, it's a bug that should be fixed for a while now.

Regarding single-file support, that is also a known missing feature but not trivial to do.

I think in my case the !!MISSING: command!! is only triggered by rust-analyzer operating on an isolated single Rust source file (as is the case with the rustlings repo, where they have these single-file exercises / samples)

I did find all these references to "rust-analyzer cannot handle the code", but here it's just very consistently on every single-source isolated rust source file.

My recommendation would be to address this at least to the extent that !!MISSING: command!! is not shown in the single-file scenario; it leaves somewhat of a bad impression.

Can you check what version of rust-analyzer you're using? This should already be fixed.

I am on the nightly channel for rust-analyzer:

DEBUG [4/20/2021, 4:10:58 PM]: /home/stefan/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu --version: {
  status: 0,
  signal: null,
  output: [ null, 'rust-analyzer 2021-04-19-55-g15b34667c\n', '' ],
  pid: 35226,
  stdout: 'rust-analyzer 2021-04-19-55-g15b34667c\n',
  stderr: ''
}

Reproduction (I can submit on github if you prefer - just need the right project/repo):

  • vscode + rust-analyzer extension
  • nightly channel rust-analyzer
  • clone git@github.com:rust-lang/rustlings.git
  • open repo base folder in vscode
  • open ./clippy/clippy1.rs

I can't reproduce this with current rust-analyzer, either the latest weekly or current master. It might help if you report it.

FWIW, a totally fresh system does not exhibit the behaviour I am describing above.

I'll try to find some root/contributing cause of that behaviour on my workhorse system (which should have been reasonably clean, hmmm).

To be honest, I suspect that you're somehow running an old version, despite the log you posted. Does the "Show RA version" command in VSCode show the same version?

So, yesterday night the Rust Analyzer VS Code extension update did fly by; the VS Code extension page has it as "v0.3.580"

This morning I opened my local clone of GitHub - rust-lang/rustlings: Small exercises to get you used to reading and writing Rust code! and I was asked about updating the language server component

After a restart of VS Code, just for good measure, the VS Code command "Rust Analyzer: Show RA Version" renders rust-analyzer version: 6b2b6c1b5 2021-05-01 nightly as a toast.

Then clicking around on the clippy1.rs/clippy2.rs continues to show the "!!MISSING: command!!".

For context, the full output of the "Rust Analyzer Client" Output window below.

This is Fedora 33, and I am not aware of having done anything nasty :slight_smile:

Will still try to find the trigger, but as you can see from my response lag, it might take a while.

INFO [5/1/2021, 10:06:28 AM]: Extension version: 0.3.580
INFO [5/1/2021, 10:06:28 AM]: Using configuration {
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: true,
    smallerHints: true,
    chainingHints: true,
    maxLength: 25,
    parameterHints: true,
    typeHints: true
  },
  updates: { channel: 'nightly', askBeforeDownload: true },
  server: { path: null, extraEnv: null },
  trace: { server: 'off', extension: true },
  debug: {
    engine: 'auto',
    sourceFileMap: {
      '/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
    },
    openDebugPane: false,
    engineSettings: {}
  },
  assist: {
    importMergeBehavior: 'full',
    importPrefix: 'plain',
    importGroup: true
  },
  callInfo: { full: true },
  cargo: {
    autoreload: true,
    allFeatures: true,
    features: [],
    runBuildScripts: true,
    useRustcWrapperForBuildScripts: true,
    noDefaultFeatures: false,
    target: null,
    noSysroot: false
  },
  checkOnSave: {
    enable: true,
    allFeatures: null,
    allTargets: true,
    command: 'check',
    noDefaultFeatures: null,
    target: null,
    extraArgs: [],
    features: null,
    overrideCommand: null
  },
  completion: {
    addCallArgumentSnippets: true,
    addCallParenthesis: true,
    postfix: { enable: true },
    autoimport: { enable: true }
  },
  diagnostics: {
    enable: true,
    enableExperimental: true,
    disabled: [],
    remapPrefix: {},
    warningsAsHint: [],
    warningsAsInfo: []
  },
  files: { watcher: 'client', excludeDirs: [] },
  hoverActions: {
    debug: true,
    enable: true,
    gotoTypeDef: true,
    implementations: true,
    run: true,
    linksInHover: true
  },
  lens: {
    debug: true,
    enable: true,
    implementations: true,
    run: true,
    methodReferences: true,
    references: true
  },
  linkedProjects: [],
  lruCapacity: null,
  notifications: { cargoTomlNotFound: true },
  procMacro: { enable: true, server: null },
  runnables: { overrideCargo: null, cargoExtraArgs: [] },
  rustcSource: null,
  rustfmt: { extraArgs: [], overrideCommand: null }
}
INFO [5/1/2021, 10:06:28 AM]: PersistentState: {
  lastCheck: 1619853344850,
  releaseId: 42298458,
  serverVersion: '0.3.580'
}
INFO [5/1/2021, 10:06:28 AM]: Using server binary at /home/stefan/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu
DEBUG [5/1/2021, 10:06:28 AM]: Checking availability of a binary at /home/stefan/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu
DEBUG [5/1/2021, 10:06:28 AM]: /home/stefan/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu --version: {
  status: 0,
  signal: null,
  output: [ null, 'rust-analyzer 6b2b6c1b5 2021-05-01 nightly\n', '' ],
  pid: 7098,
  stdout: 'rust-analyzer 6b2b6c1b5 2021-05-01 nightly\n',
  stderr: ''
}
INFO [5/1/2021, 10:10:05 AM]: Extension version: 0.3.580
INFO [5/1/2021, 10:10:05 AM]: Using configuration {
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: true,
    smallerHints: true,
    chainingHints: true,
    maxLength: 25,
    parameterHints: true,
    typeHints: true
  },
  updates: { channel: 'nightly', askBeforeDownload: true },
  server: { path: null, extraEnv: null },
  trace: { server: 'off', extension: true },
  debug: {
    engine: 'auto',
    sourceFileMap: {
      '/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
    },
    openDebugPane: false,
    engineSettings: {}
  },
  assist: {
    importMergeBehavior: 'full',
    importPrefix: 'plain',
    importGroup: true
  },
  callInfo: { full: true },
  cargo: {
    autoreload: true,
    allFeatures: true,
    features: [],
    runBuildScripts: true,
    useRustcWrapperForBuildScripts: true,
    noDefaultFeatures: false,
    target: null,
    noSysroot: false
  },
  checkOnSave: {
    enable: true,
    allFeatures: null,
    allTargets: true,
    command: 'check',
    noDefaultFeatures: null,
    target: null,
    extraArgs: [],
    features: null,
    overrideCommand: null
  },
  completion: {
    addCallArgumentSnippets: true,
    addCallParenthesis: true,
    postfix: { enable: true },
    autoimport: { enable: true }
  },
  diagnostics: {
    enable: true,
    enableExperimental: true,
    disabled: [],
    remapPrefix: {},
    warningsAsHint: [],
    warningsAsInfo: []
  },
  files: { watcher: 'client', excludeDirs: [] },
  hoverActions: {
    debug: true,
    enable: true,
    gotoTypeDef: true,
    implementations: true,
    run: true,
    linksInHover: true
  },
  lens: {
    debug: true,
    enable: true,
    implementations: true,
    run: true,
    methodReferences: true,
    references: true
  },
  linkedProjects: [],
  lruCapacity: null,
  notifications: { cargoTomlNotFound: true },
  procMacro: { enable: true, server: null },
  runnables: { overrideCargo: null, cargoExtraArgs: [] },
  rustcSource: null,
  rustfmt: { extraArgs: [], overrideCommand: null }
}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.