Closed
Description
When I auto-complete a function parameter that wants a reference, I get a &
character randomly inserted on the wrong line in the same file.
It appears to use the line-number relative to the file rather than relative to the current function.
See below for code and steps to reproduce the issue.
rust-analyzer version: (eg. output of "Rust Analyzer: Show RA Version" command)
rust-analyzer version: 0.0.0 (75b2232 2022-07-03)
rustc version: (eg. output of rustc -V
)
rustc 1.62.0 (a8314ef7d 2022-06-27)
#[derive(Debug)]
pub struct QueryResultRequest {
query_id: String,
}
pub async fn query_result(request: QueryResultRequest) -> Result<String, String> {
Ok(request.query_id)
}
pub fn show_value(value: &str) {
println!("value: {value}");
}
fn main() {
println!("Hello, world!");
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test() {
let request = QueryResultRequest {
query_id: "test".to_string(),
};
query_result(request).await.unwrap();
}
}
Steps to reproduce:
- Locate the line of code at the bottom (
query_result(...)
) - Above that line, type the following, but auto-complete the variable name
show_value(request.que
(then press ENTER to auto-completequery_id
)
Upon auto-completion, observe an &
character has been inserted on line 6 of the file, making the function signature now look like this:
pub async fn query_result(request: QueryResultRe&quest) -> Result<String, String> {
^