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

Unresolved import for gdnative::api #7146

Closed
Kreyren opened this issue Jan 4, 2021 · 9 comments
Closed

Unresolved import for gdnative::api #7146

Kreyren opened this issue Jan 4, 2021 · 9 comments

Comments

@Kreyren
Copy link

Kreyren commented Jan 4, 2021

See https://github.com/RXT0147/unnamedGame/pull/1/files#diff-e1cec28f123335e7874fd650acab37adf149e0878763e6b7ad700aeb493f0102R4

image

Seems like rust-analyzer misinterpreting unresolved import to me?

Rust analyzer v0.2.432
rustc 1.49.0 (e1884a8e3 2020-12-29)
cargo 1.49.0 (d00d64df9 2020-12-05)

@edwin0cheng
Copy link
Member

edwin0cheng commented Jan 4, 2021

Have you tried to enable followings in your settings : (gdnative::api is under binding feature)

rust-analyzer.cargo.allFeatures : true

@Kreyren
Copy link
Author

Kreyren commented Jan 5, 2021

@edwin0cheng Configuration is set with same result.

image

FWIW the configuration of vscode is managed from https://github.com/RXT0147/RXT0147 that has the repository in question as a submodule in projects/unnamedGame, but i've tried to move .vscode to unnamedGame and open that directory directly with same result as shown above.

@edwin0cheng
Copy link
Member

It is weird , without any special settings :

Screenshot from 2021-01-05 10-53-27

So any error shown in Output Panel?

@Kreyren
Copy link
Author

Kreyren commented Jan 6, 2021

So any error shown in Output Panel? @edwin0cheng

Just following:

Rust Analyzer Client Output
INFO [1/6/2021, 1:31:40 AM]: Extension version: 0.2.441
INFO [1/6/2021, 1:31:40 AM]: Using configuration {
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: true,
    chainingHints: true,
    maxLength: null,
    parameterHints: true,
    typeHints: true
  },
  updates: { channel: 'stable', askBeforeDownload: true },
  serverPath: null,
  server: { 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: { importMergeBehaviour: 'full', importPrefix: 'plain' },
  callInfo: { full: true },
  cargo: {
    autoreload: true,
    allFeatures: true,
    features: [],
    loadOutDirsFromCheck: false,
    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: [],
    warningsAsHint: [],
    warningsAsInfo: []
  },
  files: { watcher: 'client' },
  hoverActions: {
    debug: true,
    enable: true,
    gotoTypeDef: true,
    implementations: true,
    run: true,
    linksInHover: true
  },
  lens: {
    debug: true,
    enable: true,
    implementations: true,
    run: true,
    methodReferences: false
  },
  linkedProjects: [],
  lruCapacity: null,
  notifications: { cargoTomlNotFound: true },
  procMacro: { enable: false },
  runnables: { overrideCargo: null, cargoExtraArgs: [] },
  rustcSource: null,
  rustfmt: { extraArgs: [], overrideCommand: null }
}
INFO [1/6/2021, 1:31:40 AM]: PersistentState: {
  lastCheck: undefined,
  releaseId: undefined,
  serverVersion: '0.2.441'
}
INFO [1/6/2021, 1:31:40 AM]: Using server binary at /home/kreyren/.config/VSCodium/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu

@edwin0cheng
Copy link
Member

Oh , have you enabled proc-macro supported ?

    "rust-analyzer.cargo.loadOutDirsFromCheck": true,
    "rust-analyzer.procMacro.enable": true,

@Kreyren
Copy link
Author

Kreyren commented Jan 8, 2021

@edwin0cheng Seems to work now O.o

image

@edwin0cheng
Copy link
Member

Great !

@Kreyren
Copy link
Author

Kreyren commented Jan 8, 2021

@edwin0cheng Can you elaborate why is procMacro important? Would like to add a note to the code about why it fixed it O.o

@edwin0cheng
Copy link
Member

edwin0cheng commented Jan 8, 2021

Sure!

It is not quite related to proc-macro, but to support include!() macro, which is used in gdnative::binding crate, RA needed to know where is the OUTDIR of that crate. This information is only possible (at least for now) by parsing from cargo check.

"rust-analyzer.cargo.loadOutDirsFromCheck" : true

The flags above enabled RA to run cargo check command at the initialization phase. For more details , see #6448.

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

2 participants