1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! Internal helpers for derive macro code generation.
//!
//! **Not public API. Do not use.** This module is `#[doc(hidden)]` and not
//! covered by semver guarantees. It exists solely for generated code emitted
//! by `#[derive(StackError)]` and `#[suzunari_error]`.
//!
//! Uses the **autoref specialization** technique to conditionally resolve
//! trait-dependent behavior at compile time. When a source type implements
//! the target trait, the inherent method takes priority via autoref.
//! Otherwise, `Deref` coercion kicks in, calling the fallback method.
//! This avoids requiring trait bounds on source types in generated code.
//!
//! See: <https://github.com/dtolnay/case-studies/blob/master/autoref-specialization/README.md>
use crateStackError;
use crateDisplayError;
use Error;
use ;
// ---------------------------------------------------------------------------
// StackSourceResolver — resolves StackError::stack_source()
// ---------------------------------------------------------------------------
/// Wraps a reference and resolves to the inherent `resolve()` method
/// when `T: StackError`, or falls back via `Deref` → `NotStackErrorFallback`
/// when `T` does not implement `StackError`.
;
/// Fallback target via Deref. Always returns `None`.
;
// ---------------------------------------------------------------------------
// DisplayError construction helper for macro-generated code
// ---------------------------------------------------------------------------
/// Creates a [`DisplayError`] with an explicit `get_source` resolver.
///
/// Called exclusively by `#[suzunari_error]` macro-generated code.
/// Use [`DisplayError::new`] in application code.
// ---------------------------------------------------------------------------
// DisplayErrorSourceResolver — resolves get_source fn for DisplayError
// ---------------------------------------------------------------------------
/// Resolves the `get_source` function pointer for [`DisplayError`](crate::DisplayError).
///
/// Uses the same Deref-based autoref specialization as `StackSourceResolver`.
/// When `T: Error + 'static`, the inherent `get_source_fn()` takes priority.
/// Otherwise, Deref falls back to `DisplayErrorSourceFallback`.
///
/// The fallback's `get_source_fn` has a method-level generic `<T>`, so callers
/// must provide an explicit type annotation for inference to succeed:
/// ```ignore
/// let __get_source: fn(&OriginalType) -> Option<&(dyn Error + 'static)>
/// = DisplayErrorSourceResolver(&val).get_source_fn();
/// ```
;
/// Fallback target via Deref. Returns a `get_source` fn that always yields `None`.
;