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
//! Bug Reproducer: Doc examples use incorrect attribute syntax
//!
//! ## Root Cause
//!
//! The inline doc examples in `src/lib.rs` for `AsMut`, `AsRef`, `Deref`, and `DerefMut`
//! use attribute syntax `#[attribute(original)]` with an `original` parameter.
//! However, the actual implementation does not accept any parameters - the correct
//! syntax is just `#[attribute]` without parameters.
//!
//! This was discovered during manual testing when attempting to verify doc examples
//! compile and execute correctly. The examples are marked as `text` blocks (not
//! compiled), but they still mislead users about the correct syntax.
//!
//! ## Why Not Caught
//!
//! The doc examples use `'''text` code blocks instead of `'''rust` or just `'''`,
//! which means rustdoc doesn't compile-check them. This allows syntax errors to
//! persist undetected.
//!
//! ## Fix Applied
//!
//! Changed all four doc examples to use correct attribute syntax:
//! - `#[as_mut(original)]` → `#[as_mut]`
//! - `#[as_ref(original)]` → `#[as_ref]`
//! - `#[deref(original)]` → `#[deref]`
//! - `#[deref_mut(original)]` → `#[deref_mut]`
//!
//! ## Prevention
//!
//! 1. Use `'''rust` or `'''` instead of `'''text` for doc examples so rustdoc
//! compile-checks them
//! 2. Add integration tests that verify doc example syntax matches test suite
//! 3. Include doc example validation in CI pipeline
//!
//! ## Pitfall
//!
//! Doc examples marked as `text` blocks bypass all compile-time validation,
//! making it easy for syntax errors to persist. Only use `text` blocks for
//! pseudo-code or examples from external crates that aren't dependencies.
use *;
/// Test 1: `AsMut` with correct syntax (no parameter) - should succeed
/// Test 2: `AsRef` with correct syntax (no parameter) - should succeed
/// Test 3: `Deref` with correct syntax (no parameter) - should succeed
/// Test 4: `DerefMut` with correct syntax (no parameter) - should succeed