rust/compiler/rustc_errors/src
Matthias Krüger e525bc9592
Rollup merge of #120272 - long-long-float:suppress-suggestions-in-derive-macro, r=oli-obk
Suppress suggestions in derive macro

close #118809

I suppress warnings inside derive macros.

For example, the compiler emits following error by a program described in https://github.com/rust-lang/rust/issues/118809#issuecomment-1852256687 with a suggestion that indicates invalid syntax.

```
error[E0308]: `?` operator has incompatible types
 --> src/main.rs:3:17
  |
3 | #[derive(Debug, Deserialize)]
  |                 ^^^^^^^^^^^ expected `u32`, found `u64`
  |
  = note: `?` operator cannot convert from `u64` to `u32`
  = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
  |
3 | #[derive(Debug, Deserialize.try_into().unwrap())]
  |                            ++++++++++++++++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors
```

In this PR, suggestions to cast are suppressed.

```
error[E0308]: `?` operator has incompatible types
 --> src/main.rs:3:17
  |
3 | #[derive(Debug, Deserialize)]
  |                 ^^^^^^^^^^^ expected `u32`, found `u64`
  |
  = note: `?` operator cannot convert from `u64` to `u32`
  = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.
error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors
```
2024-02-11 01:37:54 +01:00
..
json Rename many DiagCtxt and EarlyDiagCtxt locals. 2023-12-18 16:06:22 +11:00
markdown apply fmt 2024-01-11 15:04:48 +03:00
annotate_snippet_emitter_writer.rs Rollup merge of #120575 - nnethercote:simplify-codegen-diag-handling, r=estebank 2024-02-06 19:40:06 +01:00
codes.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
diagnostic_builder.rs Tighten up ErrorGuaranteed handling. 2024-02-07 18:57:47 +11:00
diagnostic_impls.rs Add SubdiagnosticMessageOp as a trait alias. 2024-02-08 13:02:44 +11:00
diagnostic.rs Rollup merge of #120272 - long-long-float:suppress-suggestions-in-derive-macro, r=oli-obk 2024-02-11 01:37:54 +01:00
emitter.rs Rollup merge of #120575 - nnethercote:simplify-codegen-diag-handling, r=estebank 2024-02-06 19:40:06 +01:00
error.rs Make translate_message return result and add tests 2023-01-08 23:35:43 +01:00
json.rs Make Emitter::emit_diagnostic consuming. 2024-02-05 21:27:01 +11:00
lib.rs Remove unnecessary min_specialization after bootstrap 2024-02-10 18:15:11 +11:00
lock.rs bump windows crate 0.46 -> 0.48 in workspace 2023-05-09 18:20:13 +03:00
registry.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
snippet.rs Rework StringPart. 2024-02-01 19:23:01 +11:00
styled_buffer.rs Replace some _ == _ || _ == _s with matches!(_, _ | _)s 2023-01-30 12:26:26 +00:00
tests.rs Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
translation.rs Remove the second lifetime from DiagnosticArg. 2024-01-30 18:46:08 +11:00