Keep attribute spans in extern_protocol! #888
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 220 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.323
Real PR Conversation Timeline
1 comments
"Review active on #888"
general
weight: 0.35
madsmtm
Fixes #887.
extern_protocol!matched each attribute as#[$($attrs:tt)]and wrote it back as#[...], so the#and the brackets came from the macro. Clippy ignores docs from an external macro, somissing_safety_docfired on every protocol trait, even with a# Safetysection.Each attribute is now moved as its two tokens,
#and[...], so it keeps the caller's span:extern_protocol!hands its input to__extern_protocol_attributes!, which moves one attribute per step until it reaches the trait.__extract_attributes_inner!matches$pound:tt $group:ttinstead of#[$($parsed:tt)].define_class!andextern_class!share that arm and behave as before.__extern_protocol_check_syntax!, so invalid input is still reported against it.Testing
crates/objc2/tests/extern_protocol.rs, under#![deny(clippy::missing_safety_doc)]: a protocol with a# Safetysection must pass, and one without it carries#[expect(clippy::missing_safety_doc)], so the lint must still fire. It is an integration test because a protocol declared inside objc2 is not from an external macro, and does not show the bug.cargo clippy -p objc2 --all-targets -- -D warningsfails on the documented protocol. With this change it passes.cargo test -p objc2passes.#[allow(clippy::missing_safety_doc)]in theextern_protocol!unit test is replaced by a# Safetysection.Recursion limit
The helper adds one expansion step per attribute, so a protocol with a long doc comment uses more of the recursion limit. The longest run of attributes before a protocol in objc2-foundation 0.3.2 is 81, well under its
recursion_limit = "512".🍄