-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
rust-lang/rust: "file not included in module tree" in libcore, broken go to definition #9203
Comments
Hm. |
This is definitely supposed to put it into a workspace, so this would be a bug. |
That would be a bug on |
Another possibility is that the way we're injecting the sysroot dependencies is interfering with the explicit |
It seems to be listed like a normal workspace member, so it probably is us doing something funny, indeed. dev/rust - [master●] » cargo metadata | jq '.packages | map(select(.name == "core"))'
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
[
{
"name": "core",
"version": "0.0.0",
"id": "core 0.0.0 (path+file:///home/jade/dev/rust/library/core)",
"license": "MIT OR Apache-2.0",
"license_file": null,
"description": "The Rust Core Library",
"source": null,
"dependencies": [
{
"name": "rand",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"req": "^0.7",
"kind": "dev",
"rename": null,
"optional": false,
"uses_default_features": true,
"features": [],
"target": null,
"registry": null
}
],
"targets": [
{
"kind": [
"lib"
],
"crate_types": [
"lib"
],
"name": "core",
"src_path": "/home/jade/dev/rust/library/core/src/lib.rs",
"edition": "2018",
"doc": true,
"doctest": true,
"test": false
},
{
"kind": [
"test"
],
"crate_types": [
"bin"
],
"name": "coretests",
"src_path": "/home/jade/dev/rust/library/core/tests/lib.rs",
"edition": "2018",
"doc": false,
"doctest": false,
"test": true
},
{
"kind": [
"bench"
],
"crate_types": [
"bin"
],
"name": "corebenches",
"src_path": "/home/jade/dev/rust/library/core/benches/lib.rs",
"edition": "2018",
"doc": false,
"doctest": false,
"test": true
}
],
"features": {
"debug_refcell": [],
"panic_immediate_abort": []
},
"manifest_path": "/home/jade/dev/rust/library/core/Cargo.toml",
"metadata": null,
"publish": null,
"authors": [
"The Rust Project Developers"
],
"categories": [],
"keywords": [],
"readme": null,
"repository": "https://github.com/rust-lang/rust.git",
"homepage": null,
"documentation": null,
"edition": "2018",
"links": null
}
] Re: putting something named /tmp/f - [main●] » cargo metadata | jq .
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
{
"packages": [
{
"name": "core",
"version": "0.1.0",
"id": "core 0.1.0 (path+file:///tmp/f/core)",
"license": null,
"license_file": null,
"description": null,
"source": null,
"dependencies": [],
"targets": [
{
"kind": [
"bin"
],
"crate_types": [
"bin"
],
"name": "core",
"src_path": "/tmp/f/core/src/main.rs",
"edition": "2018",
"doc": true,
"doctest": false,
"test": true
}
],
"features": {},
"manifest_path": "/tmp/f/core/Cargo.toml",
"metadata": null,
"publish": null,
"authors": [],
"categories": [],
"keywords": [],
"readme": null,
"repository": null,
"homepage": null,
"documentation": null,
"edition": "2018",
"links": null
},
{
"name": "f",
"version": "0.1.0",
"id": "f 0.1.0 (path+file:///tmp/f)",
"license": null,
"license_file": null,
"description": null,
"source": null,
"dependencies": [],
"targets": [
{
"kind": [
"bin"
],
"crate_types": [
"bin"
],
"name": "f",
"src_path": "/tmp/f/src/main.rs",
"edition": "2018",
"doc": true,
"doctest": false,
"test": true
}
],
"features": {},
"manifest_path": "/tmp/f/Cargo.toml",
"metadata": null,
"publish": null,
"authors": [],
"categories": [],
"keywords": [],
"readme": null,
"repository": null,
"homepage": null,
"documentation": null,
"edition": "2018",
"links": null
},
{
"name": "f2",
"version": "0.1.0",
"id": "f2 0.1.0 (path+file:///tmp/f/f2)",
"license": null,
"license_file": null,
"description": null,
"source": null,
"dependencies": [
{
"name": "core",
"source": null,
"req": "*",
"kind": null,
"rename": null,
"optional": false,
"uses_default_features": true,
"features": [],
"target": null,
"registry": null,
"path": "/tmp/f/core"
}
],
"targets": [
{
"kind": [
"bin"
],
"crate_types": [
"bin"
],
"name": "f2",
"src_path": "/tmp/f/f2/src/main.rs",
"edition": "2018",
"doc": true,
"doctest": false,
"test": true
}
],
"features": {},
"manifest_path": "/tmp/f/f2/Cargo.toml",
"metadata": null,
"publish": null,
"authors": [],
"categories": [],
"keywords": [],
"readme": null,
"repository": null,
"homepage": null,
"documentation": null,
"edition": "2018",
"links": null
}
],
"workspace_members": [
"f2 0.1.0 (path+file:///tmp/f/f2)",
"core 0.1.0 (path+file:///tmp/f/core)",
"f 0.1.0 (path+file:///tmp/f)"
],
"resolve": {
"nodes": [
{
"id": "core 0.1.0 (path+file:///tmp/f/core)",
"dependencies": [],
"deps": [],
"features": []
},
{
"id": "f 0.1.0 (path+file:///tmp/f)",
"dependencies": [],
"deps": [],
"features": []
},
{
"id": "f2 0.1.0 (path+file:///tmp/f/f2)",
"dependencies": [],
"deps": [],
"features": []
}
],
"root": "f 0.1.0 (path+file:///tmp/f)"
},
"target_directory": "/tmp/f/target",
"version": 1,
"workspace_root": "/tmp/f",
"metadata": null
} |
So does this setup work with RA? |
Appears so, core/src/main.rs is not getting the error about not being part of a crate graph in spite of being transitively put into the workspace as a dep of f2 as would be the setup in r-l/r. (workspace members are written as just f2 in the workspace manifest) |
Oh, actually I think it's simply this. |
That's the same thing as #7243 but on a more common project. Not sure what we should do about it though, other than detecting it and deciding to not be in the test cfg i guess. |
Well, I think the 'correct' way to go about it is to analyze the crate in both configurations, use non- |
In the specific case for I'm mildly concerned about the perf impact of double analyzing things and unsure what changes would be required to make it happen. Also, I remember having frustrations with not being able to set the cfgs while working on a crate that used them for features without changing the default set, so having some kind of UI/command to set them would be another way to accomplish this, though of course not always as slick (also, state 😱 ) |
We do want a UI for toggling features (and maybe targets as well), but I'm not sure toggling Hard-coding the crate name seems a bit too specific for my taste. I could imagine adding a setting for this, or something like that. |
Fixes crates which vanish when the 'test' cfg atom is set. Fix rust-lang#7243. Fix rust-lang#9203. Fix rust-lang#7225.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9227: Add a config setting to disable the 'test' cfg in specified crates r=matklad a=lf- If you are opening libcore from rust-lang/rust as opposed to e.g. goto definition from some other crate which would use the sysroot instance of libcore, a `#![cfg(not(test))]` would previously have made all the code excluded from the module tree, breaking the editor experience. Core does not need to ever be edited with `#[cfg(test)]` enabled, as the tests are in another crate. This PR puts in a slight hack that checks for the crate name "core" and turns off `#[cfg(test)]` for that crate. Fixes #9203 Fixes #9226 Co-authored-by: Jade <[email protected]>
When I open
library/core/src/str/converts.rs
in my editor, I get a "file not included in module tree" diagnostic and go to definition doesn't work. Also, go to definition on e.g.pub mod ffi
inlibrary/core/src/lib.rs
does not work. This is unfortunate for working on libcore.I am using this config from the recommended page:
Log
cc #8915
The text was updated successfully, but these errors were encountered: