fix: support qualified types in topic handlers#344
Open
immanuwell wants to merge 1 commit into
Open
Conversation
Signed-off-by: immanuwell <pchpr.00@list.ru>
mikeee
requested changes
Jul 22, 2026
mikeee
left a comment
Member
There was a problem hiding this comment.
I'm in favour of this change with a few changes, please could you clarify whether allowing non-stdlib definitions of String should be allowed as implemented?
I think for the string type assertion it'd be better if we asserted against the entire type path, something like this:
fn is_string_type(ty: &Type) -> bool {
let Type::Path(type_path) = ty else {
return false;
};
if type_path.qself.is_some() {
return false;
}
let path = &type_path.path;
let matches_path = |names: &[&str]| {
path.segments.len() == names.len()
&& path
.segments
.iter()
.zip(names)
.all(|(seg, name)| seg.ident == *name && seg.arguments.is_empty())
};
matches_path(&["String"])
|| matches_path(&["std", "string", "String"])
|| matches_path(&["alloc", "string", "String"])
}wdyt?
Comment on lines
+247
to
+248
| .last() | ||
| .is_some_and(|segment| segment.ident == "String"), |
Member
There was a problem hiding this comment.
Was this intentionally added to allow String types defined by any other crates such as other_crate::String?
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { |
Member
There was a problem hiding this comment.
Thank you for adding tests, please enhance this with negative tests to confirm the above review assumptions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#[topic]blows up if the handler arg uses a qualified type likeserde_json::Value.The macro was splitting tokens on
:soserde_json::Valuegot treated like 2 inputs. This switches it to parse the function signature withsyn, keeps theStringfast path, and adds regression tests. tiny fix, but pretty real.Repro:
Before:
cargo checkpanics withExpected to only have one input variableAfter:
cargo checkpasses.Issue reference
This PR will close #172
Checklist