Rust Compiler Error Code Index

2026-08-30 浏览 (2)

Rust Compiler Error Code Index

Quick lookup table: Error code → Skill routing

Ownership & Lifetimes (m01)

Error CodeMessageSkillCommon Fix
E0382use of moved valuem01-ownershipUse clone(), restructure ownership
E0597borrowed value does not live long enoughm01-ownershipExtend lifetime, restructure scopes
E0499cannot borrow as mutable more than oncem01-ownershipUse RefCell, restructure code
E0502cannot borrow as mutable while immutable borrow existsm01-ownershipSplit borrows, use interior mutability
E0506cannot assign to borrowed valuem01-ownershipDrop borrow before assignment
E0507cannot move out of borrowed contentm01-ownershipUse clone(), take(), or restructure
E0515cannot return reference to local variablem01-ownershipReturn owned value, use lifetime params
E0716temporary value dropped while borrowedm01-ownershipBind to variable, extend lifetime
E0621explicit lifetime required in the typem01-ownershipAdd lifetime annotations

Mutability (m03)

Error CodeMessageSkillCommon Fix
E0596cannot borrow as mutablem03-mutabilityAdd mut, use interior mutability

Type System (m04)

Error CodeMessageSkillCommon Fix
E0277the trait bound X is not satisfiedm04-zero-cost / m07-concurrencyImplement trait, add bound, use dyn
E0308mismatched typesm04-zero-costType conversion, fix generics
E0599no method named X found for type Ym04-zero-costImport trait, check types

Concurrency (m07)

Error CodeMessageSkillCommon Fix
E0277 (Send)X cannot be sent between threads safelym07-concurrencyUse Arc, ensure Send
E0277 (Sync)X cannot be shared between threads safelym07-concurrencyUse Mutex, ensure Sync

Ecosystem (m11)

Error CodeMessageSkillCommon Fix
E0425cannot find value X in this scopem11-ecosystemImport with use, check visibility
E0433failed to resolve: could not find Xm11-ecosystemAdd dependency, fix path
E0603X is privatem11-ecosystemUse public API, check exports

Quick Diagnosis Flow

Compiler Error
    ↓
Contains "moved" or "borrow"?
    → m01-ownership
    ↓
Contains "mutable"?
    → m03-mutability
    ↓
Contains "Send" or "Sync" or "thread"?
    → m07-concurrency
    ↓
Contains "trait bound" or "type"?
    → m04-zero-cost
    ↓
Contains "cannot find" or "private"?
    → m11-ecosystem

Common Error Patterns

"value moved here" → m01

let s = String::from("hello");
let s2 = s;  // s moved here
println!("{}", s);  // E0382: use of moved value

"does not live long enough" → m01

fn dangling() -> &str {
    let s = String::from("hello");
    &s  // E0597: s does not live long enough
}

"cannot be sent between threads" → m07

let rc = Rc::new(42);
thread::spawn(move || {
    println!("{}", rc);  // E0277: Rc<i32> cannot be sent
});

"trait bound not satisfied" → m04

fn print_debug<T: Debug>(t: T) {
    println!("{:?}", t);
}
print_debug(SomeType);  // E0277 if SomeType: !Debug

你可能感兴趣的文章

Agents Index

Domain Extension Index

Trigger Keywords Index

Meta-Question Categories Index

Commands Index

Technical Subcategory Index (YYY)

Skills Index

  • 所属分类: AI
  • 本文标签: rust
  • 版权声明: 本文链接 https://seaxiang.com/blog/YWNX4kcM