Open
Description
Code
fn f() {
u8::cast_from_lossy(9);
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0599]: no function or associated item named `cast_from_lossy` found for type `u8` in the current scope
--> src/lib.rs:2:9
|
2 | u8::cast_from_lossy(9);
| ^^^^^^^^^^^^^^^ function or associated item not found in `u8`
|
= help: items from traits can only be used if the trait is in scope
help: trait `CastFrom` which provides `cast_from_lossy` is implemented but not in scope; perhaps you want to import it
|
1 + use compiler_builtins::math::libm::support::int_traits::CastFrom;
|
For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` (lib) due to 1 previous error
Desired output
Compiling playground v0.0.1 (/playground)
error[E0599]: no function or associated item named `cast_from_lossy` found for type `u8` in the current scope
--> src/lib.rs:2:9
|
2 | u8::cast_from_lossy(9);
| ^^^^^^^^^^^^^^^ function or associated item not found in `u8`
|
For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` (lib) due to 1 previous error
Rationale and extra context
The suggested import does not work. Additionally, the import will be suggested even if it's already there.
Other cases
A previously reported issue #71090 was supposed to be fixed, but maybe it regressed?
Rust Version
rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: This is a bug.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.