Skip to content
Back to skills

Rust Knowledge Patch

ASecurity

Rust

  • 25 stars
  • 0 votes
  • 0 copies
  • 19 views
  • Added February 7, 2026
developmentrustgoexpressapidocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill rust-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rust Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rust Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-rust-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-rust-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rust-knowledge-patch
description: Rust
version: "1.100.1"
license: MIT
metadata:
  author: Nevaberry
---


# Rust compatibility guidance

Load this skill when migrating Rust code, diagnosing changed compiler or Cargo
behavior, or selecting standard-library APIs. The quick reference prioritizes
breaking changes and deprecations. Use the topic references for detailed
conditions, examples, and version attribution.

## Reference index

| Reference | Topics |
| --- | --- |
| [Cargo](references/cargo.md) | Configuration, resolution, lockfiles, workspaces, build scripts, packaging, registries, caches, installation, reports |
| [Documentation, tests, and formatting](references/docs-tests-and-formatting.md) | Doctests, test harnesses, rustdoc generation and search, rustfmt module discovery |
| [Rust 2024 edition](references/edition-2024.md) | Migration, captures, temporaries, unsafe operations, manifests, edition-sensitive docs and formatting |
| [Language and macros](references/language-and-macros.md) | Traits, never types, macros, imports, diagnostics, patterns, lifetimes, const evaluation |
| [Safety, FFI, and low-level programming](references/safety-ffi-and-low-level.md) | Pointer validity, provenance, ABIs, layouts, symbols, CPU features, assembly, atomic alignment |
| [Standard library](references/standard-library.md) | Collections, allocation, ranges, formatting, atomics, processes, files, threads, const APIs |
| [Targets and toolchains](references/targets-and-toolchains.md) | Compiler fixes, flags, linking, WebAssembly, LLVM, CPU baselines, target availability |

## Breaking changes and regression fixes

### Compiler regressions

Rust 1.98.0 could emit a null pointer where a trait-object vtable needed a method
pointer, causing undefined behavior that could manifest as a segmentation fault.
Rebuild with Rust 1.98.1 to pick up the fix.

Rust 1.97.1 fixes an LLVM optimization that could generate incorrect code, present
since at least Rust 1.87. It also disables the Rust 1.97.0 code generation change
that made the miscompilation more likely. Rust 1.100.1 restores recognition of
valid `Iterator` implementations that Rust 1.100.0 could fail to infer.

### Never-type inference

In editions 2015, 2018, and 2021, an otherwise unconstrained never-to-any coercion
now falls back to `!`. Specify `()` explicitly where code relied on unit fallback.
`dependency_on_unit_never_type_fallback` is deny-by-default;
`never_type_fallback_flowing_into_unsafe` is also deny-by-default in pre-2024
editions. A direct build can use `#[allow(...)]` to override either lint.

### Macro compatibility

A `macro_rules!` matcher metavariable without a fragment specifier is a hard
error; use a specifier such as `$value:expr` or `$name:ident`. The check also
rejects invalid bindings in macros that are never invoked. Some substitutions
fail where an expansion expects a token; capturing the input as `tt` can fix them.
`semicolon_in_expressions_from_macros` is deny-by-default. End a value-producing
expansion with its value expression, as in `macro_rules! value { () => { 42 }; }`.

### Pointer validity and implicit references

`dangerous_implicit_autorefs` catches operations such as `(*ptr)[0]` on a raw slice
pointer, where indexing implicitly borrows the pointee. If the pointee can validly
be borrowed, make the borrow explicit with `(&*ptr)[0]`. The lint becomes
deny-by-default in 1.89.

With debug assertions enabled, nonzero-sized reads and writes through null raw
pointers and reborrows forming references from them cause a non-unwinding panic.
A dependency gets these checks only if it was itself built with debug assertions.
The standard-library definition of a pointer valid for reading or writing excludes
null even for zero-byte accesses; individual methods can explicitly allow it.

