Skip to content

Conversation

YuraLitvinov
Copy link

Derived from this issue #20676

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 17, 2025
Comment on lines 144 to 152
/// - `None` may occur if the
/// [`FileId`](https://docs.rs/ra_ap_vfs/latest/ra_ap_vfs/struct.FileId.html)
/// has been loaded into the VFS but was not registered with the
/// [`ra_ap_base_db::RootDatabase`](https://docs.rs/ra_ap_ide_db/latest/ra_ap_ide_db/struct.RootDatabase.html).
/// - See [rust-analyzer#20676](https://github.com/rust-lang/rust-analyzer/issues/20676)
/// for details and reproduction steps.
///
/// To ensure proper registration, use
/// [`ra_ap_load_cargo::load_workspace()`](https://docs.rs/ra_ap_load-cargo/latest/ra_ap_load_cargo/fn.load_workspace.html).
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not the right place to document this as nobody will see this except maybe r-a developers that don't need to.

If there is anything to change, it's the panic message, but as I said on that issue, I'm not sure we'd want even that: it's pretty expected that if you use the r-a API in incorrect ways you will get incorrect results.

Copy link
Author

Choose a reason for hiding this comment

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

I am not a developer or a maintainer, but I still saw it somehow. In my opinion, it would be better for it to be there. Because I had to invest more time in ra_ap than I have anticipitated due to this error.

Copy link
Author

Choose a reason for hiding this comment

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

Also, it would make sense for it be bug in production, but if there is another way to cause this behavior then I am not sure if this can already be considered UB.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree we should have better documentation on using r-a APIs, but I don't think this is the place to do that. Perhaps in one of hir, ide-db, ide or load-cargo.

(And this cannot trigger UB by any way).

Copy link
Author

Choose a reason for hiding this comment

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

I agree, then I will come up with a proposal soon.

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

Successfully merging this pull request may close these issues.

3 participants