Skip to content

rust-analyzer goes into "error state" in rustc repository #8667

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

Closed
RalfJung opened this issue Apr 26, 2021 · 6 comments
Closed

rust-analyzer goes into "error state" in rustc repository #8667

RalfJung opened this issue Apr 26, 2021 · 6 comments

Comments

@RalfJung
Copy link
Member

RalfJung commented Apr 26, 2021

To reproduce this problem, open the rustc repository in vsocde with rust-analyzer installed. After some time the "rust-analyzer" text in the status bar at the bottom turns into a barely readable dark-gray-on-blue with a warning triangle in front of it. Hovering that item shows "cargo check failed" followed by some cargo output ending in "...". No error is visible in that text (I did not find a way to copy-paste all that text). Running ./x.py check on the same code works just fine.

I have no idea what this "error state" means, though...

My workspace settings JSON to make RA work on rustc looks as follows:

{
    "rust-analyzer.checkOnSave.overrideCommand": [
        "./x.py",
        "check",
        "--json-output",
        "library/std"
        //, "compiler/rustc"
    ],
    "rust-analyzer.rustfmt.overrideCommand": [
        "./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt"
    ],
    "editor.formatOnSave": false,
    "files.watcherExclude": {
        "*rustc*/src/llvm-project/**": true,
        "*rustc*/build/**": true,
    },
    "files.exclude": {
        "src/llvm-project/**": true,
        "build/**": true
    },
}

"Rust Analyzer Client" output says

INFO [4/26/2021, 2:26:35 PM]: Extension version: 0.2.574
INFO [4/26/2021, 2:26:35 PM]: Using configuration {
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: false,
    chainingHints: true,
    maxLength: 25,
    parameterHints: true,
    typeHints: true
  },
  updates: { channel: 'stable', askBeforeDownload: true },
  server: { path: null, extraEnv: null },
  trace: { server: 'off', extension: false },
  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: false,
    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: [ './x.py', 'check', '--json-output', 'library/std' ]
  },
  completion: {
    addCallArgumentSnippets: true,
    addCallParenthesis: true,
    postfix: { enable: true },
    autoimport: { enable: true }
  },
  diagnostics: {
    enable: true,
    enableExperimental: true,
    disabled: [ 'unlinked-file', 'missing-match-arm' ],
    remapPrefix: {},
    warningsAsHint: [],
    warningsAsInfo: []
  },
  files: { watcher: 'client', excludeDirs: [] },
  hoverActions: {
    debug: true,
    enable: true,
    gotoTypeDef: true,
    implementations: true,
    run: true,
    linksInHover: true
  },
  lens: {
    debug: true,
    enable: false,
    implementations: true,
    run: true,
    methodReferences: false,
    references: false
  },
  linkedProjects: [],
  lruCapacity: null,
  notifications: { cargoTomlNotFound: true },
  procMacro: { enable: true, server: null },
  runnables: { overrideCargo: null, cargoExtraArgs: [] },
  rustcSource: null,
  rustfmt: {
    extraArgs: [],
    overrideCommand: [ './build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt' ]
  }
}
INFO [4/26/2021, 2:26:35 PM]: PersistentState: {
  lastCheck: 1590603478202,
  releaseId: 26923638,
  serverVersion: '0.2.565'
}
INFO [4/26/2021, 2:27:02 PM]: Using server binary at /home/r/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu
@flodiebold
Copy link
Member

Can you try setting rust-analyzer.cargo.runBuildScripts to false?

@RalfJung
Copy link
Member Author

I did that, then reloaded the window, but behavior is still as described above.

@matklad
Copy link
Member

matklad commented Apr 26, 2021

@RalfJung you want

{
    "rust-analyzer.cargo.runBuildScripts": false,
    "rust-analyzer.procMacro.enable": false,
}

If you don't disable proc macros, we'll still run build scripts. The error message will be marginally better with #8670.

The UX about settings is unfriendly ( Part of the problem is that VS Code doesn't allow us to distinguish unset settings...

@RalfJung
Copy link
Member Author

Yes, that does get rid of the error, thanks. :)

Is it expected that these features break when used in the rustc compiler workspace?

@matklad
Copy link
Member

matklad commented Apr 26, 2021

Yes at the moment. This features require tight integration with the build system. At the moment this is hard-coded to cargo check --workspace, which fails for me in the rustc repo. There's a desire to make that configurable, so that one can plug ./x.py check there, but we haven't done that yet.

@matklad
Copy link
Member

matklad commented Apr 26, 2021

(also, to give some more context -- rust-analyzer was in this partially-error state since we enabled proc macros by deafult a while ago. What changed is that we now actually report this error as bad good as we can :)

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

No branches or pull requests

3 participants