rust/tests/ui/diagnostic_namespace/do_not_recommend
Georg Semmler 9b45cfdbdd
Actually use the `#[do_not_recommend]` attribute if present
This change tweaks the error message generation to actually use the
`#[do_not_recommend]` attribute if present by just skipping the marked
trait impl in favour of the parent impl. It also adds a compile test for
this behaviour. Without this change the test would output the following
error:

```
error[E0277]: the trait bound `&str: Expression` is not satisfied
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15
   |
LL |     SelectInt.check("bar");
   |               ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>`
   |
   = help: the following other types implement trait `Expression`:
             Bound<T>
             SelectInt
note: required for `&str` to implement `AsExpression<Integer>`
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13
   |
LL | impl<T, ST> AsExpression<ST> for T
   |             ^^^^^^^^^^^^^^^^     ^
LL | where
LL |     T: Expression<SqlType = ST>,
   |        ------------------------ unsatisfied trait bound introduced here
```

Note how that mentions `&str: Expression` before and now mentions `&str:
AsExpression<Integer>` instead which is much more helpful for users.

Open points for further changes before stabilization:

* We likely want to move the attribute to the `#[diagnostic]` namespace
to relax the guarantees given?
* How does it interact with the new trait solver?
2024-05-19 08:29:27 +02:00
..
as_expression.current.stderr Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
as_expression.next.stderr Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
as_expression.rs Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
simple.current.stderr Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
simple.next.stderr Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
simple.rs Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
stacked.current.stderr Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
stacked.next.stderr Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00
stacked.rs Actually use the `#[do_not_recommend]` attribute if present 2024-05-19 08:29:27 +02:00