mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
9b45cfdbdd
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? |
||
---|---|---|
.. | ||
impl-trait | ||
rfc-0000-never_patterns | ||
rfc-0107-bind-by-move-pattern-guards | ||
rfc-1014-stdout-existential-crisis | ||
rfc-1445-restrict-constants-in-patterns | ||
rfc-1623-static | ||
rfc-1717-dllimport | ||
rfc-1789-as-cell | ||
rfc-1857-stabilize-drop-order | ||
rfc-1937-termination-trait | ||
rfc-2005-default-binding-mode | ||
rfc-2008-non-exhaustive | ||
rfc-2027-object-safe-for-dispatch | ||
rfc-2091-track-caller | ||
rfc-2093-infer-outlives | ||
rfc-2126-crate-paths | ||
rfc-2126-extern-absolute-paths | ||
rfc-2151-raw-identifiers | ||
rfc-2175-or-if-while-let | ||
rfc-2294-if-let-guard | ||
rfc-2302-self-struct-ctor | ||
rfc-2306-convert-id | ||
rfc-2361-dbg-macro | ||
rfc-2396-target_feature-11 | ||
rfc-2397-do-not-recommend | ||
rfc-2421-unreserve-pure-offsetof-sizeof-alignof | ||
rfc-2457-non-ascii-idents | ||
rfc-2497-if-let-chains | ||
rfc-2528-type-changing-struct-update | ||
rfc-2565-param-attrs | ||
rfc-2627-raw-dylib | ||
rfc-2632-const-trait-impl | ||
rfc-3348-c-string-literals | ||
type-alias-impl-trait |