Rollup merge of #108627 - estebank:suggestion-hightlight, r=WaffleLapkin
Properly colorize multi-part suggestions in the same line Fix #108547.
This commit is contained in:
commit
60f54b1025
@ -1895,7 +1895,7 @@ fn emit_suggestion_default(
|
|||||||
self.draw_code_line(
|
self.draw_code_line(
|
||||||
&mut buffer,
|
&mut buffer,
|
||||||
&mut row_num,
|
&mut row_num,
|
||||||
&Vec::new(),
|
&[],
|
||||||
p + line_start,
|
p + line_start,
|
||||||
l,
|
l,
|
||||||
show_code_change,
|
show_code_change,
|
||||||
@ -1919,7 +1919,7 @@ fn emit_suggestion_default(
|
|||||||
self.draw_code_line(
|
self.draw_code_line(
|
||||||
&mut buffer,
|
&mut buffer,
|
||||||
&mut row_num,
|
&mut row_num,
|
||||||
&Vec::new(),
|
&[],
|
||||||
p + line_start,
|
p + line_start,
|
||||||
l,
|
l,
|
||||||
show_code_change,
|
show_code_change,
|
||||||
@ -1936,7 +1936,7 @@ fn emit_suggestion_default(
|
|||||||
self.draw_code_line(
|
self.draw_code_line(
|
||||||
&mut buffer,
|
&mut buffer,
|
||||||
&mut row_num,
|
&mut row_num,
|
||||||
&Vec::new(),
|
&[],
|
||||||
p + line_start,
|
p + line_start,
|
||||||
l,
|
l,
|
||||||
show_code_change,
|
show_code_change,
|
||||||
@ -1951,7 +1951,7 @@ fn emit_suggestion_default(
|
|||||||
self.draw_code_line(
|
self.draw_code_line(
|
||||||
&mut buffer,
|
&mut buffer,
|
||||||
&mut row_num,
|
&mut row_num,
|
||||||
highlight_parts,
|
&highlight_parts,
|
||||||
line_pos + line_start,
|
line_pos + line_start,
|
||||||
line,
|
line,
|
||||||
show_code_change,
|
show_code_change,
|
||||||
@ -2176,7 +2176,7 @@ fn draw_code_line(
|
|||||||
&self,
|
&self,
|
||||||
buffer: &mut StyledBuffer,
|
buffer: &mut StyledBuffer,
|
||||||
row_num: &mut usize,
|
row_num: &mut usize,
|
||||||
highlight_parts: &Vec<SubstitutionHighlight>,
|
highlight_parts: &[SubstitutionHighlight],
|
||||||
line_num: usize,
|
line_num: usize,
|
||||||
line_to_add: &str,
|
line_to_add: &str,
|
||||||
show_code_change: DisplaySuggestion,
|
show_code_change: DisplaySuggestion,
|
||||||
|
@ -331,7 +331,7 @@ fn push_trailing(
|
|||||||
});
|
});
|
||||||
buf.push_str(&part.snippet);
|
buf.push_str(&part.snippet);
|
||||||
let cur_hi = sm.lookup_char_pos(part.span.hi());
|
let cur_hi = sm.lookup_char_pos(part.span.hi());
|
||||||
if prev_hi.line == cur_lo.line && cur_hi.line == cur_lo.line {
|
if cur_hi.line == cur_lo.line {
|
||||||
// Account for the difference between the width of the current code and the
|
// Account for the difference between the width of the current code and the
|
||||||
// snippet being suggested, so that the *later* suggestions are correctly
|
// snippet being suggested, so that the *later* suggestions are correctly
|
||||||
// aligned on the screen.
|
// aligned on the screen.
|
||||||
|
19
tests/ui/suggestions/multiline-multipart-suggestion.rs
Normal file
19
tests/ui/suggestions/multiline-multipart-suggestion.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// compile-flags: --error-format=human --color=always
|
||||||
|
// ignore-windows
|
||||||
|
|
||||||
|
fn short(foo_bar: &Vec<&i32>) -> &i32 { //~ ERROR missing lifetime specifier
|
||||||
|
&12
|
||||||
|
}
|
||||||
|
|
||||||
|
fn long( //~ ERROR missing lifetime specifier
|
||||||
|
foo_bar: &Vec<&i32>,
|
||||||
|
something_very_long_so_that_the_line_will_wrap_around__________: i32,
|
||||||
|
) -> &i32 {
|
||||||
|
&12
|
||||||
|
}
|
||||||
|
|
||||||
|
fn long2( //~ ERROR missing lifetime specifier
|
||||||
|
foo_bar: &Vec<&i32>) -> &i32 {
|
||||||
|
&12
|
||||||
|
}
|
||||||
|
fn main() {}
|
46
tests/ui/suggestions/multiline-multipart-suggestion.stderr
Normal file
46
tests/ui/suggestions/multiline-multipart-suggestion.stderr
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
[0m[1m[38;5;9merror[E0106][0m[0m[1m: missing lifetime specifier[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m--> [0m[0m$DIR/multiline-multipart-suggestion.rs:4:34[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0mfn short(foo_bar: &Vec<&i32>) -> &i32 {
|
||||||
|
[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;12m----------[0m[0m [0m[0m[1m[38;5;9m^[0m[0m [0m[0m[1m[38;5;9mexpected named lifetime parameter[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m= [0m[0m[1mhelp[0m[0m: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from[0m
|
||||||
|
[0m[1m[38;5;14mhelp[0m[0m: consider introducing a named lifetime parameter[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m| [0m[0mfn short[0m[0m[38;5;10m<'a>[0m[0m(foo_bar: &[0m[0m[38;5;10m'a [0m[0mVec<&[0m[0m[38;5;10m'a [0m[0mi32>) -> &[0m[0m[38;5;10m'a [0m[0mi32 {
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m[38;5;10m++++[0m[0m [0m[0m[38;5;10m++[0m[0m [0m[0m[38;5;10m++[0m[0m [0m[0m[38;5;10m++[0m
|
||||||
|
|
||||||
|
[0m[1m[38;5;9merror[E0106][0m[0m[1m: missing lifetime specifier[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m--> [0m[0m$DIR/multiline-multipart-suggestion.rs:11:6[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m foo_bar: &Vec<&i32>,[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;12m----------[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m something_very_long_so_that_the_line_will_wrap_around__________: i32,[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m) -> &i32 {[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;9m^[0m[0m [0m[0m[1m[38;5;9mexpected named lifetime parameter[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m= [0m[0m[1mhelp[0m[0m: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from[0m
|
||||||
|
[0m[1m[38;5;14mhelp[0m[0m: consider introducing a named lifetime parameter[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0mfn long[0m[0m[38;5;10m<'a>[0m[0m(
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0m foo_bar: &[0m[0m[38;5;10m'a [0m[0mVec<&[0m[0m[38;5;10m'a [0m[0mi32>,[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m| [0m[0m something_very_long_so_that_the_line_will_wrap_around__________: i32,[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0m) -> &[0m[0m[38;5;10m'a [0m[0mi32 {[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
|
||||||
|
[0m[1m[38;5;9merror[E0106][0m[0m[1m: missing lifetime specifier[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m--> [0m[0m$DIR/multiline-multipart-suggestion.rs:16:29[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m foo_bar: &Vec<&i32>) -> &i32 {[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;12m----------[0m[0m [0m[0m[1m[38;5;9m^[0m[0m [0m[0m[1m[38;5;9mexpected named lifetime parameter[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m= [0m[0m[1mhelp[0m[0m: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from[0m
|
||||||
|
[0m[1m[38;5;14mhelp[0m[0m: consider introducing a named lifetime parameter[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0mfn long2[0m[0m[38;5;10m<'a>[0m[0m(
|
||||||
|
[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0m foo_bar: &[0m[0m[38;5;10m'a [0m[0mVec<&[0m[0m[38;5;10m'a [0m[0mi32>) -> &[0m[0m[38;5;10m'a [0m[0mi32 {[0m
|
||||||
|
[0m [0m[0m[1m[38;5;12m|[0m
|
||||||
|
|
||||||
|
[0m[1m[38;5;9merror[0m[0m[1m: aborting due to 3 previous errors[0m
|
||||||
|
|
||||||
|
[0m[1mFor more information about this error, try `rustc --explain E0106`.[0m
|
Loading…
Reference in New Issue
Block a user