From fb046a13544297728db068700405ecefc74e898a Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sun, 17 Aug 2025 14:50:24 +0200 Subject: [PATCH 1/2] update tests to match lint message changes from rust-lang/rust#140794 --- .../tests/everything/multiple-solutions.json | 234 +++++++++--------- .../everything/replace-only-one-char.json | 108 ++++---- tests/testsuite/fix.rs | 2 +- tests/testsuite/warning_override.rs | 10 +- 4 files changed, 183 insertions(+), 171 deletions(-) diff --git a/crates/rustfix/tests/everything/multiple-solutions.json b/crates/rustfix/tests/everything/multiple-solutions.json index ce9d54e4a84..d3d7161c005 100644 --- a/crates/rustfix/tests/everything/multiple-solutions.json +++ b/crates/rustfix/tests/everything/multiple-solutions.json @@ -1,166 +1,166 @@ { "$message_type": "diagnostic", - "message": "unused imports: `HashMap`, `VecDeque`", - "code": { - "code": "unused_imports", - "explanation": null - }, - "level": "warning", - "spans": [ - { - "file_name": "./tests/everything/multiple-solutions.nightly.rs", - "byte_start": 23, - "byte_end": 30, - "line_start": 1, - "line_end": 1, - "column_start": 24, - "column_end": 31, - "is_primary": true, - "text": [ - { - "text": "use std::collections::{HashMap, HashSet, VecDeque};", - "highlight_start": 24, - "highlight_end": 31 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - }, - { - "file_name": "./tests/everything/multiple-solutions.nightly.rs", - "byte_start": 41, - "byte_end": 49, - "line_start": 1, - "line_end": 1, - "column_start": 42, - "column_end": 50, - "is_primary": true, - "text": [ - { - "text": "use std::collections::{HashMap, HashSet, VecDeque};", - "highlight_start": 42, - "highlight_end": 50 - } - ], - "label": null, - "suggested_replacement": null, - "suggestion_applicability": null, - "expansion": null - } - ], "children": [ { - "message": "`#[warn(unused_imports)]` on by default", + "children": [], "code": null, "level": "note", - "spans": [], - "children": [], - "rendered": null + "message": "`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default", + "rendered": null, + "spans": [] }, { - "message": "remove the unused imports", + "children": [], "code": null, "level": "help", + "message": "remove the unused imports", + "rendered": null, "spans": [ { - "file_name": "./tests/everything/multiple-solutions.nightly.rs", - "byte_start": 22, - "byte_end": 23, - "line_start": 1, - "line_end": 1, - "column_start": 23, - "column_end": 24, + "byte_end": 32, + "byte_start": 23, + "column_end": 33, + "column_start": 24, + "expansion": null, + "file_name": "./tests/everything/multiple-solutions.rs", "is_primary": true, - "text": [ - { - "text": "use std::collections::{HashMap, HashSet, VecDeque};", - "highlight_start": 23, - "highlight_end": 24 - } - ], "label": null, + "line_end": 1, + "line_start": 1, "suggested_replacement": "", "suggestion_applicability": "MachineApplicable", - "expansion": null - }, - { - "file_name": "./tests/everything/multiple-solutions.nightly.rs", - "byte_start": 23, - "byte_end": 32, - "line_start": 1, - "line_end": 1, - "column_start": 24, - "column_end": 33, - "is_primary": true, "text": [ { - "text": "use std::collections::{HashMap, HashSet, VecDeque};", + "highlight_end": 33, "highlight_start": 24, - "highlight_end": 33 + "text": "use std::collections::{HashMap, HashSet, VecDeque};" } - ], - "label": null, - "suggested_replacement": "", - "suggestion_applicability": "MachineApplicable", - "expansion": null + ] }, { - "file_name": "./tests/everything/multiple-solutions.nightly.rs", - "byte_start": 39, "byte_end": 49, - "line_start": 1, - "line_end": 1, - "column_start": 40, + "byte_start": 39, "column_end": 50, + "column_start": 40, + "expansion": null, + "file_name": "./tests/everything/multiple-solutions.rs", "is_primary": true, + "label": null, + "line_end": 1, + "line_start": 1, + "suggested_replacement": "", + "suggestion_applicability": "MachineApplicable", "text": [ { - "text": "use std::collections::{HashMap, HashSet, VecDeque};", + "highlight_end": 50, "highlight_start": 40, - "highlight_end": 50 + "text": "use std::collections::{HashMap, HashSet, VecDeque};" } - ], + ] + }, + { + "byte_end": 23, + "byte_start": 22, + "column_end": 24, + "column_start": 23, + "expansion": null, + "file_name": "./tests/everything/multiple-solutions.rs", + "is_primary": true, "label": null, + "line_end": 1, + "line_start": 1, "suggested_replacement": "", "suggestion_applicability": "MachineApplicable", - "expansion": null + "text": [ + { + "highlight_end": 24, + "highlight_start": 23, + "text": "use std::collections::{HashMap, HashSet, VecDeque};" + } + ] }, { - "file_name": "./tests/everything/multiple-solutions.nightly.rs", - "byte_start": 49, "byte_end": 50, - "line_start": 1, - "line_end": 1, - "column_start": 50, + "byte_start": 49, "column_end": 51, + "column_start": 50, + "expansion": null, + "file_name": "./tests/everything/multiple-solutions.rs", "is_primary": true, + "label": null, + "line_end": 1, + "line_start": 1, + "suggested_replacement": "", + "suggestion_applicability": "MachineApplicable", "text": [ { - "text": "use std::collections::{HashMap, HashSet, VecDeque};", + "highlight_end": 51, "highlight_start": 50, - "highlight_end": 51 + "text": "use std::collections::{HashMap, HashSet, VecDeque};" } - ], - "label": null, - "suggested_replacement": "", - "suggestion_applicability": "MachineApplicable", - "expansion": null + ] } - ], - "children": [], - "rendered": null + ] } ], - "rendered": "warning: unused imports: `HashMap`, `VecDeque`\n --> ./tests/everything/multiple-solutions.nightly.rs:1:24\n |\n1 | use std::collections::{HashMap, HashSet, VecDeque};\n | ^^^^^^^ ^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\n" + "code": { + "code": "unused_imports", + "explanation": null + }, + "level": "warning", + "message": "unused imports: `HashMap` and `VecDeque`", + "rendered": "warning: unused imports: `HashMap` and `VecDeque`/n --> ./tests/everything/multiple-solutions.rs:1:24/n |/n1 | use std::collections::{HashMap, HashSet, VecDeque};/n | ^^^^^^^ ^^^^^^^^/n |/n = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default/n/n", + "spans": [ + { + "byte_end": 30, + "byte_start": 23, + "column_end": 31, + "column_start": 24, + "expansion": null, + "file_name": "./tests/everything/multiple-solutions.rs", + "is_primary": true, + "label": null, + "line_end": 1, + "line_start": 1, + "suggested_replacement": null, + "suggestion_applicability": null, + "text": [ + { + "highlight_end": 31, + "highlight_start": 24, + "text": "use std::collections::{HashMap, HashSet, VecDeque};" + } + ] + }, + { + "byte_end": 49, + "byte_start": 41, + "column_end": 50, + "column_start": 42, + "expansion": null, + "file_name": "./tests/everything/multiple-solutions.rs", + "is_primary": true, + "label": null, + "line_end": 1, + "line_start": 1, + "suggested_replacement": null, + "suggestion_applicability": null, + "text": [ + { + "highlight_end": 50, + "highlight_start": 42, + "text": "use std::collections::{HashMap, HashSet, VecDeque};" + } + ] + } + ] } { "$message_type": "diagnostic", - "message": "1 warning emitted", + "children": [], "code": null, "level": "warning", - "spans": [], - "children": [], - "rendered": "warning: 1 warning emitted\n\n" -} + "message": "1 warning emitted", + "rendered": "warning: 1 warning emitted/n/n", + "spans": [] +} \ No newline at end of file diff --git a/crates/rustfix/tests/everything/replace-only-one-char.json b/crates/rustfix/tests/everything/replace-only-one-char.json index 9a70c088030..2f998ce0e6d 100644 --- a/crates/rustfix/tests/everything/replace-only-one-char.json +++ b/crates/rustfix/tests/everything/replace-only-one-char.json @@ -1,70 +1,82 @@ { - "message": "unused variable: `x`", - "code": { - "code": "unused_variables", - "explanation": null - }, - "level": "warning", - "spans": [ - { - "file_name": "replace-only-one-char.rs", - "byte_start": 20, - "byte_end": 21, - "line_start": 2, - "line_end": 2, - "column_start": 9, - "column_end": 10, - "is_primary": true, - "text": [ - { - "text": " let x = 42;", - "highlight_start": 9, - "highlight_end": 10 - } - ], - "label": null, - "suggested_replacement": null, - "expansion": null - } - ], + "$message_type": "diagnostic", "children": [ { - "message": "#[warn(unused_variables)] on by default", + "children": [], "code": null, "level": "note", - "spans": [], - "children": [], - "rendered": null + "message": "`#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default", + "rendered": null, + "spans": [] }, { - "message": "consider using `_x` instead", + "children": [], "code": null, "level": "help", + "message": "if this is intentional, prefix it with an underscore", + "rendered": null, "spans": [ { - "file_name": "replace-only-one-char.rs", - "byte_start": 20, "byte_end": 21, - "line_start": 2, - "line_end": 2, - "column_start": 9, + "byte_start": 20, "column_end": 10, + "column_start": 9, + "expansion": null, + "file_name": "./tests/everything/replace-only-one-char.rs", "is_primary": true, + "label": null, + "line_end": 2, + "line_start": 2, + "suggested_replacement": "_x", + "suggestion_applicability": "MaybeIncorrect", "text": [ { - "text": " let x = 42;", + "highlight_end": 10, "highlight_start": 9, - "highlight_end": 10 + "text": " let x = 42;" } - ], - "label": null, - "suggested_replacement": "_x", - "expansion": null + ] } - ], - "children": [], - "rendered": null + ] } ], - "rendered": "warning: unused variable: `x`\n --> replace-only-one-char.rs:2:9\n |\n2 | let x = 42;\n | ^ help: consider using `_x` instead\n |\n = note: #[warn(unused_variables)] on by default\n\n" + "code": { + "code": "unused_variables", + "explanation": null + }, + "level": "warning", + "message": "unused variable: `x`", + "rendered": "warning: unused variable: `x`/n --> ./tests/everything/replace-only-one-char.rs:2:9/n |/n2 | let x = 42;/n | ^ help: if this is intentional, prefix it with an underscore: `_x`/n |/n = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default/n/n", + "spans": [ + { + "byte_end": 21, + "byte_start": 20, + "column_end": 10, + "column_start": 9, + "expansion": null, + "file_name": "./tests/everything/replace-only-one-char.rs", + "is_primary": true, + "label": null, + "line_end": 2, + "line_start": 2, + "suggested_replacement": null, + "suggestion_applicability": null, + "text": [ + { + "highlight_end": 10, + "highlight_start": 9, + "text": " let x = 42;" + } + ] + } + ] } +{ + "$message_type": "diagnostic", + "children": [], + "code": null, + "level": "warning", + "message": "1 warning emitted", + "rendered": "warning: 1 warning emitted/n/n", + "spans": [] +} \ No newline at end of file diff --git a/tests/testsuite/fix.rs b/tests/testsuite/fix.rs index 68c41c602fa..b4d411f781c 100644 --- a/tests/testsuite/fix.rs +++ b/tests/testsuite/fix.rs @@ -1864,7 +1864,7 @@ fn non_edition_lint_migration() { ... [..]use std::str::from_utf8; ... - = [NOTE] `#[warn(unused_imports)]` on by default + = [NOTE] `#[warn(unused_imports)]` [..]on by default ... "#]]) .run(); diff --git a/tests/testsuite/warning_override.rs b/tests/testsuite/warning_override.rs index 95dcfed0c6c..f4469b53599 100644 --- a/tests/testsuite/warning_override.rs +++ b/tests/testsuite/warning_override.rs @@ -48,7 +48,7 @@ fn rustc_caching_allow_first() { 1 | fn main() { let x = 3; } | ^ [HELP] if this is intentional, prefix it with an underscore: `_x` | - = [NOTE] `#[warn(unused_variables)]` on by default + = [NOTE] `#[warn(unused_variables)]` [..]on by default [WARNING] `foo` (bin "foo") generated 1 warning [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -75,7 +75,7 @@ fn rustc_caching_deny_first() { 1 | fn main() { let x = 3; } | ^ [HELP] if this is intentional, prefix it with an underscore: `_x` | - = [NOTE] `#[warn(unused_variables)]` on by default + = [NOTE] `#[warn(unused_variables)]` [..]on by default [WARNING] `foo` (bin "foo") generated 1 warning [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -112,7 +112,7 @@ fn config() { 1 | fn main() { let x = 3; } | ^ [HELP] if this is intentional, prefix it with an underscore: `_x` | - = [NOTE] `#[warn(unused_variables)]` on by default + = [NOTE] `#[warn(unused_variables)]` [..]on by default [WARNING] `foo` (bin "foo") generated 1 warning [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -136,7 +136,7 @@ fn config() { 1 | fn main() { let x = 3; } | ^ [HELP] if this is intentional, prefix it with an underscore: `_x` | - = [NOTE] `#[warn(unused_variables)]` on by default + = [NOTE] `#[warn(unused_variables)]` [..]on by default [WARNING] `foo` (bin "foo") generated 1 warning [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -160,7 +160,7 @@ fn requires_nightly() { 1 | fn main() { let x = 3; } | ^ [HELP] if this is intentional, prefix it with an underscore: `_x` | - = [NOTE] `#[warn(unused_variables)]` on by default + = [NOTE] `#[warn(unused_variables)]` [..]on by default [WARNING] `foo` (bin "foo") generated 1 warning [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s From cec8eb1d161d7be96689a9dbc6e47a8f788a754b Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Sun, 17 Aug 2025 15:03:54 +0200 Subject: [PATCH 2/2] bump rustfix version to 0.9.3 --- Cargo.lock | 2 +- crates/rustfix/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 813904f5023..7c8f3ef2bd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3794,7 +3794,7 @@ checksum = "781442f29170c5c93b7185ad559492601acdc71d5bb0706f5868094f45cfcd08" [[package]] name = "rustfix" -version = "0.9.2" +version = "0.9.3" dependencies = [ "anyhow", "proptest", diff --git a/crates/rustfix/Cargo.toml b/crates/rustfix/Cargo.toml index 451acd4fc93..3e1de8d1b65 100644 --- a/crates/rustfix/Cargo.toml +++ b/crates/rustfix/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustfix" -version = "0.9.2" +version = "0.9.3" authors = [ "Pascal Hertleif ", "Oliver Schneider ",