-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#![feature(portable_simd)]
use std::simd::Simd;
fn foo(bes_vec: Simd<f64, 4>) {
bes_vec.ln();
}
Current output
error[E0599]: no method named `ln` found for struct `Simd<T, N>` in the current scope
--> src/lib.rs:6:13
|
6 | bes_vec.ln();
| ^^
|
::: /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/../../portable-simd/crates/std_float/src/lib.rs:90:8
|
90 | fn ln(self) -> Self;
| -- the method is available for `Simd<f64, 4>` here
|
= help: items from traits can only be used if the trait is in scope
help: there is a method `le` with a similar name, but with different arguments
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:1405:5
|
1405 | fn le(&self, other: &Rhs) -> bool {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: trait `StdFloat` which provides `ln` is implemented but not in scope; perhaps you want to import it
|
3 + use std::simd::StdFloat;
|
Desired output
error[E0599]: no method named `ln` found for struct `Simd<T, N>` in the current scope
--> src/main.rs:6:21
|
6 | let term4 = bes_vec.ln();
| ^^
|
::: /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/../../portable-simd/crates/std_float/src/lib.rs:90:8
|
90 | fn ln(self) -> Self;
| -- the method is available for `Simd<f64, 4>` here
|
= help: items from traits can only be used if the trait is in scope
help: trait `StdFloat` which provides `ln` is implemented but not in scope; perhaps you want to import it
|
4 + use std::simd::StdFloat;
|
help: there is a method `le` with a similar name, but with different arguments
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:1405:5
|
1405 | fn le(&self, other: &Rhs) -> bool {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Rationale and extra context
I think the suggestion to use
the trait should follow the line about "items from traits can only be used if the trait is in scope", especially if it is an exact match.
The error is kind of long, so there is a higher likelyhood that folks just miss the suggestion, see e.g. #project-portable-simd > SimdFloat ln() and exp() @ 💬
Other cases
Rust Version
rustc 1.91.0-nightly (a1208bf76 2025-09-03)
binary: rustc
commit-hash: a1208bf765ba783ee4ebdc4c29ab0a0c215806ef
commit-date: 2025-09-03
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.