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

False positive error on function or assosciate items #19284

Open
chenyukang opened this issue Mar 4, 2025 · 5 comments
Open

False positive error on function or assosciate items #19284

chenyukang opened this issue Mar 4, 2025 · 5 comments
Labels
C-bug Category: bug

Comments

@chenyukang
Copy link
Member

rust-analyzer version v0.3.2330, there is an error like this:

Image

but I can jump to the definition of this function, means rust-analyzer actually knows function new_at, why is there still an error?

seems it comes from rustc output:

error[E0599]: no function or associated item named `new_at` found for struct `tentacle::runtime::Interval` in the current scope
  --> /Users/yukang/code/ckb/network/src/services/dump_peer_store.rs:72:45
   |
72 |                     p2p::runtime::Interval::new_at(DEFAULT_DUMP_INTERVAL, DEFAULT_DUMP_INTERVAL);
   |                                             ^^^^^^ function or associated item not found in `Interval`
   |
note: if you're trying to build a new `tentacle::runtime::Interval`, consider using `tentacle::runtime::Interval::new` which returns `tentacle::runtime::Interval`
  --> /Users/yukang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tentacle-0.6.2/src/runtime/tokio_runtime.rs:34:9
   |
34 |         pub fn new(period: Duration) -> Self {
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: there is an associated function `new` with a similar name
  --> /Users/yukang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tentacle-0.6.2/src/runtime/tokio_runtime.rs:34:9
   |
34 |         pub fn new(period: Duration) -> Self {
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

from the code there is no difference in accessibility:

Image
@chenyukang chenyukang added the C-bug Category: bug label Mar 4, 2025
@chenyukang
Copy link
Member Author

There is no error or warning from cargo check.

@lnicola
Copy link
Member

lnicola commented Mar 4, 2025

Those are rustc errors, so they should show up in cargo check --all-targets (+ anything else you've configured in settings).

@chenyukang
Copy link
Member Author

chenyukang commented Mar 4, 2025

Those are rustc errors, so they should show up in cargo check --all-targets (+ anything else you've configured in settings).

I run
cargo check --all-targets on the terminal command line, seems it does not show any error.

I open vscode logs for rust-analyzer, here is related configuration part:

{

...

runnables: {
    extraEnv: null,
    problemMatcher: [ '$rustc' ],
    askBeforeUpdateTest: true,
    command: null,
    extraArgs: [],
    extraTestBinaryArgs: [ '--show-output' ]
  },

...

check: {
    allTargets: true,
    command: 'check',
    extraArgs: [],
    extraEnv: {},
    features: [],
    ignore: [],
    invocationStrategy: 'per_workspace',
    noDefaultFeatures: null,
    overrideCommand: null,
    targets: null,
    workspace: true
  },

...

}

@ChayimFriedman2
Copy link
Contributor

What's your rust-analyzer config in settings.json (user and workspace)?

@chenyukang
Copy link
Member Author

In my user vscode settings.json rust-analyzer related contains:

    "rust-analyzer.restartServerOnConfigChange": true,
    "rust-analyzer.cargo.buildScripts.enable": true,
    "rust-analyzer.diagnostics.enable": false,
    "rust-analyzer.signatureInfo.documentation.enable": false,
    "rust-analyzer.lru.capacity": 256,
    "rust-analyzer.trace.server": "verbose",
    "rust-analyzer.cargo.features": "all",
    "rust-analyzer.checkOnSave": true,
    "rust-analyzer.inlayHints.maxLength": 6,
    "rust-analyzer.cachePriming.numThreads": 6,
    "rust-analyzer.showRequestFailedErrorNotification": false,
    "rust-analyzer.cargo.targetDir": true,
    "rust-analyzer.testExplorer": true,
    "rust-analyzer.assist.termSearch.borrowcheck": false,
    "rust-analyzer.workspace.symbol.search.kind": "all_symbols",
    "rust-analyzer.completion.postfix.enable": false,
    "rust-analyzer.completion.callable.snippets": "none",

I have some setting in the project dir .vscode/settings.json:

{
    "rust-analyzer.check.invocationStrategy": "per_workspace",
    "rust-analyzer.checkOnSave": true,
    "rust-analyzer.trace.server": "verbose",
    "rust-analyzer.diagnostics.enable": false,
    "rust-analyzer.cargo.features": [],
    "rust-analyzer.check.allTargets": true,
    "rust-analyzer.check.features": [],

    "[rust]": {
        "editor.defaultFormatter": "rust-lang.rust-analyzer",
        "editor.formatOnSave": true,
    },
    "rust-analyzer.linkedProjects": [
        "./Cargo.toml",
        "test/Cargo.toml",
        "./benches/Cargo.toml",
        "./shared/Cargo.toml",
        "./script/Cargo.toml",
    ],
    "rust-analyzer.cargo.autoreload": true,
    "rust-analyzer.cargo.buildScripts.invocationStrategy": "per_workspace",
    "rust-analyzer.cargo.targetDir": true,
    "search.exclude": {
        "**/.git": true,
        "**/llvm-project": true,
        "**/tmp": true,
        "**/test/vendor": true,
        "**/util/rich-indexer/src/tests/": true,
        "**/docs/ckb_rpc_openrpc": true,
    },
    "githubPullRequests.remotes": [
        "upstream"
    ],
    "chat.editor.fontWeight": "default",
    "editor.fontWeight": "448",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants