about summary refs log tree commit diff
path: root/tests/ui/diagnostic_namespace
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-10-24 22:16:43 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-11-02 03:08:04 +0000
commitb7fc1a743122e3c45f105a5d1169a042a2c6e8bf (patch)
tree1e26a4fee38823f1ba577c5aae2109643c955136 /tests/ui/diagnostic_namespace
parent7c7bb7dc017545db732f5cffec684bbaeae0a9a0 (diff)
downloadrust-b7fc1a743122e3c45f105a5d1169a042a2c6e8bf.tar.gz
rust-b7fc1a743122e3c45f105a5d1169a042a2c6e8bf.zip
Add trait diff highlighting logic and use it in E0277
When a trait is not implemented for a type, but there *is* an `impl`
for another type or different trait params, we format the output to
use highlighting in the same way that E0308 does for types.

The logic accounts for 3 cases:
- When both the type and trait in the expected predicate and the candidate are different
- When only the types are different
- When only the trait generic params are different

For each case, we use slightly different formatting and wording.
Diffstat (limited to 'tests/ui/diagnostic_namespace')
-rw-r--r--tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr3
-rw-r--r--tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr3
2 files changed, 4 insertions, 2 deletions
diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr
index 41f222e46a7..5d0c1826411 100644
--- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr
+++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr
@@ -4,7 +4,8 @@ error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied
 LL |     SelectInt.check("bar");
    |               ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str`
    |
-   = help: the trait `AsExpression<Text>` is implemented for `&str`
+   = help: the trait `AsExpression<Integer>` is not implemented for `&str`
+           but trait `AsExpression<Text>` is implemented for it
    = help: for that trait implementation, expected `Text`, found `Integer`
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr
index 8c01b61191e..1e1eae852f9 100644
--- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr
+++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr
@@ -22,7 +22,8 @@ error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied
 LL |     SelectInt.check("bar");
    |               ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str`
    |
-   = help: the trait `AsExpression<Text>` is implemented for `&str`
+   = help: the trait `AsExpression<Integer>` is not implemented for `&str`
+           but trait `AsExpression<Text>` is implemented for it
    = help: for that trait implementation, expected `Text`, found `Integer`
 
 error[E0271]: type mismatch resolving `<SelectInt as Expression>::SqlType == Text`