Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Rust E0599: no method named found for type in the current scope

E0599 means no candidate method is visible. Import the trait, unify duplicate crate versions, fix the receiver, or enable the Cargo feature.

~5 min readRust
#Rust#Cargo#Traits#Compiler
A rust struct crate with a missing method socket, cyan trait key beside it and amber duplicate crate stack

Introduction & Quick Summary

text
error[E0599]: no method named `to_lowercase` found for struct `Uuid` in the current scope --> src/main.rs:6:20 | 6 | println!("{}", id.to_lowercase()); | ^^^^^^^^^^^^ method not found in `Uuid`

E0599 means the method exists nowhere the compiler can see for that type. Rust does not have runtime method lookup: a method is only callable when a trait that declares it is in scope, or when it is an inherent method on the type. Four causes:

  • The trait is not imported. Uuid has to_string, not to_lowercase; the method that could work is often on a trait such as ToString or a crate extension trait.
  • Two versions of a crate are in the graph. A trait implemented for chrono 0.4.38 does not apply to a chrono 0.4.39 value, and the method disappears.
  • The receiver is the wrong shape. The method is on &T and the value is Rc<T>, or the method takes self and the value is behind Option, so the compiler suggests a different type in its help: line.
  • A feature is not enabled. serde's Serialize methods, tokio's extension traits, and many builder methods are behind Cargo features.
Message detailMeaningFix
help: items from traits can only be used if the trait is in scopeTrait import missingAdd use path::Trait;
help: the method is available for Box<T> hereReceiver shapeDeref, clone, or use *
help: trait X is implemented but not in scopeCrate present, trait not importedImport the trait
note: the method was found for chrono::DateTime<Utc> with two versionsDuplicate crateUnify versions
the following trait bounds were not satisfiedGeneric bound missingAdd T: Trait

Core Mechanics, Signatures & Reproducible Setup

Method resolution tries inherent methods first, then trait methods from traits in scope, then auto-deref and auto-ref steps on the receiver. If no candidate matches, the compiler emits E0599 and lists the types it did find the method on. The help: suggestions are the useful part: they name the trait or the receiver shape that would work.

A reproduction is one missing import:

rust
// Cargo.toml // [dependencies] // chrono = { version = "0.4", default-features = false, features = ["clock"] } use chrono::Utc; fn main() { let now = Utc::now(); println!("{}", now.format("%Y-%m-%d")); // E0599 without the feature/import }
text
error[E0599]: no method named `format` found for struct `chrono::DateTime<Utc>` in the current scope --> src/main.rs:6:20
rust
use chrono::{DateTime, Utc}; fn main() { let now: DateTime<Utc> = Utc::now(); println!("{}", now.format("%Y-%m-%d").to_string()); }

The trait that provides the method has to be imported, and the type alias has to resolve to the same crate version the impl belongs to.

Key Comparison Table

Several error codes look similar and mean different things. Reading the code first avoids chasing the wrong fix.

CodeMessageWhat it meansWhere to look
E0599no method named x found for type TNo candidate methodTrait import, version, receiver
E0277the trait bound T: Trait is not satisfiedType does not implement the traitBound, impl, feature
E0433failed to resolve: use of undeclared crate or modulePath does not existDependencies, use path
E0412cannot find type T in this scopeName not importedImports
E0609no field f on type TField is private or absentStruct definition

Duplicate crate versions produce a distinctive set of symptoms, and cargo tree -d is the direct check.

Symptomcargo tree -d outputEffect
Trait method missing on a value from another crateTwo versions of that crateImpl belongs to the other version
expected crate::T, found crate::T in a function callTwo versions of that crateTypes are distinct
TryFrom or Into conversion missingTwo versions of the trait's crateCoherence is per version
Builds locally, fails in CILockfile not committedResolver picked another version

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

Import the trait, not just the type

An extension trait is only usable when imported. The compiler's help: line names it, so the fix is a one-line use.

rust
use std::io::{self, Read}; fn read_all() -> io::Result<String> { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer)?; // E0599 without `Read` Ok(buffer) }
rust
use std::io::{self, Read}; fn read_all() -> io::Result<String> { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer)?; // ok: Read is in scope Ok(buffer) }

Read is never used as a type, so removing it looks harmless to a linter that only checks named types; cargo check catches the missing method immediately.

Unify two versions of the same crate

