rust Errors

120 error patterns

rust3 fixes

Future not Send due to non-Send type

future cannot be sent between threads safely.*Send

  • Use Arc<Mutex<T>> instead of Rc<RefCell<T>>
  • Add Send bound or spawn_local for !Send futures
rust3 fixes

Future requires Unpin but type doesn't implement it

cannot be unpinned.*Unpin.*is not implemented

  • Use Box::pin() to pin the future on heap
  • Use pin_mut! macro for stack pinning
rust3 fixes

Type doesn't implement Future trait

the trait.*Future.*is not implemented for

  • Ensure async fn returns impl Future
  • Use .await on async calls
rust3 fixes

Nested Tokio runtime creation

Cannot start a runtime from within a runtime

  • Use tokio::task::spawn_blocking for sync code
  • Use Handle::current().block_on() in nested context
rust3 fixes

No Tokio reactor running

there is no reactor running|must be called from.*tokio runtime

  • Add #[tokio::main] or #[tokio::test]
  • Create runtime with Runtime::new()
rust3 fixes

Tokio blocking thread pool exhausted

reached the configured maximum number of blocking threads

  • Increase max_blocking_threads in RuntimeBuilder
  • Use spawn_blocking sparingly
rust3 fixes

Serde unknown field in input

serde.*unknown field `.*`, expected one of

  • Add #[serde(deny_unknown_fields)] intentionally or remove it
  • Add missing field to struct
rust3 fixes

Serde type mismatch during deserialization

serde.*invalid type: .*, expected

  • Add #[serde(deserialize_with)] custom deserializer
  • Fix source data type to match struct
rust3 fixes

Serde missing required field

serde.*missing field `.*`

  • Add #[serde(default)] for optional fields
  • Use Option<T> for nullable fields
rust3 fixes

Serde internally tagged enum deserialization failure

serde.*enum.*internally tagged.*cannot deserialize

  • Verify tag field matches #[serde(tag)] value
  • Use #[serde(untagged)] or adjacently tagged
rust3 fixes

Serde flatten conflicts with deny_unknown_fields

serde.*flatten.*cannot.*with.*deny_unknown_fields

  • Remove deny_unknown_fields when using flatten
  • Use manual Deserialize impl
rust3 fixes

Method exists but trait bounds not met

the method.*exists for.*but its trait bounds were not satisfied

  • Add required trait bounds to generic parameters
  • Import the trait with use statement
rust3 fixes

Move out of shared reference

cannot move out of.*which is behind a shared reference

  • Use .clone() if type is Clone
  • Use std::mem::take or std::mem::replace
rust3 fixes

Closure borrows value that may be dropped

closure may outlive the current function.*borrowed value

  • Add move keyword to closure
  • Clone the value before closure
rust3 fixes

Closure implements FnOnce but Fn required

expected a closure that implements the.*Fn.*trait.*but this closure only implements.*FnOnce

  • Avoid moving/consuming captured values in closure
  • Clone values instead of moving
rust3 fixes

Simultaneous mutable and immutable borrow

cannot borrow.*as mutable.*also borrowed as immutable

  • Restructure to separate borrow scopes
  • Clone data to avoid shared reference
rust3 fixes

Trait not object-safe for dyn dispatch

the trait.*cannot be made into an object

  • Remove generic methods or add where Self: Sized
  • Use enum dispatch instead of trait objects
rust3 fixes

Unsized trait object usage

the size for values of type.*dyn.*cannot be known at compilation time

  • Use Box<dyn Trait> for owned trait objects
  • Use &dyn Trait for borrowed references
rust3 fixes

Proc macro panicked during expansion

proc-macro.*panicked.*TokenStream

  • Use syn::Error::to_compile_error instead of panic
  • Validate input tokens before processing
rust3 fixes

Macro not found in scope

cannot find macro.*in this scope

  • Add #[macro_use] on extern crate or use macro_rules
  • Import with use crate::macro_name
rust3 fixes

Macro recursion limit exceeded

recursion limit reached while expanding.*macro

  • Add #![recursion_limit = "256"]
  • Restructure macro to reduce recursion depth
rust3 fixes

Proc macro attribute not found

proc macro.*attribute.*not found

  • Add proc-macro crate to dependencies
  • Import derive/attribute macro correctly
rust3 fixes

Raw pointer dereference outside unsafe

