Any plans for improving error diagnostic in Rust 2.0?
⚓ Rust 📅 2026-05-05 👤 surdeus 👁️ 2Actually Rust diagnostic as pretty good, especially comparing to C/C++. However many errors are quite puzzling for non experienced Rust coders as myself, for example:
error[E0277]: the trait bound `Vec<&str>: Extend<String>` is not satisfied
--> /media/exhdd/Dev/modu/question/question.rs:13:10
|
13 | init.extend(read_dir(dir)?.filter_map(|cur| {
| ^^^^^^ the trait `Extend<String>` is not implemented for `Vec<&str>`
|
help: the following other types implement trait `Extend<A>`
--> /rustc/ac7f9ec7da74d37fd28667c86bf117a39ba5b02a/library/alloc/src/vec/mod.rs:3949:0
|
= note: `Vec<T, A>` implements `Extend<T>`
::: /rustc/ac7f9ec7da74d37fd28667c86bf117a39ba5b02a/library/alloc/src/vec/mod.rs:4184:0
|
= note: `Vec<T, A>` implements `Extend<&T>`
error: aborting due to 1 previous error
extend method is specifically designed for extending a vector from an Iterator, so why Rust tells - is not satisfied ? I would prefer something more human friendly and even AI driven like,
You are trying to extend a vector containing a &str by an Iterator producing String, make it consistent, for example adding to_string in the context:
init.push(r#"{"name":"..", "dir":true}"#.to_string())
What do you think of such Rust diagnostic change?
4 posts - 4 participants
🏷️ Rust_feed