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

Can't find crate for test error #10716

Closed
caemor opened this issue Nov 7, 2021 · 3 comments
Closed

Can't find crate for test error #10716

caemor opened this issue Nov 7, 2021 · 3 comments
Labels
S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@caemor
Copy link

caemor commented Nov 7, 2021

It seems to be a new error or I always manually compiled with the specific target but rust analyzer outputs that it can't find crate for test with the target set to a the target seen below (and maybe to others as well?). For each bin, lib.rs or main.rs it outputs the exact same message once.

Reduced example:
Create new rust project with cargo new SomeName and then modify the following files:
.cargo/config.toml:

[build]
target = "thumbv7em-none-eabihf"

main.rs:

#![no_std]
fn main() {}

Rust Analyzer: v0.2.801

Copied Error Message:

{
	"resource": "/tmp/rustanalyzertest/src/main.rs",
	"owner": "rustc",
	"code": {
		"value": "E0463",
		"target": {
			"$mid": 1,
			"external": "https://doc.rust-lang.org/error-index.html#E0463",
			"path": "/error-index.html",
			"scheme": "https",
			"authority": "doc.rust-lang.org",
			"fragment": "E0463"
		}
	},
	"severity": 8,
	"message": "can't find crate for `test`\ncan't find crate",
	"source": "rustc",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 1
}
@Veykril
Copy link
Member

Veykril commented Nov 7, 2021

probably same as in #10659 (comment)

This is due to rust-analyzer implicitly passing --all-targets to the flycheck cargo invocation which makes it include the test crate which depends on std. You can get around this by setting the corresponding setting rust-analyzer.checkOnSave.allTargets to false.

@lnicola
Copy link
Member

lnicola commented Nov 15, 2021

@caemor did that work for you?

@lnicola lnicola added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Nov 15, 2021
@caemor
Copy link
Author

caemor commented Nov 15, 2021

Yes this fixed the issue, thanks.

@caemor caemor closed this as completed Nov 15, 2021
oddstr13 added a commit to oddstr13/dk-rtic-smoltcp-6lowpan that referenced this issue Mar 19, 2022
Daedrus added a commit to Daedrus/configfiles that referenced this issue Jun 23, 2023
So that the following error is fixed when working with embedded Rust
rust-lang/rust-analyzer#10716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

3 participants