forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#134664 - estebank:sugg-highlighting, r=jieyouxu Account for removal of multiline span in suggestion When highlighting the removed parts of a suggestion, properly account for spans that cover more than one line. Fix rust-lang#134485. ![Screenshot of the highlighted output](https://github.com/user-attachments/assets/18bcd9bc-3bec-4b79-a9d7-e4ea4e6289ad)
- Loading branch information
Showing
3 changed files
with
641 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Make sure suggestion for removal of a span that covers multiple lines is properly highlighted. | ||
//@ compile-flags: --error-format=human --color=always | ||
//@ edition:2018 | ||
//@ only-linux | ||
// ignore-tidy-tab | ||
// We use `\t` instead of spaces for indentation to ensure that the highlighting logic properly | ||
// accounts for replaced characters (like we do for `\t` with ` `). The naïve way of highlighting | ||
// could be counting chars of the original code, instead of operating on the code as it is being | ||
// displayed. | ||
use std::collections::{HashMap, HashSet}; | ||
fn foo() -> Vec<(bool, HashSet<u8>)> { | ||
let mut hm = HashMap::<bool, Vec<HashSet<u8>>>::new(); | ||
hm.into_iter() | ||
.map(|(is_true, ts)| { | ||
ts.into_iter() | ||
.map(|t| { | ||
( | ||
is_true, | ||
t, | ||
) | ||
}).flatten() | ||
}) | ||
.flatten() | ||
.collect() | ||
} | ||
fn bar() -> Vec<(bool, HashSet<u8>)> { | ||
let mut hm = HashMap::<bool, Vec<HashSet<u8>>>::new(); | ||
hm.into_iter() | ||
.map(|(is_true, ts)| { | ||
ts.into_iter() | ||
.map(|t| (is_true, t)) | ||
.flatten() | ||
}) | ||
.flatten() | ||
.collect() | ||
} | ||
fn baz() -> Vec<(bool, HashSet<u8>)> { | ||
let mut hm = HashMap::<bool, Vec<HashSet<u8>>>::new(); | ||
hm.into_iter() | ||
.map(|(is_true, ts)| { | ||
ts.into_iter().map(|t| { | ||
(is_true, t) | ||
}).flatten() | ||
}) | ||
.flatten() | ||
.collect() | ||
} | ||
fn bay() -> Vec<(bool, HashSet<u8>)> { | ||
let mut hm = HashMap::<bool, Vec<HashSet<u8>>>::new(); | ||
hm.into_iter() | ||
.map(|(is_true, ts)| { | ||
ts.into_iter() | ||
.map(|t| (is_true, t)).flatten() | ||
}) | ||
.flatten() | ||
.collect() | ||
} | ||
fn main() {} |
Oops, something went wrong.