mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
feat: Implement lifetime elision hints
This commit is contained in:
parent
890f98f21f
commit
673e2b1d8f
5 changed files with 242 additions and 17 deletions
|
@ -306,15 +306,15 @@ fn extract_line_annotations(mut line: &str) -> Vec<LineAnnotation> {
|
|||
let end_marker = line_no_caret.find(|c| c == '$');
|
||||
let next = line_no_caret.find(marker).map_or(line.len(), |it| it + len);
|
||||
|
||||
let mut content = match end_marker {
|
||||
Some(end_marker)
|
||||
if end_marker < next
|
||||
&& line_no_caret[end_marker..]
|
||||
let cond = |end_marker| {
|
||||
end_marker < next
|
||||
&& (line_no_caret[end_marker + 1..].is_empty()
|
||||
|| line_no_caret[end_marker + 1..]
|
||||
.strip_prefix(|c: char| c.is_whitespace() || c == '^')
|
||||
.is_some() =>
|
||||
{
|
||||
&line_no_caret[..end_marker]
|
||||
}
|
||||
.is_some())
|
||||
};
|
||||
let mut content = match end_marker {
|
||||
Some(end_marker) if cond(end_marker) => &line_no_caret[..end_marker],
|
||||
_ => line_no_caret[..next - len].trim_end(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue