Skip to content

Commit a15b80f

Browse files
committed
Make deprecated description return empty string
1 parent d340931 commit a15b80f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

0000-bury-description.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,20 @@ Let's steer users away from the `description()` method.
2626
# Reference-level explanation
2727
[reference-level-explanation]: #reference-level-explanation
2828

29-
The description method can have default implementation returning `core::intrinsics::type_name::<Self>()`. This preserves basic functionality of this method for backwards compatibility.
30-
3129
Users of the `Error` trait can then pretend this method does not exist.
3230

3331
# Drawbacks
3432
[drawbacks]: #drawbacks
3533

36-
When users start omitting bespoke `description()` implementations, code that still uses this method will get machine-generated rather than human-written descriptions. If this becomes a problem, the `description()` method can also be formally deprecated (with the `#[deprecated]` attribute). However, this RFC does not propose formal deprecation at this time to avoid unnecessary warnings during the transition.
34+
When users start omitting bespoke `description()` implementations, code that still uses this method will start getting empty strings instead of human-written description. If this becomes a problem, the `description()` method can also be formally deprecated (with the `#[deprecated]` attribute). However, there's no urgency to remove existing implementations of `description()`, so this RFC does not propose formal deprecation at this time to avoid unnecessary warnings during the transition.
3735

3836
# Rationale and alternatives
3937
[alternatives]: #alternatives
4038

4139
- Do nothing, and rely on 3rd party crates to improve usability of errors (e.g. various crates providing `Error`-implementing macros or the `Fail` trait).
4240
- The default message returned by `description` could be different.
43-
- it could be even less useful to discourage use of this method harder, e.g. just `"error"`,
41+
- it could be a hardcoded generic string, e.g. `"error"`,
42+
- it could return `core::intrinsics::type_name::<Self>()`,
4443
- it could try to be nicer, e.g. use the type's doccomment as the description, or convert type name to a sentence (`FileNotFoundError` -> "error: file not found").
4544

4645
# Unresolved questions

0 commit comments

Comments
 (0)