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

feat: Allow declaring cfg groups in rust-project.json, to help sharing common cfgs #17857

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

ChayimFriedman2
Copy link
Contributor

Closes #17815.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 11, 2024
@Veykril
Copy link
Member

Veykril commented Aug 12, 2024

CI fails due to rustfmt screams (I wonder if it makes sense to split that one out as a separate CI check)

r? @davidbarsky

@bors delegate=@davidbarsky

@bors
Copy link
Contributor

bors commented Aug 12, 2024

✌️ @davidbarsky, you can now approve this pull request!

If @Veykril told you to "r=me" after making some further change, please make that change, then do @bors r=@Veykril

Copy link
Contributor

@davidbarsky davidbarsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not opposed to this change in principle; just had two comments:

Anyways, I think this is a reasonable addition; I just want to make sure that some details of my understanding are not out date.

crates/project-model/src/project_json.rs Outdated Show resolved Hide resolved
Comment on lines +135 to +137
tracing::error!(
"Unknown cfg group `{cfg_extend}` in crate `{}`",
crate_data.display_name.as_deref().unwrap_or("<unknown>"),
);
[].iter().cloned()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a large meta point, but I think it's be a good idea to us to consider using https://github.com/rust-lang/annotate-snippets-rs for rust-analyzer-specific errors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems tailored to CLI output, doesn't sound too useful for us

crates/project-model/src/project_json.rs Outdated Show resolved Hide resolved
@ojeda
Copy link

ojeda commented Aug 12, 2024

I don't know if the memory usage for rust-analyzer would be better (as mentioned as a motivating example in Specifying a set of cfgs for given crates (cfg groups) #17815 by @ojeda), but I can absolutely imagine that the file size would be better. However, if Rust for Linux would prefer to use the automatic indexing approach I described in Support .rust-project.json (i.e. hidden) #17816 (comment), maybe that matters less?

Yeah, if we end up using the discoverConfig support (and we replace completely rust-project.json -- see also a few notes at #17816 (comment)), then we would not need this anymore.

I guess other projects could benefit from it, but it is true that the kernel is a bit of an outlier in terms of cfgs used.

@davidbarsky
Copy link
Contributor

Gotcha, yeah. We can probably land this this largely as-is and revisit in a year if its carrying its weight.

@ChayimFriedman2
Copy link
Contributor Author

I can make the crates share the cfg in memory too (i.e. not expand them when constructing the crate graph). It is not even hard, but it means when checking cfgs we will have to check for parent groups too, which may have an impact on rust-analyzer performance. I don't really know how to benchmark this, and if it indeed regresses perf, it raises the question of whether it is worth regressing perf for everyone to please the few that have a large amount of shared cfgs.

@Veykril
Copy link
Member

Veykril commented Aug 13, 2024

I wouldn't worry about the memory usage impact for this I think, the main compelling argument to me was the file size reduction. But indeed, if the discovery mechanism solves this problem then I'd rather get rid of this (as in im fine with us landing this temporarily but removing it once its not longer needed by the linux project

@Veykril
Copy link
Member

Veykril commented Aug 23, 2024

Will merge this for now, if the linux project doesn't need this anymore in the future (due to project discovery etc) let us know then we'll likely remove it again
@bors r+

@bors
Copy link
Contributor

bors commented Aug 23, 2024

📌 Commit 2607c09 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 23, 2024

⌛ Testing commit 2607c09 with merge ae420e3...

@bors
Copy link
Contributor

bors commented Aug 23, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing ae420e3 to master...

@bors bors merged commit ae420e3 into rust-lang:master Aug 23, 2024
11 checks passed
@ojeda
Copy link

ojeda commented Aug 23, 2024

Will merge this for now, if the linux project doesn't need this anymore in the future (due to project discovery etc) let us know then we'll likely remove it again @bors r+

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specifying a set of cfgs for given crates (cfg groups)
6 participants