rust-lang / rust-lang/rust-analyzer
Inlay hints don't update when (default) features change
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I noticed this issue when trying to implement a way for users to pick between tokio and async-std. Since the two don't function quite the same, I've had to write a small compatibility layer. Anyway, I have this bit of code:
#[cfg(feature = "async-std")]
#[inline]
pub fn lines_to_stream<R>(lines: futures::io::Lines<R>) -> futures::io::Lines<R> {
lines
}
#[cfg(feature = "tokio")]
#[inline]
pub fn lines_to_stream<R>(
lines: tokio::io::Lines<R>,
) -> tokio_stream::wrappers::LinesStream<R> {
tokio_stream::wrappers::LinesStream::new(lines)
}
To test that both versions work side by side, I have this in my Cargo.toml:
[features]
#default = ["async-std"]
default = ["tokio-runtime"]
tokio-runtime = ["tokio", "tokio-stream"]
and I switch between the two defaults when I want to test one or the other. What I've noticed is that when I make the switch, most things behave as expected (the items with the now inactive #[cfg()]s are dimmed and vice versa for the ones that are now active, e.g.), but the inlay hints don't update to reflect the changes. A call to that lines_to_stream above, e.g. will keep showing LinesStream<...> even after switching from tokio-runtime to async-std, even though it should say Lines<...> at that point.
They are updated as soon as any edits are made to the file in which the inlay hint appears, but just like how the dimming of the inactive #[cfg()]s happen without active user involvement, it'd be nice if the inlay hint was updated, too.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue by switching the default feature in Cargo.toml between async-std and tokio-runtime and observing the inlay hint at the lines_to_stream call. Done means the hint refreshes when the feature selection changes, without editing the file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100