-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Parse cargo config files with origins #21015
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
base: master
Are you sure you want to change the base?
Conversation
34cbc1f to
05e273e
Compare
| } | ||
| }) | ||
| .collect(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed anymore in favor of more correct handling in https://github.com/rust-lang/rust-analyzer/pull/21015/files#diff-f8eec93ade9e903194d42ec18dbc7494e9fbd263d9aa5f6217994623c7fd2cecR78
| ) -> Option<Self> { | ||
| let mut cargo_config = sysroot.tool(Tool::Cargo, manifest.parent(), extra_env); | ||
| cargo_config | ||
| .args(["-Z", "unstable-options", "config", "get", "--format", "toml", "--show-origin"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, --show-origin flag works only with toml format
48e160f to
3374118
Compare
ChayimFriedman2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels quite hacky, but if there is no other way then LGTM. We can't merge this yet until we solve the subtree problem, though.
| let toml = DeTable::parse(toml_str) | ||
| .inspect_err(|err| tracing::debug!("Failed to parse cargo config into toml: {err:?}")) | ||
| .ok()?; | ||
| let line_ends = toml_str.lines().fold(vec![], |mut acc, l| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map().collect() instead?
3374118 to
8aad85e
Compare
Fixes #20932
The example outputs of
cargo config get --format toml --show-originare in https://github.com/rust-lang/cargo/blob/8c4a25c6d68b2be0b65cfda8c31aab58c88d4cbd/tests/testsuite/cargo_config/mod.rs