dereferencing a raw pointer is unsafe

  • Wrap in unsafe block with safety comment
  • Use safe alternative (reference, smart pointer)
rust3 fixes

Unsafe function called without unsafe block

cannot call unsafe function.*without.*unsafe

  • Wrap call in unsafe { } block
  • Add safety documentation comment
rust3 fixes

FFI linker symbol not found

undefined reference to|ld: symbol.*not found.*ffi

  • Link correct library with #[link(name = "...")]
  • Add cargo:rustc-link-lib in build.rs
rust3 fixes

Mutable reference aliasing UB

mutable reference.*aliases.*undefined behavior

  • Use UnsafeCell for interior mutability
  • Ensure no aliasing of &mut references
rust3 fixes

Cargo workspace path dependency resolution failure

failed to resolve.*use of undeclared.*in workspace

  • Verify path in workspace Cargo.toml members
  • Use relative path in [dependencies]
rust3 fixes

Cargo feature unification conflict

feature.*was found in.*but is not requested

  • Enable required feature in dependent crate
  • Use default-features = false to avoid conflicts
rust3 fixes

Cargo linker not found or failed

linker.*not found|error: linker.*cc.*failed

  • Install build-essential/gcc for target
  • Set CARGO_TARGET_*_LINKER env variable
rust3 fixes

Format string argument mismatch

there is no argument named.*in format string

  • Match named arguments to format placeholders
  • Use positional {} or named {name} consistently
rust3 fixes

Axum request body already consumed

Axum.*Cannot.*extract.*body.*already consumed

  • Move body extractor to last position in handler
  • Use only one body extractor per handler
rust3 fixes

Axum handler extractor count mismatch

Axum.*wrong number of extractors.*handler

  • Ensure handler signature matches route extractors
  • Group extractors in tuple or custom struct
rust3 fixes

Axum extension/state not found

Extension of type.*was not found.*axum

  • Add .with_state() when building router
  • Use Extension<T> or State<T> extractor
rust3 fixes

Axum middleware service not Clone

axum.*middleware.*Service.*does not implement Clone

  • Wrap state in Arc for clonability
  • Implement Clone for middleware state
rust3 fixes

Actix-web app data not configured

actix.*App data is not configured.*Data<.*>

  • Add .app_data(Data::new(state)) to App
  • Register state before routes that use it
rust3 fixes

Actix extractor failure

actix.*Can not extract.*from request

  • Configure extractor limits (JsonConfig, FormConfig)
  • Verify Content-Type header matches extractor
rust3 fixes

Tower layer doesn't implement Service

tower.*Layer.*does not implement.*Service

  • Implement Service<Request> for the layer
  • Use tower::service_fn for simple transforms
rust3 fixes

Lifetime too short for closure capture

lifetime.*does not live long enough.*closure

  • Use 'static bound with move closure
  • Clone or Arc-wrap the reference
rust3 fixes

Type doesn't satisfy lifetime bound

the type.*does not fulfill.*required lifetime.*bound

  • Add appropriate lifetime bounds to generic
  • Use 'static if ownership is transferred
rust3 fixes

Move of non-Copy type

move occurs because.*has type.*which does not implement.*Copy

  • Implement Clone and call .clone()
  • Use reference instead of move
rust3 fixes

Serde duplicate field in input

serde.*duplicate field

  • Enable #[serde(deny_unknown_fields)]
  • Use #[serde(rename)] to avoid collisions
rust3 fixes

Declarative macro token mismatch

no rules expected the token

  • Fix macro invocation syntax
  • Add token pattern to macro_rules! arm
rust3 fixes

Macro ambiguity multiple matches

local ambiguity.*multiple.*macro.*matches

  • Reorder macro arms from specific to general
  • Add distinguishing tokens between arms
rust3 fixes

Proc-macro attribute parse failure

custom attribute panicked.*parse.*failed

  • Use syn::parse_macro_input! for robust parsing
  • Handle parse errors gracefully with compile_error!
rust3 fixes

Non-Send type held across .await

async fn.*is not.*Send.*because.*held across.*await

  • Drop non-Send value before .await point
  • Use Send-compatible alternatives (Mutex vs RefCell)
rust3 fixes

MutexGuard held across await makes future !Send

future.*is not.*Send.*MutexGuard

  • Drop MutexGuard before .await
  • Use tokio::sync::Mutex instead of std::sync::Mutex
rust3 fixes

Returning reference to temporary

