Skip to content

Commit

Permalink
fix: escape keyword when resolving path in workspace (#212)
Browse files Browse the repository at this point in the history
fix: escape keyword when resolving path in workspace mode

Co-authored-by: $wangjie.wjdew <[email protected]>
  • Loading branch information
Ggiggle and $wangjie.wjdew authored Nov 13, 2023
1 parent 2c0ecc7 commit f854364
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pilota-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pilota-build"
version = "0.9.6"
version = "0.9.7"
edition = "2021"
description = "Compile thrift and protobuf idl into rust code at compile-time."
documentation = "https://docs.rs/pilota-build"
Expand Down
11 changes: 4 additions & 7 deletions pilota-build/src/middle/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ impl PathResolver for DefaultPathResolver {
#[derive(Debug)]
enum Kind {
Super,
Ident(FastStr),
Ident(Symbol),
}

let path = (0..p1.len() - i)
.map(|_| Kind::Super)
.chain((i..p2.len()).map(|i| Kind::Ident(p2[i].clone().0)))
.chain((i..p2.len()).map(|i| Kind::Ident(p2[i].clone())))
.collect::<Vec<_>>();

let _length = path.len();

for (_idx, k) in path.into_iter().enumerate() {

Check warning on line 97 in pilota-build/src/middle/resolver.rs

View workflow job for this annotation

GitHub Actions / clippy

you seem to use `.enumerate()` and immediately discard the index

warning: you seem to use `.enumerate()` and immediately discard the index --> pilota-build/src/middle/resolver.rs:97:26 | 97 | for (_idx, k) in path.into_iter().enumerate() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index = note: `#[warn(clippy::unused_enumerate_index)]` on by default help: remove the `.enumerate()` call | 97 | for k in path.into_iter() { | ~ ~~~~~~~~~~~~~~~~
segs.push(match k {
Kind::Super => "super".into(),
Kind::Ident(ident) => Symbol::from(ident).to_string(),
Kind::Ident(ident) => ident.to_string(),
});
}
segs.into_iter().join("::").into()
Expand Down Expand Up @@ -135,10 +135,7 @@ impl PathResolver for WorkspacePathResolver {
if p2[0] == p1[0] {
DefaultPathResolver.related_path(p1, p2)
} else {
let mut segs = vec![];
p2.iter().for_each(|s| segs.push(s.clone()));

format!("::{}", segs.join("::")).into()
format!("::{}", p2.iter().map(|s| s.to_string()).join("::")).into()
}
}
}

0 comments on commit f854364

Please sign in to comment.