rust-lang / discord-mods-bot

discord moderation bot
MIT License
72 stars 30 forks source link

`?eval` command produces less than ideal error messages due to the way the code is generated #108

Open ilyvion opened 1 year ago

ilyvion commented 1 year ago

Because it puts everything on the same line, you get the "irrelevant" surrounding code as part of your error message.

?eval `let () = 1;`
error[E0308]: mismatched types
 --> src/main.rs:1:34
  |
1 | fn main(){ println!("{:?}",{ let () = 1; 
  |                                  ^^   - this expression has type `{integer}`
  |                                  |
  |                                  expected integer, found `()`

The fn main(){ println!("{:?}",{ is irrelevant to my mistake and is just noise when you're trying to parse the error output. By putting the provided code on its own line, you could instead get an error message like

error[E0308]: mismatched types
 --> src/main.rs:2:5
  |
2 | let () = 1;
  |     ^^   - this expression has type `{integer}`
  |     |
  |     expected integer, found `()`

(I produced this second output by doing ?eval with a code block with a blank line before the code itself.)