Skip to content

Commit 57876c0

Browse files
committed
Run CI checks for Rust 2024 as well
4 parents a304709 + 540e116 + 0c1ef98 + 8052451 commit 57876c0

40 files changed

+297
-93
lines changed

.github/workflows/clippy.yml

+49
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,52 @@ jobs:
7373
run: .github/driver.sh
7474
env:
7575
OS: ${{ runner.os }}
76+
77+
base-2024:
78+
# NOTE: If you modify this job, make sure you copy the changes to clippy_bors.yml
79+
runs-on: ubuntu-latest
80+
81+
steps:
82+
# Setup
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
86+
- name: Select Rust 2024 edition
87+
run: |
88+
for i in clippy_config clippy_dev clippy_lints clippy_utils lintcheck; do
89+
sed -i \
90+
-e '1icargo-features = ["edition2024"]' \
91+
-e 's/edition = "2021"/edition = "2024"/' \
92+
$i/Cargo.toml
93+
done
94+
95+
- name: Install toolchain
96+
run: rustup show active-toolchain
97+
98+
# Run
99+
- name: Build
100+
run: cargo build --tests --features internal
101+
102+
- name: Test
103+
run: cargo test --features internal
104+
105+
- name: Test clippy_lints
106+
run: cargo test --features internal
107+
working-directory: clippy_lints
108+
109+
- name: Test clippy_utils
110+
run: cargo test
111+
working-directory: clippy_utils
112+
113+
- name: Test rustc_tools_util
114+
run: cargo test
115+
working-directory: rustc_tools_util
116+
117+
- name: Test clippy_dev
118+
run: cargo test
119+
working-directory: clippy_dev
120+
121+
- name: Test clippy-driver
122+
run: .github/driver.sh
123+
env:
124+
OS: ${{ runner.os }}

.github/workflows/clippy_bors.yml

+17
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,19 @@ jobs:
5757
include:
5858
- os: ubuntu-latest
5959
host: x86_64-unknown-linux-gnu
60+
edition: 2021
61+
- os: ubuntu-latest
62+
host: x86_64-unknown-linux-gnu
63+
edition: 2024
6064
- os: ubuntu-latest
6165
host: i686-unknown-linux-gnu
66+
edition: 2021
6267
- os: windows-latest
6368
host: x86_64-pc-windows-msvc
69+
edition: 2021
6470
- os: macos-13
6571
host: x86_64-apple-darwin
72+
edition: 2021
6673

6774
runs-on: ${{ matrix.os }}
6875

@@ -79,6 +86,16 @@ jobs:
7986
sudo apt-get update
8087
sudo apt-get install gcc-multilib zlib1g-dev:i386
8188
89+
- name: Select Rust 2024 edition
90+
if: matrix.edition == 2024
91+
run: |
92+
for i in clippy_config clippy_dev clippy_lints clippy_utils lintcheck; do
93+
sed -i \
94+
-e '1icargo-features = ["edition2024"]' \
95+
-e 's/edition = "2021"/edition = "2024"/' \
96+
$i/Cargo.toml
97+
done
98+
8299
- name: Install toolchain
83100
run: |
84101
rustup set default-host ${{ matrix.host }}

