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

not found error, while cargo check & build works fine #16552

Closed
Zercerium opened this issue Feb 13, 2024 · 20 comments
Closed

not found error, while cargo check & build works fine #16552

Zercerium opened this issue Feb 13, 2024 · 20 comments
Labels
C-bug Category: bug

Comments

@Zercerium
Copy link

Zercerium commented Feb 13, 2024

/Users/nick/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/test/src/test_result.rs:102:24
    |
102 |             Some(libc::SIGABRT) => TestResult::TrFailed,
    |                        ^^^^^^^ not found in `libc`

rust-analyzer version: 0.4.1838-standalone (c06ca6c 2024-02-11) + 0.3.1839-standalone (c06ca6c 2024-02-11)

rustc version: rustc 1.78.0-nightly (b381d3ab2 2024-02-12)

OS: Mac(M1)

fresh project generated via: cargo generate esp-rs/esp-idf-template cargo

cargo build & check works fine and don't throw this error, only r-a
if I remove the line in test_result.rs everything works fine and r-a finishes without an error

if you need further information or if I can do anything to narrow the scope down please just tell

@Zercerium Zercerium added the C-bug Category: bug label Feb 13, 2024
@lnicola
Copy link
Member

lnicola commented Feb 13, 2024

That's a file from the standard library, why would you edit it?

@Zercerium
Copy link
Author

nah i don't want to edit it 😅. Was just for testing, if the error is then gone.

@lnicola
Copy link
Member

lnicola commented Feb 13, 2024

So what error are you getting when you don't have the file open?

@Zercerium
Copy link
Author

Zercerium commented Feb 13, 2024

2024-02-13T17:35:30.838956Z ERROR rust_analyzer::main_loop: FetchBuildDataError:
error[E0531]: cannot find unit struct, unit variant or constant `SIGABRT` in crate `libc`
   --> /Users/nick/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/test/src/test_result.rs:102:24
    |
102 |             Some(libc::SIGABRT) => TestResult::TrFailed,
    |                        ^^^^^^^ not found in `libc`


error: aborting due to 1 previous error


For more information about this error, try `rustc --explain E0531`.

error: could not compile `test` (lib) due to 2 previous errors

I don't have this file normally open, this error shows up in the r-a: LS window after creating a new project with the command cargo generate esp-rs/esp-idf-template cargo and after r-a finishes with it run

After I got this error I opened test_result.rs and deleted the mentioned line, to test if the deletion clears the error. Which it does.

@Kezii
Copy link

Kezii commented Feb 15, 2024

I'm having the same issue, rust analyzer breaks when using an esp-idf project

2024-02-15T21:41:26.933826Z ERROR rust_analyzer::main_loop: FetchBuildDataError:
error[E0531]: cannot find unit struct, unit variant or constant `SIGABRT` in crate `libc`
   --> /home/[...]/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/test_result.rs:102:24
    |
102 |             Some(libc::SIGABRT) => TestResult::TrFailed,
    |                        ^^^^^^^ not found in `libc`


error: aborting due to 1 previous error


For more information about this error, try `rustc --explain E0531`.

error: could not compile `test` (lib) due to 2 previous errors

@mrchantey
Copy link

mrchantey commented Feb 16, 2024

Yes same got the error on an esp-idf project after updating rust nightly to

rustc 1.78.0-nightly (ee9c7c940 2024-02-14)

@Veykril
Copy link
Member

Veykril commented Feb 16, 2024

Does this happen with the latest nightly rust-analyzer build? 2024-02-15 / 2024-02-16

@Zercerium
Copy link
Author

Does this happen with the latest nightly rust-analyzer build? 2024-02-15 / 2024-02-16

Yes, updates to rust-analyzer version: 0.4.1843-standalone (b9b0d29 2024-02-15) and rustc 1.78.0-nightly (a4472498d 2024-02-15)

@weiying-chen
Copy link

weiying-chen commented Feb 17, 2024

I'm having exactly the same issue. For those having this issue, is rust-analyzer not catch errors like these?

@weiying-chen
Copy link

weiying-chen commented Feb 18, 2024

Yes same got the error on an esp-idf project after updating rust nightly to

rustc 1.78.0-nightly (ee9c7c940 2024-02-14)

@mrchantey Which rust nightly version doesn't have this error?

@mrchantey
Copy link

@mrchantey Which rust nightly version doesn't have this error?

Pretty sure I was on the previous version 1.77.0-nightly

@weiying-chen
Copy link

weiying-chen commented Feb 18, 2024

@mrchantey I confirmed it: rust-analyzer works perfectly in esp-idf projects if you use rustc 1.77.0-nightly (2a3e63551 2023-12-30). The issue is rustc 1.78.0-nightly (ee9c7c940 2024-02-14).

@Zercerium
Copy link
Author

seems plausible cause the line was added here, if I'm correct rust-lang/rust@f622e83#diff-c91a894be23c4fb9ac51642c91c20500cdd48f7f0114b4b3c6a8a1cb47afa674

@jellyterra
Copy link

1711989266791
I have similar problem on amd64

@milewski
Copy link

milewski commented Apr 2, 2024

Same problem here, temporarily I'm commenting out that offending line and it works:

None => match status.signal() {
    // Some(libc::SIGABRT) => TestResult::TrFailed,
    Some(signal) => {
        TestResult::TrFailedMsg(format!("child process exited with signal {signal}"))
    }
    None => unreachable!("status.code() returned None but status.signal() was None"),
},

@Veykril
Copy link
Member

Veykril commented Apr 2, 2024

Try setting "rust-analyzer.cargo.allTargets": false, (needs latest nightly r-a, from 01.04.2024) if you are working on a no-std target. If you still run into that with that setting we'll need more info.

@Tevz-Beskovnik
Copy link

Enabling that setting does not resolve the issue.

@faulesocke
Copy link

Also getting that very same error when running cargo check --tests for my esp-idf projects. Seems like the error really is in the test library (or one of it's dependencies).

@faulesocke
Copy link

faulesocke commented Apr 21, 2024

When I set the option cargo.allTargets to false, this makes it work without patching the source. Indeed, passing --all-targets implies --tests.

Doing this in my neovim+lazy.nvim setup works (for example) like this:

{
  "mrcjkb/rustaceanvim",
  opts = function(_, opts)
    opts.server.default_settings["rust-analyzer"].cargo.allTargets = false
  end,
}

But note that this is only a workaround.

@Veykril
Copy link
Member

Veykril commented Apr 21, 2024

Okay thanks for confirming that the setting works, then I'll close this in favor of #14205

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

10 participants