A raw trait-object pointer can upcast to a raw pointer to a supertrait in safe
code. Keep its vtable valid: an upcast can use it without dereferencing the data
pointer. Raw pointer casts cannot add trait-object auto traits; keep required
auto traits in the original trait object type before casting.

### FFI and compiler settings

Unsupported calling conventions are hard errors in function declarations and
function pointer types. Use `#[cfg(...)]` to restrict declarations to supported
targets. With `panic=unwind`, drop glue runs while unwinding inside an `extern "C"`
function, but a panic reaching the C ABI boundary still aborts the process.

Custom JSON targets require nightly and `-Z unstable-options` alongside `--target`;
with Cargo, pass `-Z json-target-spec` on nightly. Stable rustc uses v0 symbol
mangling by default, which can affect older debugger and profiler demanglers.
Selecting legacy mangling requires nightly.

## Deprecations and removed interfaces

| Affected interface | Supported guidance |
| --- | --- |
| `Eq::assert_receiver_is_total_eq` | Deprecated; overriding it triggers a future-compatibility warning. Omit it from manual `Eq` implementations. |
| Module-level `std::char` constants and functions | Use primitive `char` associated items such as `char::MAX` and `char::from_u32(n)`. |
| Legacy `std::intrinsics` pointer operations | Use corresponding `std::ptr` functions for `copy`, `copy_nonoverlapping`, and `write_bytes`; use `std::ptr::drop_in_place` for the removed intrinsic. |
| `#![doc(document_private_items)]` | Use `cargo doc --document-private-items` or pass `--document-private-items` to rustdoc. |
| Libtest `--nocapture` | Use `cargo test -- --no-capture` to stream output. |
| Libtest `--logfile` | Deprecated. |
| Positional `cargo login` token | Run `cargo login` and supply the token at its prompt. |
| `cargo publish --token` | Soft-deprecated; use `cargo login` with the registry's credential provider. |
| Nightly Cargo `--out-dir` | Use `cargo +nightly build -Z unstable-options --artifact-dir dist`. |
| Nightly Cargo `build-plan` | Use `--unit-graph` for the build unit graph or `-Zbuild-analysis` for recorded build events. |

## Rust 2024 migration

Review `cargo fix` changes. Keep the `expr` matcher if it should also accept
`const` blocks and `_`; keep `if let` if its temporaries should drop before `else`.
Add same-crate test invocations for exported `macro_rules!` arms before running
`cargo fix --edition`. Review syntax generated by procedural macros and build
scripts separately for compatibility with the new edition.

Rust 2024 rejects a member's `default-features = false` when the dependency in
`[workspace.dependencies]` has defaults enabled. `cargo fix --edition` removes
the ignored member setting; disable defaults on the workspace dependency itself.

`boxed.into_iter()` consumes a `Box<[T]>` in Rust 2024. Use `boxed.iter()` to keep
borrowing its elements when migrating. The deprecated Unix
`CommandExt::before_exec` becomes unsafe; use `CommandExt::pre_exec` and audit
the closure against its safety requirements.

## Cargo configuration and dependency resolution

### Warning policy and lint scope

`build.warnings` accepts `allow` to hide local-package lint warnings, `warn` to
display them without failing the build, or `deny` to fail the build. The default
is `warn`; changing the policy preserves the build cache. For one CI invocation:

```sh
CARGO_BUILD_WARNINGS=deny cargo check --keep-going
```

`cargo::unused_dependencies` warns by default on stable Cargo and is configurable
in `Cargo.toml`. Cargo reports it only when the invocation builds every target
that could use the dependency entry, and it skips development dependencies.

### Configuration and artifact locations

The top-level `include` key loads additional Cargo configuration files;
`optional = true` allows a file to be absent. Program-and-argument settings merge
as a unit: a higher-precedence `target.<triple>.runner` array replaces the whole
lower-precedence command.

