Skip to content

Commit 31644e3

Browse files
committed
Account for API changes
1 parent 783f7dc commit 31644e3

41 files changed

Lines changed: 217 additions & 84 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ level = "deny"
7777
check-cfg = [
7878
"cfg(coverage)",
7979
"cfg(dylint_lib, values(any()))",
80+
"cfg(nightly)",
8081
"cfg(__cargo_cli)",
8182
"cfg(__cargo_lib)",
8283
"cfg(__library_packages)",

clippy.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ disallowed-methods = [
22
{ path = "std::process::Command::output", reason = "use `CommandExt::logged_output`" },
33
{ path = "std::result::Result::expect", reason = "hides errors; use `unwrap_or_else(|error| panic!(...))`" },
44
]
5+
# smoelius: Dylint's MSRV is actually 1.81. But some of the lints need 1.82 for `is_none_or` and
6+
# `is_some_and`.
7+
msrv = "1.82"

dylint/src/package_options/auto_correct/highlight.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub struct Highlight {
3636
pub is_primary: bool,
3737
}
3838

39+
#[allow(clippy::missing_fields_in_debug)]
3940
impl std::fmt::Debug for Highlight {
4041
#[cfg_attr(dylint_lib = "general", allow(non_local_effect_before_error_return))]
4142
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

dylint/src/package_options/auto_correct/rewrite/diff.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub(super) fn patches_from_diff<'repo>(diff: &Diff<'repo>) -> Result<Vec<Patch<'
6565
.map(|idx| -> Result<_> {
6666
let patch = Patch::from_diff(diff, idx)?;
6767
// smoelius: Only return patches for Rust source files.
68+
#[allow(clippy::nonminimal_bool)]
6869
if !patch
6970
.as_ref()
7071
.and_then(|patch| patch.delta().old_file().path())

examples/general/Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/general/await_holding_span_guard/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ path = "ui/main.rs"
1616
[dependencies]
1717
clippy_utils = { workspace = true }
1818

19+
dylint_internal = { path = "../../../internal", features = ["match_def_path"] }
1920
dylint_linting = { path = "../../../utils/linting" }
2021

2122
[dev-dependencies]

examples/general/await_holding_span_guard/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate rustc_hir;
55
extern crate rustc_middle;
66

77
use clippy_utils::diagnostics::span_lint_and_then;
8-
use clippy_utils::match_def_path;
8+
use dylint_internal::match_def_path;
99
use rustc_hir as hir;
1010
use rustc_hir::def_id::DefId;
1111
use rustc_lint::{LateContext, LateLintPass};

examples/general/incorrect_matches_operation/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
extern crate rustc_ast;
66
extern crate rustc_span;
77

8-
use clippy_utils::{diagnostics::span_lint, sym};
8+
use clippy_utils::diagnostics::span_lint;
99
use rustc_ast::{
1010
BinOpKind, Expr, ExprKind, MacCall, ptr::P, token::Token, token::TokenKind,
1111
tokenstream::TokenTree,
1212
};
1313
use rustc_lint::{EarlyContext, EarlyLintPass};
14+
use rustc_span::Symbol;
1415

1516
dylint_linting::declare_pre_expansion_lint! {
1617
/// ### What it does
@@ -65,7 +66,7 @@ dylint_linting::declare_pre_expansion_lint! {
6566

6667
fn is_matches_macro(expr: &P<Expr>) -> Option<&P<MacCall>> {
6768
if let ExprKind::MacCall(mac) = &expr.kind // must be a macro call
68-
&& mac.path == sym!(matches)
69+
&& mac.path == Symbol::intern("matches")
6970
// must be a matches! symbol
7071
{
7172
return Some(mac);

examples/general/non_local_effect_before_error_return/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ path = "ui_public_only/main.rs"
2121
clippy_utils = { workspace = true }
2222
serde = { workspace = true, features = ["derive"] }
2323

24+
dylint_internal = { path = "../../../internal", features = ["match_def_path"] }
2425
dylint_linting = { path = "../../../utils/linting" }
2526

2627
[dev-dependencies]

examples/general/non_local_effect_before_error_return/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ extern crate rustc_index;
1010
extern crate rustc_middle;
1111
extern crate rustc_span;
1212

13-
use clippy_utils::{diagnostics::span_lint_and_then, match_def_path};
13+
use clippy_utils::{
14+
diagnostics::span_lint_and_then,
15+
paths::{PathLookup, PathNS},
16+
type_path,
17+
};
18+
use dylint_internal::match_def_path;
1419
use rustc_errors::Diag;
1520
use rustc_hir::{def_id::LocalDefId, intravisit::FnKind};
1621
use rustc_index::bit_set::DenseBitSet;
@@ -221,6 +226,8 @@ fn in_async_function(tcx: ty::TyCtxt<'_>, hir_id: rustc_hir::HirId) -> bool {
221226
})
222227
}
223228

229+
static CORE_FMT_ERROR: PathLookup = type_path!(core::fmt::Error);
230+
224231
fn is_lintable_result(cx: &LateContext<'_>, ty: ty::Ty) -> bool {
225232
if let ty::Adt(adt, substs) = ty.kind() {
226233
if !cx.tcx.is_diagnostic_item(sym::Result, adt.did()) {
@@ -230,7 +237,7 @@ fn is_lintable_result(cx: &LateContext<'_>, ty: ty::Ty) -> bool {
230237
// Don't lint if the error type is core::fmt::Error
231238
if let Some(error_ty) = substs.get(1)
232239
&& let ty::Adt(error_adt, _) = error_ty.expect_ty().kind()
233-
&& match_def_path(cx, error_adt.did(), &["core", "fmt", "Error"])
240+
&& CORE_FMT_ERROR.matches(cx, error_adt.did())
234241
{
235242
return false;
236243
}

0 commit comments

Comments
 (0)