Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/aargvark_tests/examples/ultrathon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]

use {
aargvark::Aargvark,
std::path::PathBuf,
Expand Down
1 change: 1 addition & 0 deletions crates/genemichaels-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
clippy::too_many_arguments,
clippy::field_reassign_with_default,
clippy::never_loop,
clippy::derive_hash_xor_eq

Check warning on line 5 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq`

warning: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` --> crates/genemichaels-lib/src/lib.rs:5:5 | 5 | clippy::derive_hash_xor_eq | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` | = note: `#[warn(renamed_and_removed_lints)]` on by default

Check warning on line 5 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq`

warning: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` --> crates/genemichaels-lib/src/lib.rs:5:5 | 5 | clippy::derive_hash_xor_eq | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` | = note: `#[warn(renamed_and_removed_lints)]` on by default

Check warning on line 5 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq`

warning: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` --> crates/genemichaels-lib/src/lib.rs:5:5 | 5 | clippy::derive_hash_xor_eq | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` | = note: `#[warn(renamed_and_removed_lints)]` on by default
)]

use {
Expand Down Expand Up @@ -54,6 +54,7 @@
pub struct Comment {
pub mode: CommentMode,
pub lines: String,
pub orig_start_offset: usize,
}

#[derive(Debug)]
Expand Down Expand Up @@ -183,7 +184,7 @@
}
new_segs.extend(line.segs.split_off(off));
{
let seg_i = new_segs.get(0).unwrap();

Check warning on line 187 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `new_segs.get(0)`

warning: accessing first element with `new_segs.get(0)` --> crates/genemichaels-lib/src/lib.rs:187:21 | 187 | let seg_i = new_segs.get(0).unwrap(); | ^^^^^^^^^^^^^^^ help: try: `new_segs.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 187 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `new_segs.get(0)`

warning: accessing first element with `new_segs.get(0)` --> crates/genemichaels-lib/src/lib.rs:187:21 | 187 | let seg_i = new_segs.get(0).unwrap(); | ^^^^^^^^^^^^^^^ help: try: `new_segs.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 187 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `new_segs.get(0)`

warning: accessing first element with `new_segs.get(0)` --> crates/genemichaels-lib/src/lib.rs:187:21 | 187 | let seg_i = new_segs.get(0).unwrap(); | ^^^^^^^^^^^^^^^ help: try: `new_segs.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
let seg = out.segs.get(seg_i.0).unwrap();
match &seg.content {
SegmentContent::Break(a, activate) => {
Expand Down Expand Up @@ -473,8 +474,8 @@

fn render_indent(config: &FormatConfig, current_indent: IndentLevel) -> String {
match config.indent_unit {
IndentUnit::Spaces => return " ".repeat(config.indent_spaces * current_indent.0),

Check warning on line 477 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:477:31 | 477 | IndentUnit::Spaces => return " ".repeat(config.indent_spaces * current_indent.0), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 477 - IndentUnit::Spaces => return " ".repeat(config.indent_spaces * current_indent.0), 477 + IndentUnit::Spaces => " ".repeat(config.indent_spaces * current_indent.0), |

Check warning on line 477 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:477:31 | 477 | IndentUnit::Spaces => return " ".repeat(config.indent_spaces * current_indent.0), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 477 - IndentUnit::Spaces => return " ".repeat(config.indent_spaces * current_indent.0), 477 + IndentUnit::Spaces => " ".repeat(config.indent_spaces * current_indent.0), |

Check warning on line 477 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:477:31 | 477 | IndentUnit::Spaces => return " ".repeat(config.indent_spaces * current_indent.0), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 477 - IndentUnit::Spaces => return " ".repeat(config.indent_spaces * current_indent.0), 477 + IndentUnit::Spaces => " ".repeat(config.indent_spaces * current_indent.0), |
IndentUnit::Tabs => return "\t".repeat(current_indent.0),

Check warning on line 478 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:478:29 | 478 | IndentUnit::Tabs => return "\t".repeat(current_indent.0), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 478 - IndentUnit::Tabs => return "\t".repeat(current_indent.0), 478 + IndentUnit::Tabs => "\t".repeat(current_indent.0), |

Check warning on line 478 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:478:29 | 478 | IndentUnit::Tabs => return "\t".repeat(current_indent.0), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 478 - IndentUnit::Tabs => return "\t".repeat(current_indent.0), 478 + IndentUnit::Tabs => "\t".repeat(current_indent.0), |

Check warning on line 478 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:478:29 | 478 | IndentUnit::Tabs => return "\t".repeat(current_indent.0), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 478 - IndentUnit::Tabs => return "\t".repeat(current_indent.0), 478 + IndentUnit::Tabs => "\t".repeat(current_indent.0), |
}
}

Expand Down Expand Up @@ -554,13 +555,13 @@
whitespaces,
)?;
if let Some(shebang) = shebang {
return Ok(FormatRes {
rendered: format!("{}{}", shebang, out.rendered),
lost_comments: out.lost_comments,
warnings: out.warnings,
});

Check warning on line 562 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:558:9 | 558 | / return Ok(FormatRes { 559 | | rendered: format!("{}{}", shebang, out.rendered), 560 | | lost_comments: out.lost_comments, 561 | | warnings: out.warnings, 562 | | }); | |__________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 558 ~ Ok(FormatRes { 559 + rendered: format!("{}{}", shebang, out.rendered), 560 + lost_comments: out.lost_comments, 561 + warnings: out.warnings, 562 ~ }) |

Check warning on line 562 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:558:9 | 558 | / return Ok(FormatRes { 559 | | rendered: format!("{}{}", shebang, out.rendered), 560 | | lost_comments: out.lost_comments, 561 | | warnings: out.warnings, 562 | | }); | |__________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 558 ~ Ok(FormatRes { 559 + rendered: format!("{}{}", shebang, out.rendered), 560 + lost_comments: out.lost_comments, 561 + warnings: out.warnings, 562 ~ }) |

Check warning on line 562 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:558:9 | 558 | / return Ok(FormatRes { 559 | | rendered: format!("{}{}", shebang, out.rendered), 560 | | lost_comments: out.lost_comments, 561 | | warnings: out.warnings, 562 | | }); | |__________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 558 ~ Ok(FormatRes { 559 + rendered: format!("{}{}", shebang, out.rendered), 560 + lost_comments: out.lost_comments, 561 + warnings: out.warnings, 562 ~ }) |
} else {
return Ok(out);

Check warning on line 564 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:564:9 | 564 | return Ok(out); | ^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 564 - return Ok(out); 564 + Ok(out) |

Check warning on line 564 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:564:9 | 564 | return Ok(out); | ^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 564 - return Ok(out); 564 + Ok(out) |

Check warning on line 564 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/lib.rs:564:9 | 564 | return Ok(out); | ^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 564 - return Ok(out); 564 + Ok(out) |
}
}

Expand All @@ -574,7 +575,7 @@
nodes: vec![],
segs: vec![],
whitespaces,
config: config.clone(),

Check warning on line 578 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

using `clone` on type `FormatConfig` which implements the `Copy` trait

warning: using `clone` on type `FormatConfig` which implements the `Copy` trait --> crates/genemichaels-lib/src/lib.rs:578:17 | 578 | config: config.clone(), | ^^^^^^^^^^^^^^ help: try dereferencing it: `*config` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy = note: `#[warn(clippy::clone_on_copy)]` on by default

Check warning on line 578 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

using `clone` on type `FormatConfig` which implements the `Copy` trait

warning: using `clone` on type `FormatConfig` which implements the `Copy` trait --> crates/genemichaels-lib/src/lib.rs:578:17 | 578 | config: config.clone(), | ^^^^^^^^^^^^^^ help: try dereferencing it: `*config` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy = note: `#[warn(clippy::clone_on_copy)]` on by default

Check warning on line 578 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

using `clone` on type `FormatConfig` which implements the `Copy` trait

warning: using `clone` on type `FormatConfig` which implements the `Copy` trait --> crates/genemichaels-lib/src/lib.rs:578:17 | 578 | config: config.clone(), | ^^^^^^^^^^^^^^ help: try dereferencing it: `*config` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy = note: `#[warn(clippy::clone_on_copy)]` on by default
};
let base_indent = Alignment(Rc::new(RefCell::new(Alignment_ {
parent: None,
Expand Down Expand Up @@ -882,8 +883,8 @@
line_i += 1;
}
Ok(FormatRes {
rendered: rendered,

Check warning on line 886 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/lib.rs:886:9 | 886 | rendered: rendered, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `rendered` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 886 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/lib.rs:886:9 | 886 | rendered: rendered, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `rendered` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 886 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/lib.rs:886:9 | 886 | rendered: rendered, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `rendered` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
lost_comments: out.whitespaces,
warnings: warnings,

Check warning on line 888 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/lib.rs:888:9 | 888 | warnings: warnings, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `warnings` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 888 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/lib.rs:888:9 | 888 | warnings: warnings, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `warnings` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 888 in crates/genemichaels-lib/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/lib.rs:888:9 | 888 | warnings: warnings, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `warnings` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
})
}
14 changes: 12 additions & 2 deletions crates/genemichaels-lib/src/sg_general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
},
std::{
fmt::Write,
ops::Bound,
ops::{
Bound,
RangeBounds,
},
},
syn::{
spanned::Spanned,
Expand Down Expand Up @@ -271,6 +274,8 @@
after_attr_line_col = Bound::Included(HashLineColumn(span_including_attrs.start()));
}
sg.seg(out, &text[after_attr_byte_offset - span_including_attrs.span().byte_range().start..]);

// Remove comments used within subtree from global block
let remove_whitespaces_keys =
out
.whitespaces
Expand All @@ -287,7 +292,11 @@
match ws.mode {
WhitespaceMode::BlankLines(_) => { },
WhitespaceMode::Comment(comment) => {
if text.contains(&comment.lines) {
if match span_including_attrs.byte_range().end_bound() {
Bound::Included(x) => comment.orig_start_offset <= *x,
Bound::Excluded(x) => comment.orig_start_offset < *x,
Bound::Unbounded => unreachable!(),
} {
continue;
}
sg.add(out, crate::Segment {
Expand All @@ -299,6 +308,7 @@
mode: WhitespaceMode::Comment(crate::Comment {
mode: crate::CommentMode::Normal,
lines: comment.lines,
orig_start_offset: 0,
}),
}])),
});
Expand Down Expand Up @@ -505,23 +515,23 @@
{
/// Identify punctuation that connects things tightly
fn is_pull_next_punct(p: &Punct) -> bool {
return match p.as_char() {
'.' => true,
'\'' => true,
'$' => true,
'#' => true,
_ => false,
};

Check warning on line 524 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro --> crates/genemichaels-lib/src/sg_general.rs:518:28 | 518 | return match p.as_char() { | ____________________________^ 519 | | '.' => true, 520 | | '\'' => true, 521 | | '$' => true, 522 | | '#' => true, 523 | | _ => false, 524 | | }; | |_____________________^ help: try: `matches!(p.as_char(), '.' | '\'' | '$' | '#')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro = note: `#[warn(clippy::match_like_matches_macro)]` on by default

Check warning on line 524 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:518:21 | 518 | / return match p.as_char() { 519 | | '.' => true, 520 | | '\'' => true, 521 | | '$' => true, 522 | | '#' => true, 523 | | _ => false, 524 | | }; | |_____________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 518 ~ match p.as_char() { 519 + '.' => true, 520 + '\'' => true, 521 + '$' => true, 522 + '#' => true, 523 + _ => false, 524 ~ } |

Check warning on line 524 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro --> crates/genemichaels-lib/src/sg_general.rs:518:28 | 518 | return match p.as_char() { | ____________________________^ 519 | | '.' => true, 520 | | '\'' => true, 521 | | '$' => true, 522 | | '#' => true, 523 | | _ => false, 524 | | }; | |_____________________^ help: try: `matches!(p.as_char(), '.' | '\'' | '$' | '#')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro = note: `#[warn(clippy::match_like_matches_macro)]` on by default

Check warning on line 524 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:518:21 | 518 | / return match p.as_char() { 519 | | '.' => true, 520 | | '\'' => true, 521 | | '$' => true, 522 | | '#' => true, 523 | | _ => false, 524 | | }; | |_____________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 518 ~ match p.as_char() { 519 + '.' => true, 520 + '\'' => true, 521 + '$' => true, 522 + '#' => true, 523 + _ => false, 524 ~ } |

Check warning on line 524 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro --> crates/genemichaels-lib/src/sg_general.rs:518:28 | 518 | return match p.as_char() { | ____________________________^ 519 | | '.' => true, 520 | | '\'' => true, 521 | | '$' => true, 522 | | '#' => true, 523 | | _ => false, 524 | | }; | |_____________________^ help: try: `matches!(p.as_char(), '.' | '\'' | '$' | '#')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro = note: `#[warn(clippy::match_like_matches_macro)]` on by default

Check warning on line 524 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:518:21 | 518 | / return match p.as_char() { 519 | | '.' => true, 520 | | '\'' => true, 521 | | '$' => true, 522 | | '#' => true, 523 | | _ => false, 524 | | }; | |_____________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 518 ~ match p.as_char() { 519 + '.' => true, 520 + '\'' => true, 521 + '$' => true, 522 + '#' => true, 523 + _ => false, 524 ~ } |
}

// With exceptions, the default heterogeneous adjacent token tree behavior is to
// push. For punctuation-adjacent, it depends on the punctuation type.
fn is_hetero_push_next(prev: &Option<TokenTree>) -> bool {
return match &prev {
Some(prev) => match prev {
TokenTree::Group(_) => true,
TokenTree::Ident(_) | TokenTree::Literal(_) => true,
TokenTree::Punct(punct) => !is_pull_next_punct(&punct),

Check warning on line 534 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/sg_general.rs:534:76 | 534 | ... TokenTree::Punct(punct) => !is_pull_next_punct(&punct), | ^^^^^^ help: change this to: `punct` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 534 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/sg_general.rs:534:76 | 534 | ... TokenTree::Punct(punct) => !is_pull_next_punct(&punct), | ^^^^^^ help: change this to: `punct` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
},
None => false,
};

Check warning on line 537 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:530:21 | 530 | / return match &prev { 531 | | Some(prev) => match prev { 532 | | TokenTree::Group(_) => true, 533 | | TokenTree::Ident(_) | TokenTree::Literal(_) => true, ... | 536 | | None => false, 537 | | }; | |_____________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 530 ~ match &prev { 531 + Some(prev) => match prev { 532 + TokenTree::Group(_) => true, 533 + TokenTree::Ident(_) | TokenTree::Literal(_) => true, 534 + TokenTree::Punct(punct) => !is_pull_next_punct(&punct), 535 + }, 536 + None => false, 537 ~ } |

Check warning on line 537 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:530:21 | 530 | / return match &prev { 531 | | Some(prev) => match prev { 532 | | TokenTree::Group(_) => true, 533 | | TokenTree::Ident(_) | TokenTree::Literal(_) => true, ... | 536 | | None => false, 537 | | }; | |_____________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 530 ~ match &prev { 531 + Some(prev) => match prev { 532 + TokenTree::Group(_) => true, 533 + TokenTree::Ident(_) | TokenTree::Literal(_) => true, 534 + TokenTree::Punct(punct) => !is_pull_next_punct(&punct), 535 + }, 536 + None => false, 537 ~ } |

Check warning on line 537 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:530:21 | 530 | / return match &prev { 531 | | Some(prev) => match prev { 532 | | TokenTree::Group(_) => true, 533 | | TokenTree::Ident(_) | TokenTree::Literal(_) => true, ... | 536 | | None => false, 537 | | }; | |_____________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 530 ~ match &prev { 531 + Some(prev) => match prev { 532 + TokenTree::Group(_) => true, 533 + TokenTree::Ident(_) | TokenTree::Literal(_) => true, 534 + TokenTree::Punct(punct) => !is_pull_next_punct(&punct), 535 + }, 536 + None => false, 537 ~ } |
Expand Down Expand Up @@ -573,18 +583,18 @@
sg.seg(out, " ");
}
append_whitespace(out, base_indent, sg, i.span().start());
sg.seg(out, &i.to_string());

Check warning on line 586 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:586:41 | 586 | ... sg.seg(out, &i.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `i.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 586 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:586:41 | 586 | ... sg.seg(out, &i.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `i.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 586 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:586:41 | 586 | ... sg.seg(out, &i.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `i.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
},
TokenTree::Punct(p) => {
if match &previous {
Some(previous) => match previous {
TokenTree::Group(_) |
TokenTree::Ident(_) |
TokenTree::Literal(_) => match p.as_char() {
':' => false,
'.' => false,
_ => true,
},

Check warning on line 597 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro --> crates/genemichaels-lib/src/sg_general.rs:593:62 | 593 | ... TokenTree::Literal(_) => match p.as_char() { | ________________________________________________^ 594 | | ... ':' => false, 595 | | ... '.' => false, 596 | | ... _ => true, 597 | | ... }, | |_______________________^ help: try: `!matches!(p.as_char(), ':' | '.')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro

Check warning on line 597 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro --> crates/genemichaels-lib/src/sg_general.rs:593:62 | 593 | ... TokenTree::Literal(_) => match p.as_char() { | ________________________________________________^ 594 | | ... ':' => false, 595 | | ... '.' => false, 596 | | ... _ => true, 597 | | ... }, | |_______________________^ help: try: `!matches!(p.as_char(), ':' | '.')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro

Check warning on line 597 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro --> crates/genemichaels-lib/src/sg_general.rs:593:62 | 593 | ... TokenTree::Literal(_) => match p.as_char() { | ________________________________________________^ 594 | | ... ':' => false, 595 | | ... '.' => false, 596 | | ... _ => true, 597 | | ... }, | |_______________________^ help: try: `!matches!(p.as_char(), ':' | '.')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
TokenTree::Punct(prev_p) => prev_p.span().end() != p.span().start(),
},
None => false,
Expand All @@ -592,14 +602,14 @@
sg.seg(out, " ");
}
append_whitespace(out, base_indent, sg, p.span().start());
sg.seg(out, &p.to_string());

Check warning on line 605 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:605:41 | 605 | ... sg.seg(out, &p.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `p.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 605 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:605:41 | 605 | ... sg.seg(out, &p.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `p.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 605 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:605:41 | 605 | ... sg.seg(out, &p.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `p.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
},
TokenTree::Literal(l) => {
if is_hetero_push_next(&previous) {
sg.seg(out, " ");
}
append_whitespace(out, base_indent, sg, l.span().start());
sg.seg(out, &l.to_string());

Check warning on line 612 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:612:41 | 612 | ... sg.seg(out, &l.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `l.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 612 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:612:41 | 612 | ... sg.seg(out, &l.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `l.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 612 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> crates/genemichaels-lib/src/sg_general.rs:612:41 | 612 | ... sg.seg(out, &l.to_string()); | ^^^^^^^^^^^^^^ help: change this to: `l.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
},
}
previous = Some(t);
Expand Down Expand Up @@ -634,16 +644,16 @@
if use_lines == 0 {
return None;
}
return Some(Whitespace {
loc: w.loc,
mode: WhitespaceMode::BlankLines(use_lines),
});

Check warning on line 650 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:647:17 | 647 | / return Some(Whitespace { 648 | | loc: w.loc, 649 | | mode: WhitespaceMode::BlankLines(use_lines), 650 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 647 ~ Some(Whitespace { 648 + loc: w.loc, 649 + mode: WhitespaceMode::BlankLines(use_lines), 650 ~ }) |

Check warning on line 650 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:647:17 | 647 | / return Some(Whitespace { 648 | | loc: w.loc, 649 | | mode: WhitespaceMode::BlankLines(use_lines), 650 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 647 ~ Some(Whitespace { 648 + loc: w.loc, 649 + mode: WhitespaceMode::BlankLines(use_lines), 650 ~ }) |

Check warning on line 650 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:647:17 | 647 | / return Some(Whitespace { 648 | | loc: w.loc, 649 | | mode: WhitespaceMode::BlankLines(use_lines), 650 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 647 ~ Some(Whitespace { 648 + loc: w.loc, 649 + mode: WhitespaceMode::BlankLines(use_lines), 650 ~ }) |
},
WhitespaceMode::Comment(c) => {
return Some(Whitespace {
loc: w.loc,
mode: WhitespaceMode::Comment(c),
});

Check warning on line 656 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:653:17 | 653 | / return Some(Whitespace { 654 | | loc: w.loc, 655 | | mode: WhitespaceMode::Comment(c), 656 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 653 ~ Some(Whitespace { 654 + loc: w.loc, 655 + mode: WhitespaceMode::Comment(c), 656 ~ }) |

Check warning on line 656 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:653:17 | 653 | / return Some(Whitespace { 654 | | loc: w.loc, 655 | | mode: WhitespaceMode::Comment(c), 656 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 653 ~ Some(Whitespace { 654 + loc: w.loc, 655 + mode: WhitespaceMode::Comment(c), 656 ~ }) |

Check warning on line 656 in crates/genemichaels-lib/src/sg_general.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/sg_general.rs:653:17 | 653 | / return Some(Whitespace { 654 | | loc: w.loc, 655 | | mode: WhitespaceMode::Comment(c), 656 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 653 ~ Some(Whitespace { 654 + loc: w.loc, 655 + mode: WhitespaceMode::Comment(c), 656 ~ }) |
},
}
}).collect();
Expand Down
43 changes: 24 additions & 19 deletions crates/genemichaels-lib/src/whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

impl Ord for HashLineColumn {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
return self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column));

Check warning on line 36 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:36:9 | 36 | return self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 36 - return self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)); 36 + self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)) |

Check warning on line 36 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:36:9 | 36 | return self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 36 - return self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)); 36 + self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)) |

Check warning on line 36 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:36:9 | 36 | return self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 36 - return self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)); 36 + self.0.line.cmp(&other.0.line).then(self.0.column.cmp(&other.0.column)) |
}
}

impl PartialOrd for HashLineColumn {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
return Some(self.0.cmp(&other.0));

Check warning on line 42 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:42:9 | 42 | return Some(self.0.cmp(&other.0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 42 - return Some(self.0.cmp(&other.0)); 42 + Some(self.0.cmp(&other.0)) |

Check warning on line 42 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:42:9 | 42 | return Some(self.0.cmp(&other.0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 42 - return Some(self.0.cmp(&other.0)); 42 + Some(self.0.cmp(&other.0)) |

Check warning on line 42 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:42:9 | 42 | return Some(self.0.cmp(&other.0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 42 - return Some(self.0.cmp(&other.0)); 42 + Some(self.0.cmp(&other.0)) |
}
}

Check warning on line 44 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

non-canonical implementation of `partial_cmp` on an `Ord` type

warning: non-canonical implementation of `partial_cmp` on an `Ord` type --> crates/genemichaels-lib/src/whitespace.rs:40:1 | 40 | / impl PartialOrd for HashLineColumn { 41 | | fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | | _______________________________________________________________________- 42 | || return Some(self.0.cmp(&other.0)); 43 | || } | ||_____- help: change this to: `{ Some(self.cmp(other)) }` 44 | | } | |__^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#non_canonical_partial_ord_impl = note: `#[warn(clippy::non_canonical_partial_ord_impl)]` on by default

Check warning on line 44 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

non-canonical implementation of `partial_cmp` on an `Ord` type

warning: non-canonical implementation of `partial_cmp` on an `Ord` type --> crates/genemichaels-lib/src/whitespace.rs:40:1 | 40 | / impl PartialOrd for HashLineColumn { 41 | | fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | | _______________________________________________________________________- 42 | || return Some(self.0.cmp(&other.0)); 43 | || } | ||_____- help: change this to: `{ Some(self.cmp(other)) }` 44 | | } | |__^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#non_canonical_partial_ord_impl = note: `#[warn(clippy::non_canonical_partial_ord_impl)]` on by default

Check warning on line 44 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

non-canonical implementation of `partial_cmp` on an `Ord` type

warning: non-canonical implementation of `partial_cmp` on an `Ord` type --> crates/genemichaels-lib/src/whitespace.rs:40:1 | 40 | / impl PartialOrd for HashLineColumn { 41 | | fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | | _______________________________________________________________________- 42 | || return Some(self.0.cmp(&other.0)); 43 | || } | ||_____- help: change this to: `{ Some(self.cmp(other)) }` 44 | | } | |__^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#non_canonical_partial_ord_impl = note: `#[warn(clippy::non_canonical_partial_ord_impl)]` on by default

Expand Down Expand Up @@ -95,7 +95,7 @@
self.source[line_start_offset..].chars().take(loc.column).map(char::len_utf8).sum::<usize>()
}

fn add_comments(&mut self, end: LineColumn, between_ast_nodes: &str) {
fn add_comments(&mut self, end: LineColumn, abs_start: usize, between_ast_nodes: &str) {
let start_re = &self.start_re.get_or_insert_with(|| Regex::new(
// `//` maybe followed by `[/!.?]`, `/**/`, or `/*` maybe followed by `[*!]`
r#"(?:(//)(/|!|\.|\?)?)|(/\*\*/)|(?:(/\*)(\*|!)?)"#,
Expand All @@ -110,6 +110,7 @@
mode: CommentMode,
lines: Vec<String>,
loc: LineColumn,
orig_start_offset: Option<usize>,
}

impl CommentBuffer {
Expand All @@ -122,9 +123,11 @@
mode: crate::WhitespaceMode::Comment(Comment {
mode: self.mode,
lines: self.lines.split_off(0).join("\n"),
orig_start_offset: self.orig_start_offset.unwrap(),
}),
});
self.blank_lines = 0;
self.orig_start_offset = None;
}

fn add(&mut self, mode: CommentMode, line: &str) {
Expand Down Expand Up @@ -156,19 +159,21 @@
mode: CommentMode::Normal,
lines: vec![],
loc: end,
orig_start_offset: None,
};
let mut text = between_ast_nodes;
let mut text = (abs_start, between_ast_nodes);
'comment_loop : loop {
match start_re.captures(text) {
match start_re.captures(text.1) {
Some(found_start) => {
buffer.orig_start_offset.get_or_insert(abs_start + found_start.get(0).unwrap().start());
let start_prefix_match =
found_start
.get(1)
.or_else(|| found_start.get(3))
.or_else(|| found_start.get(4))
.unwrap();
if buffer.out.is_empty() && buffer.lines.is_empty() {
buffer.add_blank_lines(&text[..start_prefix_match.start()]);
buffer.add_blank_lines(&text.1[..start_prefix_match.start()]);
}
match start_prefix_match.as_str() {
"//" => {
Expand All @@ -184,24 +189,24 @@
}, start_suffix_match.end()),
None => (CommentMode::Normal, start_prefix_match.end()),
};
if mode == CommentMode::DocOuter && text[match_end..].starts_with("/") {
if mode == CommentMode::DocOuter && text.1[match_end..].starts_with("/") {
// > 3 slashes, so actually not a doc comment
mode = CommentMode::Normal;
match_end = start_prefix_match.end();
}
text = &text[match_end..];
text = (text.0 + match_end, &text.1[match_end..]);
mode
};
let (line, next_start) = match text.find('\n') {
Some(line_end) => (&text[..line_end], line_end + 1),
None => (text, text.len()),
let (line, next_start) = match text.1.find('\n') {
Some(line_end) => (&text.1[..line_end], line_end + 1),
None => (text.1, text.1.len()),
};
buffer.add(mode, line);
text = &text[next_start..];
text = (text.0 + next_start, &text.1[next_start..]);
},
"/**/" => {
buffer.add(CommentMode::Normal, "".into());

Check warning on line 208 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `&str`

warning: useless conversion to the same type: `&str` --> crates/genemichaels-lib/src/whitespace.rs:208:65 | 208 | ... buffer.add(CommentMode::Normal, "".into()); | ^^^^^^^^^ help: consider removing `.into()`: `""` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default

Check warning on line 208 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `&str`

warning: useless conversion to the same type: `&str` --> crates/genemichaels-lib/src/whitespace.rs:208:65 | 208 | ... buffer.add(CommentMode::Normal, "".into()); | ^^^^^^^^^ help: consider removing `.into()`: `""` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default

Check warning on line 208 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `&str`

warning: useless conversion to the same type: `&str` --> crates/genemichaels-lib/src/whitespace.rs:208:65 | 208 | ... buffer.add(CommentMode::Normal, "".into()); | ^^^^^^^^^ help: consider removing `.into()`: `""` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default
text = &text[start_prefix_match.end()..];
text = (text.0 + start_prefix_match.end(), &text.1[start_prefix_match.end()..]);
},
"/*" => {
let mode = {
Expand All @@ -214,14 +219,14 @@
}, start_suffix_match.end()),
None => (CommentMode::Normal, start_prefix_match.end()),
};
text = &text[match_end..];
text = (text.0 + match_end, &text.1[match_end..]);
mode
};
let mut nesting = 1;
let mut search_end_at = 0usize;
let (lines, next_start) = loop {
let found_event =
block_event_re.captures(&text[search_end_at..]).unwrap().get(1).unwrap();
block_event_re.captures(&text.1[search_end_at..]).unwrap().get(1).unwrap();
let event_start = search_end_at + found_event.start();
search_end_at += found_event.end();
match found_event.as_str() {
Expand All @@ -231,7 +236,7 @@
"*/" => {
nesting -= 1;
if nesting == 0 {
break (&text[..event_start], search_end_at);
break (&text.1[..event_start], search_end_at);
}
},
_ => unreachable!(),
Expand All @@ -242,14 +247,14 @@
line = line.strip_prefix("* ").unwrap_or(line);
buffer.add(mode, line);
}
text = &text[next_start..];
text = (text.0 + next_start, &text.1[next_start..]);
},
_ => unreachable!(),
}
},
None => {
if buffer.out.is_empty() && buffer.lines.is_empty() {
buffer.add_blank_lines(text);
buffer.add_blank_lines(text.1);
}
break 'comment_loop;
},
Expand All @@ -257,7 +262,7 @@
}
buffer.flush();
if !buffer.out.is_empty() {
let whitespaces = self.whitespaces.entry(HashLineColumn(end)).or_insert(vec![]);

Check warning on line 265 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

use of `or_insert` to construct default value

warning: use of `or_insert` to construct default value --> crates/genemichaels-lib/src/whitespace.rs:265:79 | 265 | let whitespaces = self.whitespaces.entry(HashLineColumn(end)).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default = note: `#[warn(clippy::unwrap_or_default)]` on by default

Check warning on line 265 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

use of `or_insert` to construct default value

warning: use of `or_insert` to construct default value --> crates/genemichaels-lib/src/whitespace.rs:265:79 | 265 | let whitespaces = self.whitespaces.entry(HashLineColumn(end)).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default = note: `#[warn(clippy::unwrap_or_default)]` on by default

Check warning on line 265 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

use of `or_insert` to construct default value

warning: use of `or_insert` to construct default value --> crates/genemichaels-lib/src/whitespace.rs:265:79 | 265 | let whitespaces = self.whitespaces.entry(HashLineColumn(end)).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default = note: `#[warn(clippy::unwrap_or_default)]` on by default

// Merge with existing comments (basically only if comments come before and after
// at the end of the line)
Expand All @@ -276,7 +281,7 @@
if previous_comment.mode != start_comment.mode {
break;
}
previous_comment.lines.push_str("\n");

Check warning on line 284 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

calling `push_str()` using a single-character string literal

warning: calling `push_str()` using a single-character string literal --> crates/genemichaels-lib/src/whitespace.rs:284:25 | 284 | previous_comment.lines.push_str("\n"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `previous_comment.lines.push('\n')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str = note: `#[warn(clippy::single_char_add_str)]` on by default

Check warning on line 284 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

calling `push_str()` using a single-character string literal

warning: calling `push_str()` using a single-character string literal --> crates/genemichaels-lib/src/whitespace.rs:284:25 | 284 | previous_comment.lines.push_str("\n"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `previous_comment.lines.push('\n')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str = note: `#[warn(clippy::single_char_add_str)]` on by default

Check warning on line 284 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

calling `push_str()` using a single-character string literal

warning: calling `push_str()` using a single-character string literal --> crates/genemichaels-lib/src/whitespace.rs:284:25 | 284 | previous_comment.lines.push_str("\n"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `previous_comment.lines.push('\n')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str = note: `#[warn(clippy::single_char_add_str)]` on by default
previous_comment.lines.push_str(&start_comment.lines);
break 'merge;
}
Expand Down Expand Up @@ -307,7 +312,7 @@
};
let text = &self.source[start .. eol];
if text.trim_start().starts_with("//") {
self.add_comments(*previous_start, text);
self.add_comments(*previous_start, start, text);
}
start = eol;
break true;
Expand All @@ -321,15 +326,15 @@
return;
}
let whole_text = &self.source[start .. end_offset];
self.add_comments(end, whole_text);
self.add_comments(end, start, whole_text);
}
}

// Extract comments
let mut state = State {
source: source,

Check warning on line 335 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:335:9 | 335 | source: source, | ^^^^^^^^^^^^^^ help: replace it with: `source` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names = note: `#[warn(clippy::redundant_field_names)]` on by default

Check warning on line 335 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:335:9 | 335 | source: source, | ^^^^^^^^^^^^^^ help: replace it with: `source` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names = note: `#[warn(clippy::redundant_field_names)]` on by default
keep_max_blank_lines: keep_max_blank_lines,

Check warning on line 336 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:336:9 | 336 | keep_max_blank_lines: keep_max_blank_lines, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `keep_max_blank_lines` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 336 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:336:9 | 336 | keep_max_blank_lines: keep_max_blank_lines, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `keep_max_blank_lines` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
line_lookup: line_lookup,

Check warning on line 337 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:337:9 | 337 | line_lookup: line_lookup, | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `line_lookup` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 337 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:337:9 | 337 | line_lookup: line_lookup, | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `line_lookup` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
whitespaces: BTreeMap::new(),
last_offset: 0usize,
line_start: None,
Expand Down Expand Up @@ -398,7 +403,7 @@
line = e.span().start().line,
column = e.span().start().column,
error = e.to_string(),
source = source.lines().skip(e.span().start().line - 1).next().unwrap()

Check warning on line 406 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

called `skip(..).next()` on an iterator

warning: called `skip(..).next()` on an iterator --> crates/genemichaels-lib/src/whitespace.rs:406:48 | 406 | source = source.lines().skip(e.span().start().line - 1).next().unwrap() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(e.span().start().line - 1)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next = note: `#[warn(clippy::iter_skip_next)]` on by default

Check warning on line 406 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

called `skip(..).next()` on an iterator

warning: called `skip(..).next()` on an iterator --> crates/genemichaels-lib/src/whitespace.rs:406:48 | 406 | source = source.lines().skip(e.span().start().line - 1).next().unwrap() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(e.span().start().line - 1)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next = note: `#[warn(clippy::iter_skip_next)]` on by default

Check warning on line 406 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

called `skip(..).next()` on an iterator

warning: called `skip(..).next()` on an iterator --> crates/genemichaels-lib/src/whitespace.rs:406:48 | 406 | source = source.lines().skip(e.span().start().line - 1).next().unwrap() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(e.span().start().line - 1)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next = note: `#[warn(clippy::iter_skip_next)]` on by default
),
),
)?,
Expand All @@ -406,7 +411,7 @@
state.add_comments(LineColumn {
line: 0,
column: 1,
}, &source[state.last_offset..]);
}, state.last_offset, &source[state.last_offset..]);
Ok((state.whitespaces, tokens))
}