When a trait impl and the value come from different versions, no import fixes it. cargo tree -d prints the duplicates and cargo tree -i <crate> shows who requires them.

bash
cargo tree -d # chrono v0.4.38 # └── lib-a v1.0.0 # chrono v0.4.39 # └── lib-b v2.0.0
bash
cargo update -p chrono --precise 0.4.39 cargo tree -d cargo check
toml
# force one version when a dependency pins an older release [patch.crates-io] chrono = { version = "0.4.39" }

[patch.crates-io] only works when the patch resolves to the same source; a git dependency needs [patch."https://github.com/..."]. After patching, run cargo update -p chrono so the lockfile picks up the change.

Receiver shape and auto-deref

Auto-deref covers &T, &mut T, and Box<T>, but not Rc<T>, Option<T>, or a tuple struct without Deref. The compiler's suggestion names the type where the method exists.

rust
use std::rc::Rc; fn label(name: Rc<String>) -> String { name.to_uppercase() // E0599: the method exists on String, not Rc<String> }
rust
use std::rc::Rc; fn label(name: Rc<String>) -> String { name.as_str().to_uppercase() }

Auto-deref stops at types that do not implement Deref, so Rc and Arc need an explicit as_str, &**value, or a method call that forwards through Deref in the standard library.

Feature gates

A method that exists in the source but is compiled out by a feature produces E0599 with no other hint. The fix is in Cargo.toml, not in the code.

toml
[dependencies] serde = { version = "1", features = ["derive"] } tokio = { version = "1", features = ["full"] } reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
bash
cargo check --all-features cargo tree -e features -i serde | head -20

Checking with --all-features separates a feature problem from a code problem; if it compiles there and not in the default build, the manifest is the issue.

Generic bounds

Inside a generic function, the method is only available when the bound is declared. E0599 on a type parameter usually comes with an E0277 note that names the missing bound.

rust
fn describe<T>(value: T) -> String { value.to_string() // E0599: T does not implement Display }
rust
fn describe<T: std::fmt::Display>(value: T) -> String { value.to_string() }

Adding + ?Sized or a separate where clause is equivalent; the important part is that the bound names the trait that provides the method.

Method name collisions between traits

Two traits in scope can both provide a method with the same name, and the call becomes ambiguous (E0034) rather than E0599. A fully qualified call resolves it, and importing only one trait avoids it.

rust
trait A { fn run(&self) -> &'static str; } trait B { fn run(&self) -> &'static str; } struct S; impl A for S { fn run(&self) -> &'static str { "a" } } impl B for S { fn run(&self) -> &'static str { "b" } } fn main() { let s = S; println!("{}", s.run()); // E0034: multiple applicable items in scope println!("{}", A::run(&s)); }

Importing both traits is legitimate; the call site needs the qualified form when the meaning differs.

Common Compilation/Runtime Mistakes & Version Gotchas

Adding a use for a type when a trait is needed. use crate::Uuid; imports the type; use crate::ToLowercase; or the prelude import is what makes the method resolve.

Ignoring the help: lines. They usually say exactly which trait to import or which receiver type has the method, and they are generated from the compiler's own candidate list.

Blaming the code when the lockfile changed. Cargo.lock committed in a binary crate keeps versions stable; a library crate without one can resolve differently on every machine, which is the usual reason CI fails and a laptop does not.

Using #[allow(unused_imports)] to keep a trait import. The import is required for the method call, so a use that appears unused may be needed by another file through a macro expansion. Check cargo check before removing it.

Forcing a version with a wildcard. cargo update -p chrono --precise 0.4 is not a valid version, and 0.4.* in a patch is rejected; use an exact version or a range.

Version notes. -Z minimal-versions and the 2024 edition resolver changes affect which duplicate versions can coexist, but the method-resolution rule is unchanged. cargo tree -d omits duplicates that differ only by patch level in some older versions, so cargo tree --duplicates is the explicit form. Rust 2024 makes use of a trait inside a block scope subject to the same rules, so a trait imported in a function is not available in a nested module.

Order: read the help: block, import the named trait, then check cargo tree -d if the type comes from another crate. When two versions are the cause, the text diff on Cargo.lock shows the version that moved, and the regex tester is a quick way to list impl ... for blocks across a source tree.

Official references: E0599 and Cargo resolver.

Official references

primary documentation

The Rust documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Rust work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Rust guides

More in Rust

All Rust guides

The guides filed next to this one in Rust, in library order.