Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support r# in the module path #148

Closed
liuchengxu opened this issue Apr 7, 2022 · 2 comments · Fixed by #149
Closed

Support r# in the module path #148

liuchengxu opened this issue Apr 7, 2022 · 2 comments · Fixed by #149

Comments

@liuchengxu
Copy link
Contributor

liuchengxu commented Apr 7, 2022

scale-info now complains that All path segments should be valid Rust identifiers if a module path contains r#, uncovered in subspace/subspace#330.

A quick solution could be simply ignoring r# in my opinion, not sure whether it has other side effects though.

@@ -97,7 +84,16 @@ impl Path {
     ///
     /// - If the type identifier or module path contain invalid Rust identifiers
     pub fn new(ident: &'static str, module_path: &'static str) -> Path {
-        let mut segments = module_path.split("::").collect::<Vec<_>>();
+        let mut segments = module_path
+            .split("::")
+            .map(|s| {
+                if let Some(stripped) = s.strip_prefix("r#") {
+                    stripped
+                } else {
+                    s
+                }
+            })
+            .collect::<Vec<_>>();

CC @nazar-pc

@ascjones
Copy link
Contributor

ascjones commented Apr 8, 2022

Thank you for the bug report. See #149 for a fix

@liuchengxu
Copy link
Contributor Author

That seems to be cleaner, Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants