Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit c6e5bee

Browse files
authored
chore: bump rust version and fix lints (#47)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 805edf2 commit c6e5bee

File tree

8 files changed

+131
-122
lines changed

8 files changed

+131
-122
lines changed

Cargo.lock

+116-109
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ all = "warn"
2929
pedantic = "warn"
3030
nursery = "warn"
3131

32+
[lints.rust]
33+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
34+
3235
[dev-dependencies]
3336
rstest = { version = "0.19.0" } # parametrized tests
3437
indoc = { version = "2.0.5" } # dedented test cases for literal strings

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.77"
2+
channel = "1.81"

rust/src/build_system.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::helpers::array::{sort, transform};
22
use crate::helpers::pep508::{format_requirement, get_canonic_requirement_name};
33
use crate::helpers::table::{for_entries, reorder_table_keys, Tables};
44

5-
pub fn fix(tables: &mut Tables, keep_full_version: bool) {
5+
pub fn fix(tables: &Tables, keep_full_version: bool) {
66
let table_element = tables.get("build-system");
77
if table_element.is_none() {
88
return;
@@ -35,8 +35,8 @@ mod tests {
3535
fn evaluate(start: &str, keep_full_version: bool) -> String {
3636
let root_ast = parse(start).into_syntax().clone_for_update();
3737
let count = root_ast.children_with_tokens().count();
38-
let mut tables = Tables::from_ast(&root_ast);
39-
fix(&mut tables, keep_full_version);
38+
let tables = Tables::from_ast(&root_ast);
39+
fix(&tables, keep_full_version);
4040
let entries = tables
4141
.table_set
4242
.iter()

rust/src/global.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use taplo::syntax::Lang;
33

44
use crate::helpers::table::Tables;
55

6-
pub fn reorder_tables(root_ast: &SyntaxNode<Lang>, tables: &mut Tables) {
6+
pub fn reorder_tables(root_ast: &SyntaxNode<Lang>, tables: &Tables) {
77
tables.reorder(
88
root_ast,
99
&[
@@ -161,8 +161,8 @@ mod tests {
161161
)]
162162
fn test_reorder_table(#[case] start: &str, #[case] expected: &str) {
163163
let root_ast = parse(start).into_syntax().clone_for_update();
164-
let mut tables = Tables::from_ast(&root_ast);
165-
reorder_tables(&root_ast, &mut tables);
164+
let tables = Tables::from_ast(&root_ast);
165+
reorder_tables(&root_ast, &tables);
166166
let opt = Options {
167167
column_width: 1,
168168
..Options::default()

rust/src/helpers/array.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ where
3939
== Some(COMMA);
4040
let multiline = array_node
4141
.children_with_tokens()
42-
.find(|e| e.kind() == NEWLINE)
43-
.is_some();
42+
.any(|e| e.kind() == NEWLINE);
4443
let mut value_set = Vec::<Vec<SyntaxElement>>::new();
4544
let entry_set = RefCell::new(Vec::<SyntaxElement>::new());
4645
let mut key_to_pos = HashMap::<String, usize>::new();

rust/src/helpers/table.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct Tables {
1717
}
1818

1919
impl Tables {
20-
pub(crate) fn get(&mut self, key: &str) -> Option<Vec<&RefCell<Vec<SyntaxElement>>>> {
20+
pub(crate) fn get(&self, key: &str) -> Option<Vec<&RefCell<Vec<SyntaxElement>>>> {
2121
if self.header_to_pos.contains_key(key) {
2222
let mut res = Vec::<&RefCell<Vec<SyntaxElement>>>::new();
2323
for pos in &self.header_to_pos[key] {
@@ -75,7 +75,7 @@ impl Tables {
7575
}
7676
}
7777

78-
pub fn reorder(&mut self, root_ast: &SyntaxNode, order: &[&str]) {
78+
pub fn reorder(&self, root_ast: &SyntaxNode, order: &[&str]) {
7979
let mut to_insert = Vec::<SyntaxElement>::new();
8080
let order = calculate_order(&self.header_to_pos, &self.table_set, order);
8181
let mut next = order.clone();

rust/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ pub fn format_toml(content: &str, opt: &Settings) -> String {
5252
let root_ast = parse(content).into_syntax().clone_for_update();
5353
let mut tables = Tables::from_ast(&root_ast);
5454

55-
build_system::fix(&mut tables, opt.keep_full_version);
55+
build_system::fix(&tables, opt.keep_full_version);
5656
project::fix(
5757
&mut tables,
5858
opt.keep_full_version,
5959
opt.max_supported_python,
6060
opt.min_supported_python,
6161
);
6262
ruff::fix(&mut tables);
63-
reorder_tables(&root_ast, &mut tables);
63+
reorder_tables(&root_ast, &tables);
6464

6565
let options = Options {
6666
align_entries: false, // do not align by =

0 commit comments

Comments
 (0)