; } Current output error[E0605]: non-primitive cast: `&'static str` as `Arc` --> main.rs:4:14 | 4 | let _a = "arc" as Arc; |...">

Incorrect help suggestion when attempting "arc" as Arc · Issue #135412 · rust-lang/rust (original) (raw)

Code

fn main() { use std::sync::Arc;

let _a = "arc" as Arc<str>;

}

Current output

error[E0605]: non-primitive cast: &'static str as Arc<str> --> main.rs:4:14 | 4 | let _a = "arc" as Arc; | ^^^^^^^^^^^^^^^^^ help: consider using the From trait instead: Arc<str>::from("arc") | = note: an as expression can only be used to convert between primitive types or to coerce to a specific trait object

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0605.

Desired output

error[E0605]: non-primitive cast: &'static str as Arc<str> --> main.rs:4:14 | 4 | let _a = "arc" as Arc; | ^^^^^^^^^^^^^^^^^ help: consider using the From trait instead: Arc::<str>::from("arc") | = note: an as expression can only be used to convert between primitive types or to coerce to a specific trait object

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0605.

Rationale and extra context

The compiler suggests:
help: consider using the From trait instead: Arc<str>::from("arc")

when it should be:
help: consider using the From trait instead: Arc::<str>::from("arc")

There's a :: missing to complete the turbofish.

Other cases

Rust Version

rustc 1.84.0 (9fc6b4312 2025-01-07) binary: rustc commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869 commit-date: 2025-01-07 host: x86_64-unknown-linux-gnu release: 1.84.0 LLVM version: 19.1.5

Anything else?

No response