cannot return value referencing.*temporary value

  • Return owned value instead of reference
  • Store temporary in let binding
rust3 fixes

Sized method called on trait object

trait.*has.*method.*with a.*where Self: Sized.*cannot be called on.*dyn

  • Remove where Self: Sized from method
  • Use enum dispatch for Sized-requiring methods
rust3 fixes

Ambiguous method from multiple traits

multiple applicable items in scope.*method

  • Use fully qualified syntax: <T as Trait>::method()
  • Rename conflicting methods
rust3 fixes

Missing Deserialize impl for type

the trait bound.*Deserialize.*is not satisfied

  • Add #[derive(Deserialize)] to type
  • Implement custom Deserialize with impl
rust3 fixes

Serde untagged enum no variant matched

serde.*data did not match any variant

  • Verify data matches at least one variant
  • Add fallback variant with #[serde(other)]
rust3 fixes

Type cycle detection error

cycle detected when.*type_of

  • Break cycle with Box<T> for recursive types
  • Use indirection through trait object
rust3 fixes

Type inference failure needs turbofish

cannot infer type for type parameter.*turbofish

  • Add ::<Type> turbofish annotation
  • Add explicit type to let binding
rust3 fixes

Cannot move out of indexed content

error\[E0507\].*cannot move out of.*index

  • Use .remove() to take ownership from Vec
  • Use std::mem::replace with default
rust3 fixes

Method not found for type

no method named.*found for.*in the current scope

  • Import the trait that provides the method
  • Check method visibility (pub/crate)
rust3 fixes

Async type mismatch - missing .await

mismatched types.*expected.*found.*async

  • Add .await to resolve the future
  • Change return type to impl Future<Output=T>
rust3 fixes

Missing lifetime on struct holding reference

consider adding.*lifetime.*to type.*so that.*reference.*tied to it

  • Add lifetime parameter to struct definition
  • Use owned type instead of reference
rust3 fixes

Impl not general enough for HRTB

implementation of.*is not general enough

  • Use for<'a> higher-ranked trait bound
  • Widen lifetime bound to satisfy all cases
rust3 fixes

Async trait method not Send

async.*trait.*Send.*not satisfied

  • Use #[async_trait] from async-trait crate
  • Return Pin<Box<dyn Future + Send>>
rust3 fixes

Value used after move

value used here after move

  • Clone value before first use
  • Restructure to avoid reuse after move
rust3 fixes

Cargo workspace member not found

workspace.*member.*not found

  • Verify path in [workspace] members array
  • Check directory exists at specified path
rust3 fixes

Cargo version resolution failure

failed to select a version for.*required by

  • Update dependency version constraints
  • Use cargo update -p <package>
rust3 fixes

Cargo feature not enabled

feature.*requires.*but.*not enabled

  • Enable feature in Cargo.toml dependency
  • Use features = ["feature-name"]
rust3 fixes

Axum type doesn't implement IntoResponse

axum.*IntoResponse.*not implemented

  • Implement IntoResponse for custom type
  • Return (StatusCode, impl IntoResponse) tuple
rust3 fixes

Axum handler trait not satisfied

axum.*Handler.*does not implement

  • Ensure handler is async and returns IntoResponse
  • Check extractor types implement FromRequest
rust3 fixes

Tokio spawned task panicked

tokio.*task.*JoinError.*panic

  • Handle JoinError from task.await
  • Use catch_unwind in spawned task
rust3 fixes

Tokio timeout elapsed

tokio.*elapsed.*deadline has elapsed

  • Increase timeout duration
  • Handle Elapsed error gracefully
rust3 fixes

Iterator consumed by move

borrow of moved value.*iterator

  • Use .iter() for borrowing iteration
  • Use .into_iter() intentionally for consuming
rust3 fixes

Temporary dropped while reference alive

temporary value dropped while borrowed.*let

  • Bind temporary to let variable
  • Extend temporary lifetime with let binding
rust3 fixes

Macro invocation incomplete

macro.*unexpected end of macro invocation

  • Add missing arguments to macro call
  • Check macro definition for required tokens
rust3 fixes

FFI improper C type usage

FFI.*type.*improper_ctypes

  • Use #[repr(C)] on struct for FFI
  • Replace with C-compatible type
rust3 fixes

Double mutable borrow

cannot borrow.*as mutable more than once

  • Split borrows into separate scopes
  • Use Cell/RefCell for interior mutability