Expand Down Expand Up @@ -487,7 +492,7 @@
explicit_wrap: bool,
) -> LineState {
LineState(Rc::new(RefCell::new(LineState_ {
base_prefix_len: base_prefix_len,

Check warning on line 495 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:495:13 | 495 | base_prefix_len: base_prefix_len, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `base_prefix_len` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 495 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:495:13 | 495 | base_prefix_len: base_prefix_len, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `base_prefix_len` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
first_prefix,
prefix,
explicit_wrap,
Expand Down Expand Up @@ -563,21 +568,21 @@
let next_break = Some((b, &breaks[i + 1..]));
if width + unicode_len(&text[..b]) > max_len {
return FoundWritableLen {
writable: writable,

Check warning on line 571 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:571:25 | 571 | writable: writable, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `writable` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 571 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:571:25 | 571 | writable: writable, | ^^^^^^^^^^^^^^^^^^ help: replace it with: `writable` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
previous_break: previous_break,

Check warning on line 572 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:572:25 | 572 | previous_break: previous_break, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `previous_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 572 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:572:25 | 572 | previous_break: previous_break, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `previous_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 572 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:572:25 | 572 | previous_break: previous_break, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `previous_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
next_break: next_break,

Check warning on line 573 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:573:25 | 573 | next_break: next_break, | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `next_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 573 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:573:25 | 573 | next_break: next_break, | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `next_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 573 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:573:25 | 573 | next_break: next_break, | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `next_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
};
}
previous_break = next_break;
writable = b;
}
return FoundWritableLen {
writable: if width + unicode_len(&text) > max_len {

Check warning on line 580 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:580:50 | 580 | writable: if width + unicode_len(&text) > max_len { | ^^^^^ help: change this to: `text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default

Check warning on line 580 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:580:50 | 580 | writable: if width + unicode_len(&text) > max_len { | ^^^^^ help: change this to: `text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default

Check warning on line 580 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:580:50 | 580 | writable: if width + unicode_len(&text) > max_len { | ^^^^^ help: change this to: `text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
writable
} else {
text.len()
},
previous_break: previous_break,

Check warning on line 585 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:585:17 | 585 | previous_break: previous_break, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `previous_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 585 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:585:17 | 585 | previous_break: previous_break, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `previous_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Check warning on line 585 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization --> crates/genemichaels-lib/src/whitespace.rs:585:17 | 585 | previous_break: previous_break, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `previous_break` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
next_break: None,
};

Check warning on line 587 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:579:13 | 579 | / return FoundWritableLen { 580 | | writable: if width + unicode_len(&text) > max_len { 581 | | writable 582 | | } else { ... | 586 | | next_break: None, 587 | | }; | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 579 ~ FoundWritableLen { 580 + writable: if width + unicode_len(&text) > max_len { 581 + writable 582 + } else { 583 + text.len() 584 + }, 585 + previous_break: previous_break, 586 + next_break: None, 587 ~ } |

Check warning on line 587 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:579:13 | 579 | / return FoundWritableLen { 580 | | writable: if width + unicode_len(&text) > max_len { 581 | | writable 582 | | } else { ... | 586 | | next_break: None, 587 | | }; | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 579 ~ FoundWritableLen { 580 + writable: if width + unicode_len(&text) > max_len { 581 + writable 582 + } else { 583 + text.len() 584 + }, 585 + previous_break: previous_break, 586 + next_break: None, 587 ~ } |

Check warning on line 587 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:579:13 | 579 | / return FoundWritableLen { 580 | | writable: if width + unicode_len(&text) > max_len { 581 | | writable 582 | | } else { ... | 586 | | next_break: None, 587 | | }; | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 579 ~ FoundWritableLen { 580 + writable: if width + unicode_len(&text) > max_len { 581 + writable 582 + } else { 583 + text.len() 584 + }, 585 + previous_break: previous_break, 586 + next_break: None, 587 ~ } |
}
Expand All @@ -587,7 +592,7 @@
if let Some(b) = b {
s.backward_break = Some((state.line_buffer.len() + b, s.explicit_wrap));
}
state.line_buffer.push_str(&text);

Check warning on line 595 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:595:40 | 595 | state.line_buffer.push_str(&text); | ^^^^^ help: change this to: `text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 595 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:595:40 | 595 | state.line_buffer.push_str(&text); | ^^^^^ help: change this to: `text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 595 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:595:40 | 595 | state.line_buffer.push_str(&text); | ^^^^^ help: change this to: `text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
}

fn write_forward_breaks(
Expand Down Expand Up @@ -634,7 +639,7 @@
out,
max_len,
false,
(&text[found.writable..]).to_string(),

Check warning on line 642 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression borrows a value the compiler would automatically borrow

warning: this expression borrows a value the compiler would automatically borrow --> crates/genemichaels-lib/src/whitespace.rs:642:17 | 642 | (&text[found.writable..]).to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `text[found.writable..]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 642 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression borrows a value the compiler would automatically borrow

warning: this expression borrows a value the compiler would automatically borrow --> crates/genemichaels-lib/src/whitespace.rs:642:17 | 642 | (&text[found.writable..]).to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `text[found.writable..]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 642 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression borrows a value the compiler would automatically borrow

warning: this expression borrows a value the compiler would automatically borrow --> crates/genemichaels-lib/src/whitespace.rs:642:17 | 642 | (&text[found.writable..]).to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `text[found.writable..]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
found.writable,
found.previous_break.map(|b| b.1).unwrap_or(breaks),
);
Expand All @@ -649,10 +654,10 @@
// No retroactive split, try first split after max len (overflow, but better than
// nothing)
write_forward(state, &mut s, &text[..b], Some(b));
write_forward_breaks(state, &mut s, out, max_len, false, (&text[b..]).to_string(), b, breaks);

Check warning on line 657 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression borrows a value the compiler would automatically borrow

warning: this expression borrows a value the compiler would automatically borrow --> crates/genemichaels-lib/src/whitespace.rs:657:70 | 657 | write_forward_breaks(state, &mut s, out, max_len, false, (&text[b..]).to_string(), b, breaks); | ^^^^^^^^^^^^ help: change this to: `text[b..]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 657 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression borrows a value the compiler would automatically borrow

warning: this expression borrows a value the compiler would automatically borrow --> crates/genemichaels-lib/src/whitespace.rs:657:70 | 657 | write_forward_breaks(state, &mut s, out, max_len, false, (&text[b..]).to_string(), b, breaks); | ^^^^^^^^^^^^ help: change this to: `text[b..]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
} else {
state.line_buffer.push_str(text);
return;

Check warning on line 660 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:660:13 | 660 | return; | ^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 659 - state.line_buffer.push_str(text); 660 - return; 659 + state.line_buffer.push_str(text); |

Check warning on line 660 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> crates/genemichaels-lib/src/whitespace.rs:660:13 | 660 | return; | ^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 659 - state.line_buffer.push_str(text); 660 - return; 659 + state.line_buffer.push_str(text); |
}
}

Expand Down Expand Up @@ -843,7 +848,7 @@
},
Node::Image(x) => {
let alt = join_lines(&x.alt);
match (get_splits(&join_lines(&alt)).first().is_some(), &x.title) {

Check warning on line 851 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:851:20 | 851 | match (get_splits(&join_lines(&alt)).first().is_some(), &x.title) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&join_lines(&alt)).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check = note: `#[warn(clippy::unnecessary_first_then_check)]` on by default

Check warning on line 851 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:851:20 | 851 | match (get_splits(&join_lines(&alt)).first().is_some(), &x.title) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&join_lines(&alt)).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check = note: `#[warn(clippy::unnecessary_first_then_check)]` on by default
(false, None) => {
line.write_unbreakable(state, out, &format!("![{}]({})", alt, x.url));
},
Expand Down Expand Up @@ -875,11 +880,11 @@
let simple_text = if x.children.len() != 1 {
None
} else {
x.children.get(0)

Check warning on line 883 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `x.children.get(0)`

warning: accessing first element with `x.children.get(0)` --> crates/genemichaels-lib/src/whitespace.rs:883:17 | 883 | x.children.get(0) | ^^^^^^^^^^^^^^^^^ help: try: `x.children.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first = note: `#[warn(clippy::get_first)]` on by default

Check warning on line 883 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `x.children.get(0)`

warning: accessing first element with `x.children.get(0)` --> crates/genemichaels-lib/src/whitespace.rs:883:17 | 883 | x.children.get(0) | ^^^^^^^^^^^^^^^^^ help: try: `x.children.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first = note: `#[warn(clippy::get_first)]` on by default
}.and_then(|c| match c {
Node::Text(t) => {
let t = join_lines(&t.value);
if get_splits(&t).first().is_some() {

Check warning on line 887 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:887:24 | 887 | if get_splits(&t).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check

Check warning on line 887 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:887:24 | 887 | if get_splits(&t).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check
None
} else {
Some(t)
Expand All @@ -887,7 +892,7 @@
},
Node::InlineCode(t) => {
let t = join_lines(&t.value);
if get_splits(&t).first().is_some() {

Check warning on line 895 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:895:24 | 895 | if get_splits(&t).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check

Check warning on line 895 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:895:24 | 895 | if get_splits(&t).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check
None
} else {
Some(format!("`{}`", t))
Expand Down Expand Up @@ -932,14 +937,14 @@
let simple_text = if x.children.len() != 1 {
None
} else {
x.children.get(0)

Check warning on line 940 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `x.children.get(0)`

warning: accessing first element with `x.children.get(0)` --> crates/genemichaels-lib/src/whitespace.rs:940:17 | 940 | x.children.get(0) | ^^^^^^^^^^^^^^^^^ help: try: `x.children.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 940 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `x.children.get(0)`

warning: accessing first element with `x.children.get(0)` --> crates/genemichaels-lib/src/whitespace.rs:940:17 | 940 | x.children.get(0) | ^^^^^^^^^^^^^^^^^ help: try: `x.children.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 940 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

accessing first element with `x.children.get(0)`

warning: accessing first element with `x.children.get(0)` --> crates/genemichaels-lib/src/whitespace.rs:940:17 | 940 | x.children.get(0) | ^^^^^^^^^^^^^^^^^ help: try: `x.children.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
}.and_then(|c| match c {
Node::Text(t) => if get_splits(&t.value).first().is_some() {

Check warning on line 942 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:942:37 | 942 | Node::Text(t) => if get_splits(&t.value).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t.value).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check

Check warning on line 942 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:942:37 | 942 | Node::Text(t) => if get_splits(&t.value).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t.value).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check

Check warning on line 942 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:942:37 | 942 | Node::Text(t) => if get_splits(&t.value).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t.value).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check
None
} else {
Some(t.value.clone())
},
Node::InlineCode(t) => if get_splits(&t.value).first().is_some() {

Check warning on line 947 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:947:43 | 947 | Node::InlineCode(t) => if get_splits(&t.value).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t.value).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check

Check warning on line 947 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:947:43 | 947 | Node::InlineCode(t) => if get_splits(&t.value).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t.value).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check

Check warning on line 947 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary use of `first().is_some()` to check if slice is not empty

warning: unnecessary use of `first().is_some()` to check if slice is not empty --> crates/genemichaels-lib/src/whitespace.rs:947:43 | 947 | Node::InlineCode(t) => if get_splits(&t.value).first().is_some() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!get_splits(&t.value).is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_first_then_check
None
} else {
Some(format!("`{}`", t.value))
Expand Down Expand Up @@ -1003,7 +1008,7 @@
&mut state,
&mut out,
LineState::new(
unicode_len(&prefix),

Check warning on line 1011 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:1011:29 | 1011 | unicode_len(&prefix), | ^^^^^^^ help: change this to: `prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 1011 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:1011:29 | 1011 | unicode_len(&prefix), | ^^^^^^^ help: change this to: `prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 1011 in crates/genemichaels-lib/src/whitespace.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/genemichaels-lib/src/whitespace.rs:1011:29 | 1011 | unicode_len(&prefix), | ^^^^^^^ help: change this to: `prefix` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
None,
prefix.to_string(),
VisualLen(max_width),
Expand Down
1 change: 1 addition & 0 deletions crates/genemichaels-lib/tests/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fn comment(mode: CommentMode, lines: &str) -> Whitespace {
mode: genemichaels_lib::WhitespaceMode::Comment(Comment {
mode: mode,
lines: lines.to_string(),
orig_start_offset: 0,
}),
};
}
Expand Down
26 changes: 26 additions & 0 deletions crates/genemichaels-lib/tests/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,32 @@ fn rt_rustfmt_skip_subtree_comment() {
);
}

#[test]
fn rt_rustfmt_skip_subtree_comment_array() {
rt(
r#"fn main() {
#[rustfmt::skip]
let src_attribs = [
// EGL_WIDTH
0x3057, src.width() as i32,
// EGL_HEIGHT
0x3056, src.height() as i32,
//EGL_DMA_BUF_PLANE0_FD_EXT
0x3271, srcfd,
// EGL_DMA_BUF_PLANE0_OFFSET_EXT
0x3273, 0,
// EGL_DMA_BUF_PLANE0_PITCH_EXT
0x3274, src.stride() as i32,
// EGL_LINUX_DRM_FOURCC_EXT
// DRM_FORMAT_XRGB8888
0x3203, 0x34325258,
egl::EGL_NONE,
];
}
"#,
);
}

#[test]
fn rttabs_struct_generic1() {
rt_tabs(
Expand Down
Loading