Skip to main content
added 7 characters in body
Source Link
kaya3
  • 22.4k
  • 50
  • 139

For context, in case any readers are unfamiliar with Rust's error messages, they are very detailed. Here's a typical example; yes, this is the message for one error.

error[E0382]: borrow of moved value: `x` --> src/main.rs:5:15 | 2 | let x = String::from("Hello, world!"); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait 3 | drop(x); | - value moved here 4 | 5 | println!("{x}"); | ^^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 3 | drop(x.clone()); | ++++++++ For more information about this error, try `rustc --explain E0382`. 

You've got: an error code and short description, a source file reference, the source line where x is declared (plus explanation), the source line where x is moved (plus explanation), the source line where x is used after being moved (plus explanation), a note that this occurred in the expansion of a macro (plus a suggestionhint for how to debug within macros), a suggestion for how to fix the error (plus explanation), and a suggestionhint for how to get more information about the error.


One reason that the Rust developers might feel it's worth their time and effort to generate such detailed error messages, is that they want to make Rust a popular, general-purpose language, but the language itself has some features ─ particularly ownership, lifetimes, and traits ─ which don't exist in many other popular languages, so they are unfamiliar to most newcomers to the language. Even for some experienced programmers, learning Rust can feel like being a beginner again.

So Rust is something of a special case in this regard, because most languages either aren't radically different to what people are used to, only require the programmer to understand concepts that are well-explained in many sources, or are specialised languages aimed at programmers who mostly understand the necessary concepts already.

Therefore I would say it's worth going into that level of detail in your error messages if your language is aimed at people who don't already understand the core ideas that the language is based on, particularly if those core ideas are unusual compared to other languages. Even then, it's probably best to focus your effort on error messages where the error does relate to one of those specific concepts. The flipside is that long error messages can be annoying if they explain things the user already understands.

For context, in case any readers are unfamiliar with Rust's error messages, they are very detailed. Here's a typical example; yes, this is the message for one error.

error[E0382]: borrow of moved value: `x` --> src/main.rs:5:15 | 2 | let x = String::from("Hello, world!"); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait 3 | drop(x); | - value moved here 4 | 5 | println!("{x}"); | ^^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 3 | drop(x.clone()); | ++++++++ For more information about this error, try `rustc --explain E0382`. 

You've got: an error code and short description, a source file reference, the source line where x is declared (plus explanation), the source line where x is moved (plus explanation), the source line where x is used after being moved (plus explanation), a note that this occurred in the expansion of a macro (plus a suggestion for how to debug within macros), a suggestion for how to fix the error, and a suggestion for how to get more information about the error.


One reason that the Rust developers might feel it's worth their time and effort to generate such detailed error messages, is that they want to make Rust a popular, general-purpose language, but the language itself has some features ─ particularly ownership, lifetimes, and traits ─ which don't exist in many other popular languages, so they are unfamiliar to most newcomers to the language. Even for some experienced programmers, learning Rust can feel like being a beginner again.

So Rust is something of a special case in this regard, because most languages either aren't radically different to what people are used to, only require the programmer to understand concepts that are well-explained in many sources, or are specialised languages aimed at programmers who mostly understand the necessary concepts already.

Therefore I would say it's worth going into that level of detail in your error messages if your language is aimed at people who don't already understand the core ideas that the language is based on, particularly if those core ideas are unusual compared to other languages. Even then, it's probably best to focus your effort on error messages where the error does relate to one of those specific concepts. The flipside is that long error messages can be annoying if they explain things the user already understands.

For context, in case any readers are unfamiliar with Rust's error messages, they are very detailed. Here's a typical example; yes, this is the message for one error.

error[E0382]: borrow of moved value: `x` --> src/main.rs:5:15 | 2 | let x = String::from("Hello, world!"); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait 3 | drop(x); | - value moved here 4 | 5 | println!("{x}"); | ^^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 3 | drop(x.clone()); | ++++++++ For more information about this error, try `rustc --explain E0382`. 

You've got: an error code and short description, a source file reference, the source line where x is declared (plus explanation), the source line where x is moved (plus explanation), the source line where x is used after being moved (plus explanation), a note that this occurred in the expansion of a macro (plus a hint for how to debug within macros), a suggestion for how to fix the error (plus explanation), and a hint for how to get more information about the error.


One reason that the Rust developers might feel it's worth their time and effort to generate such detailed error messages, is that they want to make Rust a popular, general-purpose language, but the language itself has some features ─ particularly ownership, lifetimes, and traits ─ which don't exist in many other popular languages, so they are unfamiliar to most newcomers to the language. Even for some experienced programmers, learning Rust can feel like being a beginner again.

So Rust is something of a special case in this regard, because most languages either aren't radically different to what people are used to, only require the programmer to understand concepts that are well-explained in many sources, or are specialised languages aimed at programmers who mostly understand the necessary concepts already.

Therefore I would say it's worth going into that level of detail in your error messages if your language is aimed at people who don't already understand the core ideas that the language is based on, particularly if those core ideas are unusual compared to other languages. Even then, it's probably best to focus your effort on error messages where the error does relate to one of those specific concepts. The flipside is that long error messages can be annoying if they explain things the user already understands.

added 1526 characters in body
Source Link
kaya3
  • 22.4k
  • 50
  • 139

