Skip to content

Commit 053882b

Browse files
committed
fixed msrv
1 parent 3bccd4b commit 053882b

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

clippy_lints/src/format_args.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ declare_clippy_lint! {
115115
impl_lint_pass!(FormatArgs => [FORMAT_IN_FORMAT_ARGS, NEEDLESS_FORMAT_ARGS, TO_STRING_IN_FORMAT_ARGS]);
116116

117117
pub struct FormatArgs {
118-
format_args_capture: bool,
118+
msrv: Option<RustcVersion>,
119119
}
120120

121121
impl FormatArgs {
122122
#[must_use]
123123
pub fn new(msrv: Option<RustcVersion>) -> Self {
124-
Self {
125-
format_args_capture: meets_msrv(msrv, msrvs::FORMAT_ARGS_CAPTURE),
126-
}
124+
Self { msrv }
127125
}
128126
}
129127

@@ -148,7 +146,7 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs {
148146
check_to_string_in_format_args(cx, name, arg.param.value);
149147
}
150148

151-
if !self.format_args_capture {
149+
if !meets_msrv(self.msrv, msrvs::FORMAT_ARGS_CAPTURE) {
152150
return;
153151
}
154152
let mut inline_spans = Vec::new();
@@ -173,6 +171,8 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs {
173171
}
174172
}
175173
}
174+
175+
extract_msrv_attr!(LateContext);
176176
}
177177

178178
fn check_inline(cx: &LateContext<'_>, param: &FormatParam<'_>, inline_spans: &mut Vec<(Span, String)>) -> bool {

clippy_lints/src/utils/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ define_Conf! {
213213
///
214214
/// Suppress lints whenever the suggested change would cause breakage for other crates.
215215
(avoid_breaking_exported_api: bool = true),
216-
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED.
216+
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, NEEDLESS_FORMAT_ARGS.
217217
///
218218
/// The minimum rust version that the project supports
219219
(msrv: Option<String> = None),

tests/ui/needless_format_args.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn main() {
125125
fn _under_msrv() {
126126
#![clippy::msrv = "1.57"]
127127
let local_i32 = 1;
128-
println!("don't expand='{local_i32}'");
128+
println!("don't expand='{}'", local_i32);
129129
}
130130

131131
fn _meets_msrv() {

tests/ui/needless_format_args.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -850,18 +850,6 @@ LL - println!("{}", format!("{}", local_i32));
850850
LL + println!("{}", format!("{local_i32}"));
851851
|
852852

853-
error: variables can be used directly in the `format!` string
854-
--> $DIR/needless_format_args.rs:131:5
855-
|
856-
LL | println!("don't expand='{}'", local_i32);
857-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
858-
|
859-
help: change this to
860-
|
861-
LL - println!("don't expand='{}'", local_i32);
862-
LL + println!("don't expand='{local_i32}'");
863-
|
864-
865853
error: variables can be used directly in the `format!` string
866854
--> $DIR/needless_format_args.rs:137:5
867855
|
@@ -874,5 +862,5 @@ LL - println!("expand='{}'", local_i32);
874862
LL + println!("expand='{local_i32}'");
875863
|
876864

877-
error: aborting due to 72 previous errors
865+
error: aborting due to 71 previous errors
878866

0 commit comments

Comments
 (0)