Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Rust Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-rust-knowledge-patch-nevaberry-plugins)
---
name: rust-knowledge-patch
description: Rust
version: "1.100.1"
license: MIT
metadata:
author: Nevaberry
---
# Rust Knowledge Patch
Load this skill when migrating Rust code, diagnosing compiler compatibility changes,
updating Cargo workflows, or using the library APIs described here.
Use the quick reference for common changes and the topic files for full conditions,
examples, platform details, and version-specific behavior.
## Reference index
| File | Topics |
| --- | --- |
| [Cargo](references/cargo.md) | Configuration, workspaces, resolution, registries, build scripts, caches, packaging, installation, reports |
| [Documentation, tests, and formatting](references/docs-tests-and-formatting.md) | Doctests, runners, test harnesses, rustdoc generation and search, formatting |
| [Rust 2024 edition](references/edition-2024.md) | Migration, captures, temporary lifetimes, manifests, doctest paths, style editions |
| [Language and macros](references/language-and-macros.md) | Traits, inference, patterns, imports, macros, constants, diagnostics |
| [Safety, FFI, and low-level programming](references/safety-ffi-and-low-level.md) | Pointer validity, provenance, ABIs, assembly, allocation, atomics |
| [Standard library](references/standard-library.md) | Collections, iterators, ranges, numerics, strings, I/O, synchronization, const APIs |
| [Targets and toolchains](references/targets-and-toolchains.md) | Compiler fixes, code generation, linkers, CPU features, platform tiers |
## Compiler failures and changed behavior
### Trait-object vtable regression
Rust 1.98.0 could emit a null method pointer in a trait-object vtable, causing undefined
behavior that could manifest as a segmentation fault. Rebuild with Rust 1.98.1 for the fix.
### LLVM optimization regression
Rust 1.97.1 backports a fix for an LLVM optimization that could generate incorrect code,
present since at least Rust 1.87. It also disables the 1.97.0 code generation change
that made the miscompilation more likely.
### Macro compatibility
Give every matcher metavariable a fragment specifier, such as `$value:expr` or
`$name:ident`; invalid bindings are rejected even in unused macros. End a value-producing
expansion with its value expression: `semicolon_in_expressions_from_macros` is deny-by-default.
### Never-type inference
`dependency_on_unit_never_type_fallback` and `never_type_fallback_flowing_into_unsafe`
are deny-by-default, including in pre-2024 editions. A direct build can override either
with `#[allow(...)]`. Specify the intended type when unsafe code relies on fallback.
In editions 2015, 2018, and 2021, unconstrained never-to-any coercions now fall back to `!`;
specify `()` explicitly where code relied on unit fallback.
### Raw-pointer autoref and null checks
`dangerous_implicit_autorefs` is deny-by-default from 1.89. If the pointee can validly
be borrowed, replace an implicit borrow such as `(*ptr)[0]` with `(&*ptr)[0]`.
With debug assertions, nonzero-sized null reads and writes and reborrows forming references
cause a non-unwinding panic. A dependency gets these checks only if built with debug assertions.
### Pointer validity contracts
The standard library's general validity definition excludes null even for zero-byte
accesses. Individual methods can explicitly allow null. `ptr::read_volatile` and
`ptr::write_volatile` permit access outside Rust allocations, including address zero
when the target defines a valid access there.
### Trait objects and ABI declarations
Raw trait-object upcasts can use the vtable without dereferencing the data pointer;
keep that vtable valid. Raw-pointer casts cannot add trait-object auto traits.
Unsupported calling conventions are errors in declarations and function pointer types;
gate them to supporting targets with `#[cfg(...)]`.
### Assertion and pinning temporaries
`assert_eq!` and `assert_ne!` give operand temporaries a scope local to the assertion,
which can change drop timing. `pin!` no longer applies deref coercions to its argument:
for `x: &mut T`, `pin!(x)` produces `Pin<&mut &mut T>`.
### Iterator and environment behavior
Calling `count()` or `last()` directly on `std::iter::repeat(value)` panics; limit it
with `.take(n)` for a finite sequence. `std::env::Vars` and `VarsOs` implement neither
`Send` nor `Sync`; collect into an owned `Vec<_>` before sending entries to another thread.
## Deprecations, removals, and toolchain changes
| Change | Supported action or constraint |
| --- | --- |
| Legacy pointer intrinsics | Use `std::ptr` versions of deprecated `copy`, `copy_nonoverlapping`, and `write_bytes`; their old intrinsic names lack debug precondition checks and cannot coerce to function pointers. Use `std::ptr::drop_in_place` for the removed intrinsic. |
| `Eq::assert_receiver_is_total_eq` | Omit the deprecated helper from manual `Eq` implementations. |
| Module-level `std::char` APIs | Use primitive associated items such as `char::MAX` and `char::from_u32(n)`. |
| Libtest `--nocapture` | Use `cargo test -- --no-capture`; libtest's `--logfile` is also deprecated. |
| Positional `cargo login` token | Supply the token at the prompt. `cargo publish --token` is 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. |
| Custom JSON target specifications | Rustc requires nightly and `-Z unstable-options` with `--target`; Cargo requires nightly `-Z json-target-spec`. |
| `-Csoft-float` | Removed; custom AArch64 soft-float JSON targets must set `"rustc_abi": "softfloat"`. |
| Symbol mangling | Stable rustc defaults to v0, which can affect older debugger and profiler demanglers; legacy mangling requires nightly. |
## Edition migration
Review `cargo fix` changes: keep `expr` if the matcher should accept `const` blocks and
`_`, and keep `if let` if its temporaries should drop before `else`. Add same-crate test
invocations for exported macro arms before `cargo fix --edition`; review syntax generated
by procedural macros and build scripts separately.
Rust 2024 can drop a tail-expression temporary before an outer call uses its reference.
Bind the block directly in a `let` initializer when extending that temporary's lifetime.
For boxed slices, use `boxed.iter()` to keep borrowing: `boxed.into_iter()` consumes
the box in Rust 2024.
Use `[package]` and hyphenated manifest keys. A member's `default-features = false` is
rejected when the workspace dependency enables defaults; disable defaults on the workspace
dependency itself. A Rust 2024 root package selects resolver `"3"`; a virtual workspace
opts in under `[workspace]`.
Rust 2024 doctests can share a compiled crate. Use `standalone_crate` on a doctest fence
when source locations or `std::any::type_name` paths require separate compilation.
Doctest includes loaded through `#[doc = include_str!(...)]` resolve from the Markdown file.
## Cargo workflows
### Configuration and intermediate artifacts
Use the top-level `include` key in `.cargo/config.toml` to load files; `optional = true`
permits absence. Program-and-argument settings replace the lower-precedence command as a unit.
`build.build-dir` selects intermediate storage, while metadata's `build_directory` locates it
and `target_directory` identifies final output. Use `cargo package` to retain the `.crate` tarball.
Intermediate artifacts are grouped by build step with the configuration hash in the parent;
hard-coded paths in builds and tests may need updating.
### Warning policy
`build.warnings` accepts `allow`, `warn` (the default), or `deny`; changing it preserves
the build cache. For one CI invocation, use `CARGO_BUILD_WARNINGS=deny cargo check --keep-going`.
The `linker_messages` lint reports successful-link output and is unaffected by rustc's
`warnings` group; set its level directly.
### Lockfiles and dependency age
`resolver.lockfile-path` selects a lockfile outside the workspace; `cargo install` ignores
the setting. `registry.global-min-publish-age` holds back versions with registry publication
timestamps, while `cargo install` bypasses it for the installed crate and its dependencies.
The source's one-off override is:
```sh
CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo update clap --precise 4.6.9
```
The selected version stays in `Cargo.lock` until re-resolved.
### Workspace publishing and stable Cargo linting
`cargo publish --workspace --dry-run` verifies against the full package set; workspace
publishing follows dependency order. A failed upload can leave earlier crates published.
Stable `cargo::unused_dependencies` warns by default, reports only when the invocation
builds every target that could use the entry, and skips development dependencies.
## Language and library quick reference
### Never type, captures, and const arguments
`!` can be named wherever a type is allowed, including as a generic argument;
`std::convert::Infallible` is an alias for it. Trait methods returning `impl Trait`
can use `use<...>` for precise captures. `_` can infer const arguments in expressions;
function signatures and item types still require explicit const arguments.
### Conditional code and pattern guards
`cfg_select!` chooses the first matching predicate and accepts `_` as a fallback;
the selected arm can supply an expression or items. An `if let` match guard can bind
values for the arm and refer to pattern bindings, but does not count toward exhaustiveness.
Import `assert_matches!` and `debug_assert_matches!` from `core` or `std`, or qualify them.
### Allocation and cleanup
Stable `std::alloc::Allocator`, `Box<T, A>`, and `Vec<T, A>` include selected `_in`
constructors and raw conversions carrying the allocator. `Box::take` extracts the value
and retains the allocation as `Box<MaybeUninit<T>>`. `DropGuard::new(value, cleanup)`
runs cleanup on drop, including early return or unwinding; `DropGuard::dismiss(guard)`
returns the value and skips cleanup. Zero-filled `MaybeUninit` storage requires valid
stored bytes before `assume_init`.
### Slices, ranges, and borrowed views
`slice.array_windows()` yields overlapping `&[T; N]` windows. `get_disjoint_mut` accepts
disjoint inclusive ranges. `str::substr_range` and `[T]::subslice_range` locate an existing
borrowed view. New `core::range` bounds have separate iterators; range literals still
produce `core::ops` types. Convert legacy inclusive ranges before iteration when original
bounds are needed: converting an exhausted one can panic.
### Atomics and synchronization
Atomic `update` and `try_update` may call their closure more than once under contention;
`try_update` can skip the write with `None`. `RwLockWriteGuard::downgrade` atomically
converts a write guard to a read guard, preventing another writer during the transition.
`Atomic<T>::from_mut` and `from_mut_slice` borrow primitive storage as atomics when
their alignments match.
### I/O and numeric formatting
`std::io::pipe()` supplies child-process streams; drain the reader before waiting for
the child so a full pipe cannot stall it. `File` supports blocking and nonblocking shared
and exclusive locks. Primitive integers format into `core::fmt::NumBuffer`, returning
a borrowed `&str`. Algebraic floating-point operations may be reassociated, so results
can vary with optimization while the operations remain safe for all inputs.