For context, in case any readers are unfamiliar with Rust's error messages, they are very detailed. Here's a typical example; yes, this is the message for one error.

error[E0382]: borrow of moved value: `x` --> src/main.rs:5:15 | 2 | let x = String::from("Hello, world!"); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait 3 | drop(x); | - value moved here 4 | 5 | println!("{x}"); | ^^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 3 | drop(x.clone()); | ++++++++ For more information about this error, try `rustc --explain E0382`. 

You've got: an error code and short description, a source file reference, the source line where x is declared (plus explanation), the source line where x is moved (plus explanation), the source line where x is used after being moved (plus explanation), a note that this occurred in the expansion of a macro (plus a suggestion for how to debug within macros), a suggestion for how to fix the error, and a suggestion for how to get more information about the error.


One reason that the Rust developers might feel it's worth their time and effort to generate very helpfulsuch detailed error messages, is that they want to make Rust a popular, general-purpose language, but the language itself has some features ─ particularly ownership, lifetimes, and traits ─ which don't exist in many other popular languages, so they are unfamiliar to most newcomers to the language. Even for some experienced programmers, learning Rust can feel like being a beginner again.

So Rust is something of a special case in this regard, because most languages either aren't radically different to what people are used to, only require the programmer to understand concepts that are well-explained in many sources, or are specialised languages aimed at programmers who mostly understand the necessary concepts already.

Therefore I would say it's worth going into that level of detail in your error messages if your language is aimed at people who don't already understand the core ideas that the language is based on, particularly if those core ideas are unusual compared to other languages. Even then, it's probably best to focus your effort on error messages where the error does relate to one of those specific concepts. The flipside is that long error messages can be annoying if they explain things the user already understands.

One reason that the Rust developers might feel it's worth their time and effort to generate very helpful error messages, is that they want to make Rust a popular, general-purpose language, but the language itself has some features ─ particularly ownership, lifetimes, and traits ─ which don't exist in many other popular languages, so they are unfamiliar to most newcomers to the language. Even for some experienced programmers, learning Rust can feel like being a beginner again.

So Rust is something of a special case in this regard, because most languages either aren't radically different to what people are used to, only require the programmer to understand concepts that are well-explained in many sources, or are specialised languages aimed at programmers who mostly understand the necessary concepts already.

Therefore I would say it's worth going into that level of detail in your error messages if your language is aimed at people who don't already understand the core ideas that the language is based on, particularly if those core ideas are unusual compared to other languages. Even then, it's probably best to focus your effort on error messages where the error does relate to one of those specific concepts. The flipside is that long error messages can be annoying if they explain things the user already understands.

For context, in case any readers are unfamiliar with Rust's error messages, they are very detailed. Here's a typical example; yes, this is the message for one error.

error[E0382]: borrow of moved value: `x` --> src/main.rs:5:15 | 2 | let x = String::from("Hello, world!"); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait 3 | drop(x); | - value moved here 4 | 5 | println!("{x}"); | ^^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 3 | drop(x.clone()); | ++++++++ For more information about this error, try `rustc --explain E0382`. 

You've got: an error code and short description, a source file reference, the source line where x is declared (plus explanation), the source line where x is moved (plus explanation), the source line where x is used after being moved (plus explanation), a note that this occurred in the expansion of a macro (plus a suggestion for how to debug within macros), a suggestion for how to fix the error, and a suggestion for how to get more information about the error.


One reason that the Rust developers might feel it's worth their time and effort to generate such detailed error messages, is that they want to make Rust a popular, general-purpose language, but the language itself has some features ─ particularly ownership, lifetimes, and traits ─ which don't exist in many other popular languages, so they are unfamiliar to most newcomers to the language. Even for some experienced programmers, learning Rust can feel like being a beginner again.

So Rust is something of a special case in this regard, because most languages either aren't radically different to what people are used to, only require the programmer to understand concepts that are well-explained in many sources, or are specialised languages aimed at programmers who mostly understand the necessary concepts already.

Therefore I would say it's worth going into that level of detail in your error messages if your language is aimed at people who don't already understand the core ideas that the language is based on, particularly if those core ideas are unusual compared to other languages. Even then, it's probably best to focus your effort on error messages where the error does relate to one of those specific concepts. The flipside is that long error messages can be annoying if they explain things the user already understands.

Source Link
kaya3
  • 22.4k
  • 50
  • 139

One reason that the Rust developers might feel it's worth their time and effort to generate very helpful error messages, is that they want to make Rust a popular, general-purpose language, but the language itself has some features ─ particularly ownership, lifetimes, and traits ─ which don't exist in many other popular languages, so they are unfamiliar to most newcomers to the language. Even for some experienced programmers, learning Rust can feel like being a beginner again.

So Rust is something of a special case in this regard, because most languages either aren't radically different to what people are used to, only require the programmer to understand concepts that are well-explained in many sources, or are specialised languages aimed at programmers who mostly understand the necessary concepts already.

Therefore I would say it's worth going into that level of detail in your error messages if your language is aimed at people who don't already understand the core ideas that the language is based on, particularly if those core ideas are unusual compared to other languages. Even then, it's probably best to focus your effort on error messages where the error does relate to one of those specific concepts. The flipside is that long error messages can be annoying if they explain things the user already understands.