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

minor: Read workspace root ratomls on startup #17661

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

alibektas
Copy link
Member

No description provided.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 22, 2024
@alibektas alibektas changed the title minor: Read rust-analyzer.toml files on startup minor: Read workspace root ratomls on startup Jul 22, 2024
Comment on lines 255 to 260
if !matches!(ws.kind, ProjectWorkspaceKind::DetachedFile { .. }) {
let ws_root = ws.workspace_root();
file_set_roots.push(VfsPath::from(ws_root.to_owned()));
entries.push(ws_root.to_owned());
register = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

We should specifically push the rust-analyzer.toml file path here, not the workspace root itself. We only want to watch that one file there

Copy link
Member Author

@alibektas alibektas Jul 23, 2024

Choose a reason for hiding this comment

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

sorry ofc I meant to write that. 😞

res.load.push(entry);
local_filesets.push(fsc.len() as u64);
fsc.add_file_set(file_set_roots)
if register {
Copy link
Member

Choose a reason for hiding this comment

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

register can be replaced by checking whether entries and/or file_set_roots is empty or not

@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2024
@alibektas alibektas added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 23, 2024
@Veykril
Copy link
Member

Veykril commented Jul 24, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Jul 24, 2024

📌 Commit af88940 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 24, 2024

⌛ Testing commit af88940 with merge fbfda1b...

@bors
Copy link
Contributor

bors commented Jul 24, 2024

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

@bors bors merged commit fbfda1b into rust-lang:master Jul 24, 2024
11 checks passed
@cormacrelf
Copy link
Contributor

Given #17246, it's still not being read early enough -- there is a pretty big chicken/egg problem with configs like this:

[workspace.discoverConfig]
...

We don't read rust-analyzer.toml until workspaces have already been discovered (to find the root), and we can't discover a workspace because haven't read it. I think we need to search upwards from the current working directory to find a rust-analyzer.toml to use on startup.

For rust-analyzer.toml users, these configs will never be populated in src/bin/main.rs:

if config.discover_workspace_config().is_none()
&& !config.has_linked_projects()
&& config.detached_files().is_empty()
{
config.rediscover_workspaces();
}

@Veykril
Copy link
Member

Veykril commented Jul 26, 2024

Well, we should actually not allow workspace.discoverConfig in workspace associated rust-analyzer.toml files given the chicken and egg problem. Having it in there is non-sensical.

We are in general planning a slight restructuring of config grouping as the current structure has some problems.

@cormacrelf
Copy link
Contributor

Configuring a repo to discover non-cargo workspaces for anyone who opens it is one of the main difficulties I was hoping rust- analyzer.toml would solve, so I really hope we can break the chicken/egg somehow.

@Veykril
Copy link
Member

Veykril commented Jul 26, 2024

We definitely want to have some solution there, but the current implementation isn't sufficient for that (its really just an MVP atm).

@alibektas
Copy link
Member Author

That's a valid point to which I have no answer atm. But I am making a separate issue from this and I will find a way to address this

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.

5 participants