rust3 fixes

Type length limit overflow

overflow evaluating the requirement.*type_length_limit

  • Add #![type_length_limit = "N"]
  • Reduce generic nesting depth
rust3 fixes

Serde JSON parse error at position

serde.*invalid value.*expected.*at line.*column

  • Validate JSON structure before parsing
  • Check for trailing commas or invalid syntax
rust3 fixes

Higher-ranked lifetime error

higher-ranked lifetime error

  • Simplify lifetime bounds
  • Use Box<dyn> to erase problematic lifetimes
rust3 fixes

Trait object not allowed in const

trait object.*dyn.*not allowed in const

  • Use generic with impl Trait instead
  • Use enum dispatch for const context
rust3 fixes

Derive macro doesn't handle generics

proc-macro.*derive.*does not handle.*generics

  • Add generic handling to proc macro impl
  • Use syn::Generics to parse type params
rust3 fixes

Error conversion From trait missing

the trait.*From<.*Error>.*is not implemented

  • Implement From<SourceError> for target
  • Use #[from] with thiserror derive
rust3 fixes

Async closure not stable

async.*closure.*not.*stable|async closures are unstable

  • Use move || async move { } pattern instead
  • Create async fn and pass as reference
rust3 fixes

pin-project invalid pin annotation

pin_project.*#\[pin\].*not allowed on this field

  • Only use #[pin] on fields needing pinning
  • Remove #[pin] from non-Future fields
rust3 fixes

Serde enum with data as map key

serde.*cannot serialize.*enum.*with.*data.*as map key

  • Implement custom Serialize for key type
  • Use String key with conversion
rust3 fixes

Type not found in external crate

cannot find type.*in.*extern crate

  • Check crate version for API changes
  • Enable required feature flag on dependency
rust3 fixes

Conflicting trait implementations

conflicting implementations of trait.*for type

  • Use newtype pattern to avoid overlap
  • Add more specific bounds to one impl
rust3 fixes

Orphan rule - potential future conflict

upstream crates may add.*impl.*in future versions

  • Use newtype wrapper pattern
  • Move impl to crate that owns the type
rust3 fixes

Actix payload already consumed

actix.*Payload.*already consumed

  • Use single body extractor per handler
  • Buffer payload with web::Bytes first
rust3 fixes

Tower service timeout

tower.*timeout.*elapsed

  • Increase tower::timeout::Timeout duration
  • Add retry layer after timeout
rust3 fixes

Mutable static access requires unsafe

unsafe.*mutable.*static.*requires unsafe

  • Use std::sync::OnceLock or LazyLock
  • Use atomic types for simple values
rust3 fixes

Returning reference to local variable

cannot return reference to.*local variable

  • Return owned value (String, Vec, etc.)
  • Use Cow for flexible ownership
rust3 fixes

Axum router merge state type mismatch

axum.*Router.*merge.*state.*mismatch

  • Use same state type across merged routers
  • Convert state with .with_state() before merge
rust3 fixes

Rc used where Send required

Send.*not implemented for.*Rc<

  • Use Arc instead of Rc for thread safety
  • Clone data instead of sharing with Rc
rust3 fixes

Associated type not specified in trait bound

trait.*associated type.*not specified

  • Add Item = Type to trait bound
  • Specify all associated types
rust3 fixes

Non-FFI-safe type in extern block

extern.*block uses.*type.*which is not FFI-safe

  • Use C-compatible types (i32, *const, etc.)
  • Add #[repr(C)] to struct definitions
rust3 fixes

Type not Sync for shared access

Sync.*not implemented.*cannot be shared between threads

  • Use Mutex/RwLock for synchronized access
  • Use Arc<Mutex<T>> for shared mutable state
rust3 fixes

Future not Unpin for polling

future.*returned.*does not implement.*Unpin

  • Use Box::pin(future) to pin on heap
  • Use pin_mut! macro from pin-utils
rust3 fixes

FnMut closure moves value on repeat call

cannot.*move.*closure.*FnMut.*called multiple times

  • Clone value inside closure each call
  • Use &mut reference instead of moving
rust3 fixes

Must-use value ignored

unused.*must be used.*#\[must_use\]

  • Handle the Result/Option
  • Use let _ = expr to intentionally discard
rust3 fixes

Proc macro wrong expansion context

procedural macro.*cannot expand to.*statements

  • Use attribute macro for statement context
  • Return valid TokenStream for position
