diff --git a/Cargo.lock b/Cargo.lock index a6b931e..181d848 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "cargo_pup" -version = "0.1.3" +version = "0.1.4" dependencies = [ "ansi_term", "anyhow", @@ -157,7 +157,7 @@ dependencies = [ [[package]] name = "cargo_pup_common" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "cargo_metadata", @@ -168,7 +168,7 @@ dependencies = [ [[package]] name = "cargo_pup_lint_config" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "cargo_pup_common", @@ -179,7 +179,7 @@ dependencies = [ [[package]] name = "cargo_pup_lint_impl" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "cargo_pup_common", diff --git a/Cargo.toml b/Cargo.toml index ad47940..053c63f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ exclude = ["test_app"] [package] name = "cargo_pup" -version = "0.1.3" +version = "0.1.4" edition = "2024" description = "A Rust architectural linting tool that integrates with rustc to enforce architectural patterns and boundaries" license = "Apache-2.0" @@ -34,9 +34,9 @@ anyhow = { workspace = true } tempfile = { workspace = true } ron = { workspace = true } cargo_metadata = { workspace = true } -cargo_pup_common = { path = "cargo_pup_common", version = "=0.1.3" } -cargo_pup_lint_impl = { path = "cargo_pup_lint_impl", version = "=0.1.3" } -cargo_pup_lint_config = { path = "cargo_pup_lint_config", version = "=0.1.3" } +cargo_pup_common = { path = "cargo_pup_common", version = "=0.1.4" } +cargo_pup_lint_impl = { path = "cargo_pup_lint_impl", version = "=0.1.4" } +cargo_pup_lint_config = { path = "cargo_pup_lint_config", version = "=0.1.4" } # # These bits are just to keep rust rover happy. diff --git a/README.md b/README.md index 3e106a7..35a4355 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ First, make sure to install [rustup](https://rustup.rs/) to manage your local ru Then install pup; **you must use this nightly toolchain, as pup depends on compiler internals that are otherwise unavailable!** ```bash -rustup component add --toolchain nightly-2025-07-25 rust-src rustc-dev llvm-tools-preview -cargo +nightly-2025-07-25 install cargo_pup +rustup component add --toolchain nightly-2025-11-14 rust-src rustc-dev llvm-tools-preview +cargo +nightly-2025-11-14 install cargo_pup ``` ## Getting Started @@ -121,7 +121,7 @@ First, add the following to your `Cargo.toml`: ```toml [dev-dependencies] -cargo_pup_lint_config = "0.1.3" +cargo_pup_lint_config = "0.1.4" ``` ## Examples diff --git a/cargo_pup_common/Cargo.toml b/cargo_pup_common/Cargo.toml index 9519758..709957c 100644 --- a/cargo_pup_common/Cargo.toml +++ b/cargo_pup_common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo_pup_common" -version = "0.1.3" +version = "0.1.4" edition = "2024" description = "Common utilities and shared components for cargo-pup architectural linting tool" license = "Apache-2.0" diff --git a/cargo_pup_lint_config/Cargo.toml b/cargo_pup_lint_config/Cargo.toml index 51d81d2..fd74d27 100644 --- a/cargo_pup_lint_config/Cargo.toml +++ b/cargo_pup_lint_config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo_pup_lint_config" -version = "0.1.3" +version = "0.1.4" edition = "2024" description = "Configuration and rule builder utilities for cargo-pup architectural linting" license = "Apache-2.0" @@ -13,4 +13,4 @@ serde.workspace = true ron.workspace = true tempfile.workspace = true anyhow.workspace = true -cargo_pup_common = { path = "../cargo_pup_common", version = "=0.1.3" } +cargo_pup_common = { path = "../cargo_pup_common", version = "=0.1.4" } diff --git a/cargo_pup_lint_config/README.md b/cargo_pup_lint_config/README.md index ad39edf..7ce883d 100644 --- a/cargo_pup_lint_config/README.md +++ b/cargo_pup_lint_config/README.md @@ -24,7 +24,7 @@ Add this to your `Cargo.toml`: ```toml [dev-dependencies] -cargo_pup_lint_config = "0.1.3" +cargo_pup_lint_config = "0.1.4" ``` ## Example diff --git a/cargo_pup_lint_impl/Cargo.toml b/cargo_pup_lint_impl/Cargo.toml index 9a366a2..5d8e383 100644 --- a/cargo_pup_lint_impl/Cargo.toml +++ b/cargo_pup_lint_impl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo_pup_lint_impl" -version = "0.1.3" +version = "0.1.4" edition = "2024" description = "Core lint implementations and rustc integration for cargo-pup architectural linting" license = "Apache-2.0" @@ -9,8 +9,8 @@ homepage = "https://github.com/datadog/cargo-pup" readme = "README.md" [dependencies] -cargo_pup_lint_config = { path = "../cargo_pup_lint_config", version = "=0.1.3" } -cargo_pup_common = { path = "../cargo_pup_common", version = "=0.1.3" } +cargo_pup_lint_config = { path = "../cargo_pup_lint_config", version = "=0.1.4" } +cargo_pup_common = { path = "../cargo_pup_common", version = "=0.1.4" } anyhow.workspace = true regex.workspace = true serde_json.workspace = true diff --git a/cargo_pup_lint_impl/src/helpers/architecture_lint_runner.rs b/cargo_pup_lint_impl/src/helpers/architecture_lint_runner.rs index 71a2f91..132c4c8 100644 --- a/cargo_pup_lint_impl/src/helpers/architecture_lint_runner.rs +++ b/cargo_pup_lint_impl/src/helpers/architecture_lint_runner.rs @@ -192,7 +192,7 @@ impl ArchitectureLintRunner { { // This is a trait implementation // Get the canonical trait name using the centralized helper - let trait_def_id = trait_ref.path.res.def_id(); + let trait_def_id = trait_ref.trait_ref.path.res.def_id(); let canonical_full_name = crate::helpers::queries::get_full_canonical_trait_name_from_def_id( &tcx, @@ -326,8 +326,6 @@ impl Callbacks for ArchitectureLintRunner { _compiler: &rustc_interface::interface::Compiler, _tcx: TyCtxt<'_>, ) -> rustc_driver::Compilation { - _compiler.sess.coverage_discard_all_spans_in_codegen(); - rustc_driver::Compilation::Continue } } diff --git a/cargo_pup_lint_impl/src/lints/function_lint/lint.rs b/cargo_pup_lint_impl/src/lints/function_lint/lint.rs index cb33f84..fd55646 100644 --- a/cargo_pup_lint_impl/src/lints/function_lint/lint.rs +++ b/cargo_pup_lint_impl/src/lints/function_lint/lint.rs @@ -22,7 +22,11 @@ fn get_self_type<'tcx>( fn_def_id: rustc_hir::def_id::DefId, ) -> Option> { ctx.tcx - .impl_of_method(fn_def_id) + .opt_associated_item(fn_def_id) + .and_then(|assoc_item| { + // Check if this associated item is from an impl block + assoc_item.impl_container(ctx.tcx) + }) .map(|impl_def_id| ctx.tcx.type_of(impl_def_id).instantiate_identity()) } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e023780..6124969 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-07-25" +channel = "nightly-2025-11-14" components = ["llvm-tools-preview", "rustc-dev", "rust-analyzer", "rust-src"]