compiler/rustc_error_codes/src/error_codes/E0659.md MARKDOWN 51 lines View on github.com → Search inside
1An item usage is ambiguous.23Erroneous code example:45```compile_fail,edition2018,E06596pub mod moon {7    pub fn foo() {}8}910pub mod earth {11    pub fn foo() {}12}1314mod collider {15    pub use crate::moon::*;16    pub use crate::earth::*;17}1819fn main() {20    crate::collider::foo(); // ERROR: `foo` is ambiguous21}22```2324This error generally appears when two items with the same name are imported into25a module. Here, the `foo` functions are imported and reexported from the26`collider` module and therefore, when we're using `collider::foo()`, both27functions collide.2829To solve this error, the best solution is generally to keep the path before the30item when using it. Example:3132```edition201833pub mod moon {34    pub fn foo() {}35}3637pub mod earth {38    pub fn foo() {}39}4041mod collider {42    pub use crate::moon;43    pub use crate::earth;44}4546fn main() {47    crate::collider::moon::foo(); // ok!48    crate::collider::earth::foo(); // ok!49}50```

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.