rust3 fixes

Serde i128 not supported by format

serde.*i128.*not supported

  • Use i64 or String for large numbers
  • Enable i128 feature on serde
rust3 fixes

Borrowed data escapes scope

error\[E0521\].*borrowed data escapes outside of

  • Extend lifetime of borrowed data
  • Return owned type instead
rust3 fixes

Cargo package verification failure

cargo.*failed to verify.*package.*tarball

  • Run cargo package --list to check included files
  • Fix .gitignore excluding required files
rust3 fixes

Mutable borrow while immutable borrow exists

cannot borrow.*as mutable because it is also borrowed as immutable

  • Clone the data to avoid shared references
  • Restructure code so immutable borrow ends before mutable borrow begins
rust3 fixes

Value does not live long enough for lifetime

lifetime.*does not live long enough

  • Extend the lifetime of the borrowed value by moving it to an outer scope
  • Clone the value instead of borrowing it
rust3 fixes

Required trait not implemented

the trait.*is not implemented for

  • Add #[derive(TraitName)] to the struct if it's a standard trait
  • Implement the trait manually with an impl block
rust3 fixes

Use of value after move

value used here after move

  • Clone the value before the move if it implements Clone
  • Use a reference (&T) instead of moving ownership
rust3 fixes

Type mismatch in expression

mismatched types.*expected.*found

  • Convert the type explicitly using .into() or as keyword
  • Check function signature for expected parameter types
rust3 fixes

Undefined value in scope

cannot find value.*in this scope

  • Check for typos in the variable name
  • Bring the value into scope with use statement
rust3 fixes

Unused variable warning

unused variable:.*#\[warn\(unused_variables\)\]

  • Prefix the variable with underscore: _variable_name
  • Remove the variable if it's truly unnecessary
rust3 fixes

Multiple mutable borrows

cannot borrow.*as mutable more than once at a time

  • Restructure to use only one mutable reference at a time
  • Split the struct into separate fields that can be borrowed independently
rust3 fixes

Borrow of value after it was moved

error\[E0382\].*borrow of moved value

  • Clone the value before the move
  • Use references instead of moving ownership
rust3 fixes

Unsized type used where sized is required

the size for values of type.*cannot be known at compilation time

  • Box the value: Box<dyn Trait> instead of dyn Trait
  • Use a reference &dyn Trait instead of owned dyn Trait
rust3 fixes

Expected type but found unit ()

error\[E0308\].*expected.*found.*\()

  • Remove the trailing semicolon from the last expression in the block
  • Add an explicit return statement with the correct value
rust3 fixes

Method not found on type

no method named.*found for.*in the current scope

  • Import the trait that provides the method with use statement
  • Check the type — you may need to dereference or convert first
rust3 fixes

Cannot move out of shared reference

cannot move out of.*which is behind a shared reference

  • Clone the value instead of moving it
  • Use .as_ref() or pattern match with ref keyword
rust3 fixes

Missing lifetime annotation

error\[E0106\].*missing lifetime specifier

  • Add explicit lifetime parameter: fn foo<'a>(x: &'a str) -> &'a str
  • Return an owned type instead of a reference if possible
rust3 fixes

Undeclared crate or module

failed to resolve.*use of undeclared.*crate

  • Add the crate to [dependencies] in Cargo.toml
  • Run cargo build to download the dependency
rust3 fixes

Array/vector index out of bounds panic

thread '.*' panicked at '.*index out of bounds

  • Use .get(index) which returns Option instead of panicking
  • Check length before indexing
rust3 fixes

Type does not implement Send for async/threading

error\[E0277\].*the trait bound.*Send.*is not satisfied

  • Ensure all types held across await points implement Send
  • Use Arc<Mutex<T>> instead of Rc<RefCell<T>> for thread-safe sharing
rust3 fixes

Function or associated item not found

error\[E0599\].*no function or associated item named.*found

  • Check for typos in the function name
  • Import the correct module or use the full path
rust3 fixes

System library not found by pkg-config during build

package.*was not found in the pkg-config search path

  • Install the system development package (e.g., apt install libssl-dev)
  • Set PKG_CONFIG_PATH to include the library's .pc file directory
rust3 fixes

Cannot move out of dereference

error\[E0507\].*cannot move out of.*dereference of

  • Use .clone() to get an owned copy
  • Match with ref keyword to borrow instead of move