Skip to content

Commit 94b6bdd

Browse files
committed
fix clippy tests
1 parent 7b6258b commit 94b6bdd

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

src/tools/clippy/clippy_config/src/msrvs.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ macro_rules! msrv_aliases {
1717

1818
// names may refer to stabilized feature flags or library items
1919
msrv_aliases! {
20-
1,81,0 { LINT_REASONS_STABILIZATION }
20+
1,82,0 { CONST_EXTERN_FN }
21+
1,81,0 { LINT_REASONS_STABILIZATION }
2122
1,80,0 { BOX_INTO_ITER}
2223
1,77,0 { C_STR_LITERALS }
2324
1,76,0 { PTR_FROM_REF, OPTION_RESULT_INSPECT }
@@ -26,7 +27,7 @@ msrv_aliases! {
2627
1,68,0 { PATH_MAIN_SEPARATOR_STR }
2728
1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS }
2829
1,63,0 { CLONE_INTO }
29-
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE, CONST_EXTERN_FN }
30+
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE, CONST_EXTERN_C_FN }
3031
1,59,0 { THREAD_LOCAL_CONST_INIT }
3132
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY, CONST_RAW_PTR_DEREF }
3233
1,56,0 { CONST_FN_UNION }

src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
119119
.iter()
120120
.any(|param| matches!(param.kind, GenericParamKind::Const { .. }));
121121

122-
if already_const(header)
123-
|| has_const_generic_params
124-
|| !could_be_const_with_abi(cx, &self.msrv, header.abi)
122+
if already_const(header) || has_const_generic_params || !could_be_const_with_abi(&self.msrv, header.abi)
125123
{
126124
return;
127125
}
@@ -183,13 +181,13 @@ fn already_const(header: hir::FnHeader) -> bool {
183181
header.constness == Constness::Const
184182
}
185183

186-
fn could_be_const_with_abi(cx: &LateContext<'_>, msrv: &Msrv, abi: Abi) -> bool {
184+
fn could_be_const_with_abi(msrv: &Msrv, abi: Abi) -> bool {
187185
match abi {
188186
Abi::Rust => true,
189187
// `const extern "C"` was stabilized after 1.62.0
190-
Abi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_FN),
188+
Abi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_C_FN),
191189
// Rest ABIs are still unstable and need the `const_extern_fn` feature enabled.
192-
_ => cx.tcx.features().const_extern_fn,
190+
_ => msrv.meets(msrvs::CONST_EXTERN_FN),
193191
}
194192
}
195193

src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,6 @@ mod msrv {
186186
extern "C" fn c() {}
187187
}
188188

189-
mod with_extern {
190-
extern "C-unwind" fn c_unwind() {}
191-
extern "system" fn system() {}
192-
extern "system-unwind" fn system_unwind() {}
193-
}
194-
195189
mod with_ty_alias {
196190
type Foo = impl std::fmt::Debug;
197191

src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![warn(clippy::missing_const_for_fn)]
22
#![allow(unsupported_calling_conventions)]
3-
#![feature(const_extern_fn)]
43

54
const extern "C-unwind" fn c_unwind() {}
65
//~^ ERROR: this could be a `const fn`

src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![warn(clippy::missing_const_for_fn)]
22
#![allow(unsupported_calling_conventions)]
3-
#![feature(const_extern_fn)]
43

54
extern "C-unwind" fn c_unwind() {}
65
//~^ ERROR: this could be a `const fn`

src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this could be a `const fn`
2-
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:5:1
2+
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:4:1
33
|
44
LL | extern "C-unwind" fn c_unwind() {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -12,7 +12,7 @@ LL | const extern "C-unwind" fn c_unwind() {}
1212
| +++++
1313

1414
error: this could be a `const fn`
15-
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:7:1
15+
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:6:1
1616
|
1717
LL | extern "system" fn system() {}
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL | const extern "system" fn system() {}
2323
| +++++
2424

2525
error: this could be a `const fn`
26-
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:9:1
26+
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:8:1
2727
|
2828
LL | extern "system-unwind" fn system_unwind() {}
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -34,7 +34,7 @@ LL | const extern "system-unwind" fn system_unwind() {}
3434
| +++++
3535

3636
error: this could be a `const fn`
37-
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:11:1
37+
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:10:1
3838
|
3939
LL | pub extern "stdcall" fn std_call() {}
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -45,7 +45,7 @@ LL | pub const extern "stdcall" fn std_call() {}
4545
| +++++
4646

4747
error: this could be a `const fn`
48-
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:13:1
48+
--> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:12:1
4949
|
5050
LL | pub extern "stdcall-unwind" fn std_call_unwind() {}
5151
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)