clippy_lints/src/checked_conversions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ fn get_types_from_cast<'a>(
232232
// or `to_type::MAX as from_type`
233233
let call_from_cast: Option<(&Expr<'_>, &str)> = if let ExprKind::Cast(limit, from_type) = &expr.kind
234234
// to_type::max_value(), from_type
235-
&& let TyKind::Path(ref from_type_path) = &from_type.kind
235+
&& let TyKind::Path(from_type_path) = &from_type.kind
236236
&& let Some(from_sym) = int_ty_to_sym(from_type_path)
237237
{
238238
Some((limit, from_sym))
@@ -245,7 +245,7 @@ fn get_types_from_cast<'a>(
245245
if let ExprKind::Call(from_func, [limit]) = &expr.kind
246246
// `from_type::from, to_type::max_value()`
247247
// `from_type::from`
248-
&& let ExprKind::Path(ref path) = &from_func.kind
248+
&& let ExprKind::Path(path) = &from_func.kind
249249
&& let Some(from_sym) = get_implementing_type(path, INTS, "from")
250250
{
251251
Some((limit, from_sym))

clippy_lints/src/copy_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare_lint_pass!(CopyIterator => [COPY_ITERATOR]);
3737
impl<'tcx> LateLintPass<'tcx> for CopyIterator {
3838
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
3939
if let ItemKind::Impl(Impl {
40-
of_trait: Some(ref trait_ref),
40+
of_trait: Some(trait_ref),
4141
..
4242
}) = item.kind
4343
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()

clippy_lints/src/derivable_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn check_enum<'tcx>(cx: &LateContext<'tcx>, item: &'tcx Item<'_>, func_expr: &Ex
187187
impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
188188
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
189189
if let ItemKind::Impl(Impl {
190-
of_trait: Some(ref trait_ref),
190+
of_trait: Some(trait_ref),
191191
items: [child],
192192
self_ty,
193193
..

clippy_lints/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ declare_lint_pass!(Derive => [
202202
impl<'tcx> LateLintPass<'tcx> for Derive {
203203
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
204204
if let ItemKind::Impl(Impl {
205-
of_trait: Some(ref trait_ref),
205+
of_trait: Some(trait_ref),
206206
..
207207
}) = item.kind
208208
{

clippy_lints/src/disallowed_script_idents.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl EarlyLintPass for DisallowedScriptIdents {
8080
let mut symbols: Vec<_> = symbols.iter().collect();
8181
symbols.sort_unstable_by_key(|k| k.1);
8282

83-
for (symbol, &span) in &symbols {
83+
for &(symbol, &span) in &symbols {
8484
// Note: `symbol.as_str()` is an expensive operation, thus should not be called
8585
// more than once for a single symbol.
8686
let symbol_str = symbol.as_str();

clippy_lints/src/empty_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ declare_lint_pass!(EmptyDrop => [EMPTY_DROP]);
3636
impl LateLintPass<'_> for EmptyDrop {
3737
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
3838
if let ItemKind::Impl(Impl {
39-
of_trait: Some(ref trait_ref),
39+
of_trait: Some(trait_ref),
4040
items: [child],
4141
..
4242
}) = item.kind

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
629629
.filter_by_name_unhygienic(is_empty)
630630
.any(|item| is_is_empty(cx, item))
631631
}),
632-
ty::Alias(ty::Projection, ref proj) => has_is_empty_impl(cx, proj.def_id),
632+
ty::Alias(ty::Projection, proj) => has_is_empty_impl(cx, proj.def_id),
633633
ty::Adt(id, _) => has_is_empty_impl(cx, id.did()),
634634
ty::Array(..) | ty::Slice(..) | ty::Str => true,
635635
_ => false,

clippy_lints/src/lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'tcx> Visitor<'tcx> for RefVisitor<'_, 'tcx> {
425425
self.visit_opaque_ty(opaque);
426426
self.lts.truncate(len);
427427
self.lts.extend(bounds.iter().filter_map(|bound| match bound {
428-
GenericArg::Lifetime(&l) => Some(l),
428+
&GenericArg::Lifetime(l) => Some(l),
429429
_ => None,
430430
}));
431431
},

clippy_lints/src/manual_async_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
169169
}
170170

171171
fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>) -> Option<&'tcx Body<'tcx>> {
172-
if let Some(Expr {
172+
if let Some(&Expr {
173173
kind: ExprKind::Closure(&Closure { kind, body, .. }),
174174
..
175175
}) = block.expr

clippy_lints/src/matches/match_like_matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn find_bool_lit(ex: &ExprKind<'_>) -> Option<bool> {
148148
}) => Some(*b),
149149
ExprKind::Block(
150150
rustc_hir::Block {
151-
stmts: &[],
151+
stmts: [],
152152
expr: Some(exp),
153153
..
154154
},

clippy_lints/src/matches/redundant_pattern_match.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,9 @@ fn found_good_method<'tcx>(
319319
node: (&PatKind<'_>, &PatKind<'_>),
320320
) -> Option<(&'static str, Option<&'tcx Expr<'tcx>>)> {
321321
match node {
322-
(
323-
PatKind::TupleStruct(ref path_left, patterns_left, _),
324-
PatKind::TupleStruct(ref path_right, patterns_right, _),
325-
) if patterns_left.len() == 1 && patterns_right.len() == 1 => {
322+
(PatKind::TupleStruct(path_left, patterns_left, _), PatKind::TupleStruct(path_right, patterns_right, _))
323+
if patterns_left.len() == 1 && patterns_right.len() == 1 =>
324+
{
326325
if let (PatKind::Wild, PatKind::Wild) = (&patterns_left[0].kind, &patterns_right[0].kind) {
327326
find_good_method_for_match(
328327
cx,
@@ -350,8 +349,8 @@ fn found_good_method<'tcx>(
350349
None
351350
}
352351
},
353-
(PatKind::TupleStruct(ref path_left, patterns, _), PatKind::Path(ref path_right))
354-
| (PatKind::Path(ref path_left), PatKind::TupleStruct(ref path_right, patterns, _))
352+
(PatKind::TupleStruct(path_left, patterns, _), PatKind::Path(path_right))
353+
| (PatKind::Path(path_left), PatKind::TupleStruct(path_right, patterns, _))
355354
if patterns.len() == 1 =>
356355
{
357356
if let PatKind::Wild = patterns[0].kind {
@@ -381,14 +380,14 @@ fn found_good_method<'tcx>(
381380
None
382381
}
383382
},
384-
(PatKind::TupleStruct(ref path_left, patterns, _), PatKind::Wild) if patterns.len() == 1 => {
383+
(PatKind::TupleStruct(path_left, patterns, _), PatKind::Wild) if patterns.len() == 1 => {
385384
if let PatKind::Wild = patterns[0].kind {
386385
get_good_method(cx, arms, path_left)
387386
} else {
388387
None
389388
}
390389
},
391-
(PatKind::Path(ref path_left), PatKind::Wild) => get_good_method(cx, arms, path_left),
390+
(PatKind::Path(path_left), PatKind::Wild) => get_good_method(cx, arms, path_left),
392391
_ => None,
393392
}
394393
}

clippy_lints/src/methods/filter_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fn is_method(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symbol) -> bool
2121
ExprKind::Path(QPath::TypeRelative(_, mname)) => mname.ident.name == method_name,
2222
ExprKind::Path(QPath::Resolved(_, segments)) => segments.segments.last().unwrap().ident.name == method_name,
2323
ExprKind::MethodCall(segment, _, _, _) => segment.ident.name == method_name,
24-
ExprKind::Closure(&Closure { body, .. }) => {
25-
let body = cx.tcx.hir().body(body);
24+
ExprKind::Closure(Closure { body, .. }) => {
25+
let body = cx.tcx.hir().body(*body);
2626
let closure_expr = peel_blocks(body.value);
2727
match closure_expr.kind {
2828
ExprKind::MethodCall(PathSegment { ident, .. }, receiver, ..) => {

clippy_lints/src/needless_late_init.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit {
347347
if let LetStmt {
348348
init: None,
349349
pat:
350-
&Pat {
350+
Pat {
351351
kind: PatKind::Binding(BindingMode::NONE, binding_id, _, None),
352352
..
353353
},
@@ -357,7 +357,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit {
357357
&& let Some((_, Node::Stmt(local_stmt))) = parents.next()
358358
&& let Some((_, Node::Block(block))) = parents.next()
359359
{
360-
check(cx, local, local_stmt, block, binding_id);
360+
check(cx, local, local_stmt, block, *binding_id);
361361
}
362362
}
363363
}

clippy_lints/src/needless_pass_by_ref_mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
183183
.iter()
184184
.zip(fn_sig.inputs())
185185
.zip(body.params)
186-
.filter(|((&input, &ty), arg)| !should_skip(cx, input, ty, arg))
186+
.filter(|&((&input, &ty), arg)| !should_skip(cx, input, ty, arg))
187187
.peekable();
188188
if it.peek().is_none() {
189189
return;

clippy_lints/src/no_mangle_with_rust_abi.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
2-
use clippy_utils::source::snippet_with_applicability;
2+
use clippy_utils::source::{snippet, snippet_with_applicability};
33
use rustc_errors::Applicability;
44
use rustc_hir::{Item, ItemKind};
55
use rustc_lint::{LateContext, LateLintPass};
@@ -18,13 +18,13 @@ declare_clippy_lint! {
1818
/// Rust ABI can break this at any point.
1919
///
2020
/// ### Example
21-
/// ```no_run
21+
/// ```rust,ignore
2222
/// #[no_mangle]
2323
/// fn example(arg_one: u32, arg_two: usize) {}
2424
/// ```
2525
///
2626
/// Use instead:
27-
/// ```no_run
27+
/// ```rust,ignore
2828
/// #[no_mangle]
2929
/// extern "C" fn example(arg_one: u32, arg_two: usize) {}
3030
/// ```
@@ -40,24 +40,25 @@ impl<'tcx> LateLintPass<'tcx> for NoMangleWithRustAbi {
4040
if let ItemKind::Fn(fn_sig, _, _) = &item.kind {
4141
let attrs = cx.tcx.hir().attrs(item.hir_id());
4242
let mut app = Applicability::MaybeIncorrect;
43-
let snippet = snippet_with_applicability(cx, fn_sig.span, "..", &mut app);
43+
let fn_snippet = snippet_with_applicability(cx, fn_sig.span, "..", &mut app);
4444
for attr in attrs {
4545
if let Some(ident) = attr.ident()
4646
&& ident.name == rustc_span::sym::no_mangle
4747
&& fn_sig.header.abi == Abi::Rust
48-
&& let Some((fn_attrs, _)) = snippet.split_once("fn")
48+
&& let Some((fn_attrs, _)) = fn_snippet.split_once("fn")
4949
&& !fn_attrs.contains("extern")
5050
{
5151
let sugg_span = fn_sig
5252
.span
5353
.with_lo(fn_sig.span.lo() + BytePos::from_usize(fn_attrs.len()))
5454
.shrink_to_lo();
55+
let attr_snippet = snippet(cx, attr.span, "..");
5556

5657
span_lint_and_then(
5758
cx,
5859
NO_MANGLE_WITH_RUST_ABI,
5960
fn_sig.span,
60-
"`#[no_mangle]` set on a function with the default (`Rust`) ABI",
61+
format!("`{attr_snippet}` set on a function with the default (`Rust`) ABI"),
6162
|diag| {
6263
diag.span_suggestion(sugg_span, "set an ABI", "extern \"C\" ", app)
6364
.span_suggestion(sugg_span, "or explicitly set the default", "extern \"Rust\" ", app);

clippy_lints/src/partialeq_ne_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_lint_pass!(PartialEqNeImpl => [PARTIALEQ_NE_IMPL]);
3434
impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl {
3535
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
3636
if let ItemKind::Impl(Impl {
37-
of_trait: Some(ref trait_ref),
37+
of_trait: Some(trait_ref),
3838
items: impl_items,
3939
..
4040
}) = item.kind

clippy_lints/src/question_mark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ enum IfBlockType<'hir> {
9393

9494
fn find_let_else_ret_expression<'hir>(block: &'hir Block<'hir>) -> Option<&'hir Expr<'hir>> {
9595
if let Block {
96-
stmts: &[],
96+
stmts: [],
9797
expr: Some(els),
9898
..
9999
} = block

clippy_lints/src/ref_option_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
3939
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
4040
if let TyKind::Ref(_, ref mut_ty) = ty.kind
4141
&& mut_ty.mutbl == Mutability::Not
42-
&& let TyKind::Path(ref qpath) = &mut_ty.ty.kind
42+
&& let TyKind::Path(qpath) = &mut_ty.ty.kind
4343
&& let last = last_path_segment(qpath)
4444
&& let Some(def_id) = last.res.opt_def_id()
4545
&& cx.tcx.is_diagnostic_item(sym::Option, def_id)

clippy_lints/src/returns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ fn check_final_expr<'tcx>(
347347
let peeled_drop_expr = expr.peel_drop_temps();
348348
match &peeled_drop_expr.kind {
349349
// simple return is always "bad"
350-
ExprKind::Ret(ref inner) => {
350+
ExprKind::Ret(inner) => {
351351
// check if expr return nothing
352352
let ret_span = if inner.is_none() && replacement == RetReplacement::Empty {
353353
extend_span_to_previous_non_ws(cx, peeled_drop_expr.span)

clippy_lints/src/serde_api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ declare_lint_pass!(SerdeApi => [SERDE_API_MISUSE]);
2626
impl<'tcx> LateLintPass<'tcx> for SerdeApi {
2727
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
2828
if let ItemKind::Impl(Impl {
29-
of_trait: Some(ref trait_ref),
29+
of_trait: Some(trait_ref),
3030
items,
3131
..
3232
}) = item.kind

clippy_lints/src/single_component_path_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl SingleComponentPathImports {
174174
}
175175

176176
match &item.kind {
177-
ItemKind::Mod(_, ModKind::Loaded(ref items, ..)) => {
177+
ItemKind::Mod(_, ModKind::Loaded(items, ..)) => {
178178
self.check_mod(items);
179179
},
180180
ItemKind::MacroDef(MacroDef { macro_rules: true, .. }) => {

0 commit comments

Comments
 (0)