`build.build-dir` selects the intermediate artifact directory. `cargo metadata`
exposes it as `build_directory`; `target_directory` identifies final output.
Cargo's build directory groups intermediate artifacts by build step and puts the
build-configuration hash in the parent directory. Hard-coded paths may need updating.

`resolver.lockfile-path` allows a lockfile outside the workspace, including with
read-only sources. The experimental `--lockfile-path` switch was removed in the
Cargo 1.95 release cycle; `cargo install` ignores the configuration setting as of
the Cargo 1.96 release cycle.

### Publication age and publishing

Set `registry.global-min-publish-age` in `.cargo/config.toml` to hold back newly
published versions during resolution. It applies to versions with registry
publication timestamps. `cargo install` bypasses it for both the installed crate
and its dependencies. A one-off precise update can allow the newer version:

```sh
CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo update clap --precise 4.6.9
```

Cargo records that version in `Cargo.lock` until re-resolution. Workspace
publishing uses dependency order and verifies builds against all packages,
including during a dry run. A failed upload can leave earlier crates published.

## Library and language APIs

### Allocators and cleanup

`std::alloc::Allocator` is stable with implementations for `Global`, `System`,
and references and smart pointers to allocators. Stable `Box<T, A>` and
`Vec<T, A>` APIs include selected `_in` constructors and raw conversions carrying
the allocator alongside the pointer.

`core::mem::DropGuard::new(value, cleanup)` provides `Deref` and `DerefMut` access,
then passes the value to cleanup on drop, including early return or unwinding.
`DropGuard::dismiss(guard)` consumes the guard, returning the value without cleanup.
`Box::take` extracts the value while retaining the allocation as `Box<MaybeUninit<T>>`.

### Slices, ranges, and atomic updates

`slice.array_windows()` yields overlapping `&[T; N]` windows; a closure's array
pattern can supply the const length. `get_disjoint_mut` accepts an array of
disjoint inclusive ranges to borrow several subslices at once.

New `core::range` bounds have separate iterator types. Construct the new bounds
explicitly and accept `impl core::ops::RangeBounds<usize>` in slice APIs that
should also take range literals, which still produce `core::ops` types.
Converting an exhausted legacy inclusive range with `std::range::RangeInclusive::from`
can panic; convert before iteration when the original bounds are needed.

Atomic pointers, booleans, and integers offer `update` and `try_update`.
The latter allows the closure to return `None` to skip the write. Under contention,
the closure may run more than once. `RwLockWriteGuard::downgrade(guard)` atomically
converts a write guard to a read guard, preventing another writer during transition.

### Configuration selection and match guards

`cfg_select!` expands to the right-hand side of the first matching predicate;
use `_` as a fallback. The selected arm can supply an expression or items.
An `if let` match guard can bind values for the arm body and refer to arm-pattern
bindings. Guarded arms do not count toward match exhaustiveness.

## Documentation and tests

`cargo test --doc --target <triple>` runs target doctests. Set
`target.<triple>.runner` to use an emulator or another target runner.
`cargo test --doc --no-run` is an error; `cargo test --doc` compiles and runs them.

Rustdoc can combine Rust 2024 doctests, changing source locations and paths
reported by `std::any::type_name`. Use `standalone_crate` on a doctest's opening
fence when it depends on those values. `cargo fix` and `cargo clippy --fix` use
ordinary target selection; pass `--all-targets` to include examples, tests, and
benches. `cargo fix --edition` still selects all targets by default.

Files in this skill

  • SKILL.md4.8 KB
  • references/assembly-and-simd.md1.8 KB
  • references/async-and-concurrency.md2 KB
  • references/cargo-and-tooling.md664 B
  • references/collections.md2.6 KB
  • references/edition-2024.md1.9 KB
  • references/integers-and-arithmetic.md2.4 KB
  • references/io-and-process.md1.4 KB
  • references/misc-apis.md3.9 KB
  • references/pointers-and-memory.md2.8 KB
  • references/slices-and-arrays.md1.9 KB
  • references/strings-and-paths.md2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.