Skip to content

Commit

Permalink
Filter empty lines, comments and delimiters from previous to last mul…
Browse files Browse the repository at this point in the history
…tiline span rendering
  • Loading branch information
estebank committed Dec 12, 2024
1 parent 65a54a7 commit 49a22a4
Show file tree
Hide file tree
Showing 103 changed files with 115 additions and 401 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3064,7 +3064,11 @@ impl FileWithAnnotatedLines {
add_annotation_to_file(&mut output, Lrc::clone(&file), line, ann.as_line());
}
let line_end = ann.line_end - 1;
if middle < line_end {
let end_is_empty = file.get_line(line_end - 1).map_or(false, |s| {
let s = s.trim();
["", "{", "}", "(", ")", "[", "]"].contains(&s) || s.starts_with("//")
});
if middle < line_end && !end_is_empty {
add_annotation_to_file(&mut output, Lrc::clone(&file), line_end, ann.as_line());
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ LL | | fn clone_self(&self) -> Self {
LL | | Self {
LL | | a: true,
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -32,7 +31,6 @@ LL | | fn default() -> Self {
LL | | Self {
LL | | a: true,
... |
LL | | }
LL | | }
| |_^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ LL | | if unsafe { true } {
LL | | todo!();
LL | | } else {
... |
LL | | }
LL | | };
| |______^
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ LL | | if unsafe { true } {
LL | | todo!();
LL | | } else {
... |
LL | | }
LL | | };
| |______^
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ LL | | if {
LL | | if s == "43" {
LL | | return Some(43);
... |
LL | | }
LL | | });
| |______^
|
Expand Down
5 changes: 0 additions & 5 deletions src/tools/clippy/tests/ui/collapsible_else_if.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ LL | } else {
LL | | if y == "world" {
LL | | println!("world")
... |
LL | | }
LL | | }
| |_____^
|
Expand All @@ -66,7 +65,6 @@ LL | } else {
LL | | if let Some(42) = Some(42) {
LL | | println!("world")
... |
LL | | }
LL | | }
| |_____^
|
Expand All @@ -88,7 +86,6 @@ LL | } else {
LL | | if let Some(42) = Some(42) {
LL | | println!("world")
... |
LL | | }
LL | | }
| |_____^
|
Expand All @@ -110,7 +107,6 @@ LL | } else {
LL | | if x == "hello" {
LL | | println!("world")
... |
LL | | }
LL | | }
| |_____^
|
Expand All @@ -132,7 +128,6 @@ LL | } else {
LL | | if let Some(42) = Some(42) {
LL | | println!("world")
... |
LL | | }
LL | | }
| |_____^
|
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/tests/ui/copy_iterator.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LL | |
LL | |
LL | | type Item = u8;
... |
LL | | }
LL | | }
| |_^
|
Expand Down
2 changes: 0 additions & 2 deletions src/tools/clippy/tests/ui/crashes/ice-360.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ error: this loop never actually loops
|
LL | / loop {
... |
LL | |
LL | | }
| |_____^
|
Expand All @@ -14,7 +13,6 @@ error: this loop could be written as a `while let` loop
|
LL | / loop {
... |
LL | |
LL | | }
| |_____^ help: try: `while let Some(ele) = iter.next() { .. }`
|
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/tests/ui/derivable_impls.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LL | | fn default() -> Self {
LL | | Self {
LL | | a: false,
... |
LL | | }
LL | | }
| |_^
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ error: empty lines after doc comment
|
LL | / /// for OldA
... |
LL | | // struct OldB;
LL | |
| |_^
...
Expand Down
5 changes: 1 addition & 4 deletions src/tools/clippy/tests/ui/entry.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ LL | / if !m.contains_key(&k) {
LL | | if true {
LL | | m.insert(k, v);
LL | | } else {
LL | | m.insert(k, v2);
LL | | }
... |
LL | | }
| |_____^
|
Expand Down Expand Up @@ -63,7 +62,6 @@ LL | | if true {
LL | | m.insert(k, v);
LL | | } else {
... |
LL | | }
LL | | }
| |_____^
|
Expand Down Expand Up @@ -154,7 +152,6 @@ LL | | foo();
LL | | match 0 {
LL | | 0 if false => {
... |
LL | | }
LL | | }
| |_____^
|
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/tests/ui/enum_variants.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ LL | / enum Food {
LL | |
LL | | FoodGood,
... |
LL | |
LL | | }
| |_^
|
Expand Down
3 changes: 0 additions & 3 deletions src/tools/clippy/tests/ui/fallible_impl_from.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ LL | |
LL | | fn from(i: usize) -> Invalid {
LL | | if i != 42 {
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -49,7 +48,6 @@ LL | |
LL | | fn from(s: Option<String>) -> Invalid {
LL | | let s = s.unwrap();
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -76,7 +74,6 @@ LL | |
LL | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
LL | | if s.parse::<u32>().ok().unwrap() != 42 {
... |
LL | | }
LL | | }
| |_^
|
Expand Down
2 changes: 0 additions & 2 deletions src/tools/clippy/tests/ui/if_same_then_else2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LL | | for _ in &[42] {
LL | | let foo: &Option<_> = &Some::<u8>(42);
LL | | if foo.is_some() {
... |
LL | | }
LL | | } else {
| |_____^
|
Expand All @@ -20,7 +19,6 @@ LL | | for _ in &[42] {
LL | | let bar: &Option<_> = &Some::<u8>(42);
LL | | if bar.is_some() {
... |
LL | | }
LL | | }
| |_____^
= note: `-D clippy::if-same-then-else` implied by `-D warnings`
Expand Down
6 changes: 0 additions & 6 deletions src/tools/clippy/tests/ui/infinite_loops.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ LL | / loop {
LL | |
LL | | loop {
... |
LL | | }
LL | | }
| |_________^
|
Expand Down Expand Up @@ -94,7 +93,6 @@ LL | |
LL | | loop {
LL | | if cond {
... |
LL | | }
LL | | }
| |_____^
|
Expand All @@ -111,7 +109,6 @@ LL | |
LL | | 'inner: loop {
LL | | loop {
... |
LL | | }
LL | | }
| |_____^
|
Expand Down Expand Up @@ -142,7 +139,6 @@ LL | |
LL | | 'inner: loop {
LL | | loop {
... |
LL | | }
LL | | }
| |_________^
|
Expand All @@ -159,7 +155,6 @@ LL | |
LL | | match opt {
LL | | Some(v) => {
... |
LL | | }
LL | | }
| |_____^
|
Expand Down Expand Up @@ -276,7 +271,6 @@ LL | |
LL | | 'inner: loop {
LL | | loop {
... |
LL | | }
LL | | }
| |_____^
|
Expand Down
8 changes: 1 addition & 7 deletions src/tools/clippy/tests/ui/into_iter_without_iter.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LL | |
LL | | type IntoIter = std::slice::Iter<'a, u8>;
LL | | type Item = &'a u8;
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -30,7 +29,6 @@ LL | |
LL | | type IntoIter = std::slice::IterMut<'a, u8>;
LL | | type Item = &'a mut u8;
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -52,7 +50,6 @@ LL | |
LL | | type IntoIter = std::slice::Iter<'a, T>;
LL | | type Item = &'a T;
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -74,7 +71,6 @@ LL | |
LL | | type IntoIter = std::slice::IterMut<'a, T>;
LL | | type Item = &'a mut T;
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -96,7 +92,6 @@ LL | |
LL | | type IntoIter = std::slice::IterMut<'a, T>;
LL | | type Item = &'a mut T;
... |
LL | | }
LL | | }
| |_^
|
Expand All @@ -117,8 +112,7 @@ LL | / impl<'a> IntoIterator for &'a Issue12037 {
LL | | type IntoIter = std::slice::Iter<'a, u8>;
LL | | type Item = &'a u8;
LL | | fn into_iter(self) -> Self::IntoIter {
LL | | todo!()
LL | | }
... |
LL | | }
| |_________^
...
Expand Down
2 changes: 0 additions & 2 deletions src/tools/clippy/tests/ui/manual_find.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LL | |
LL | |
LL | | if s == String::new() {
... |
LL | | }
LL | | None
| |________^ help: replace with an iterator: `strings.into_iter().find(|s| s == String::new())`
|
Expand All @@ -22,7 +21,6 @@ LL | |
LL | |
LL | | if s == String::new() {
... |
LL | | }
LL | | None
| |________^ help: replace with an iterator: `arr.into_iter().map(|(s, _)| s).find(|s| s == String::new())`
|
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/tests/ui/manual_flatten.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ LL | |
LL | | Some(1),
LL | | Some(2),
... |
LL | | }
LL | | }
| |_____^
|
Expand Down
4 changes: 0 additions & 4 deletions src/tools/clippy/tests/ui/manual_let_else.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ LL | |
LL | | v_some
LL | | } else {
... |
LL | | }
LL | | };
| |______^
|
Expand All @@ -175,7 +174,6 @@ LL | |
LL | | v_some
LL | | } else {
... |
LL | | }
LL | | };
| |______^
|
Expand All @@ -197,7 +195,6 @@ LL | |
LL | | v_some
LL | | } else {
... |
LL | | }
LL | | };
| |______^
|
Expand Down Expand Up @@ -306,7 +303,6 @@ LL | |
LL | | v_some
LL | | } else {
... |
LL | | }
LL | | };
| |______^
|
Expand Down
2 changes: 0 additions & 2 deletions src/tools/clippy/tests/ui/manual_unwrap_or.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ LL | | Some(i) => i,
LL | | None => {
LL | | 42 + 42
... |
LL | | }
LL | | };
| |_____^
|
Expand Down Expand Up @@ -130,7 +129,6 @@ LL | | Ok(i) => i,
LL | | Err(_) => {
LL | | 42 + 42
... |
LL | | }
LL | | };
| |_____^
|
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/tests/ui/missing_doc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ LL | | /// dox
LL | | pub fn documented() {}
LL | | pub fn undocumented1() {}
... |
LL | | }
LL | | }
| |_^

Expand Down
Loading

0 comments on commit 49a22a4

Please sign in to comment.