Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Replaced unsound `ptr::read` with safe unbox in panic recovery, removing UB from potential double-drop ([#2934](https://github.com/0xMiden/miden-vm/pull/2934)).
- Reverted `InvokeKind::ProcRef` back to `InvokeKind::Exec` in `visit_mut_procref` and added an explanatory comment (#2893).
- Fixed the release dry-run publish cycle between `miden-air` and `miden-ace-codegen`, and preserved leaf-only DAG imports with explicit snapshots ([#2931](https://github.com/0xMiden/miden-vm/pull/2931)).
- Canonicalized `PathBuf::try_from(String)` to match `TryFrom<&str>`/`FromStr`, so semantically equivalent quoted path components compare and hash consistently.

#### Changes

Expand Down
12 changes: 10 additions & 2 deletions crates/assembly-syntax/src/ast/path/path_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ impl TryFrom<String> for PathBuf {
type Error = PathError;

fn try_from(value: String) -> Result<Self, Self::Error> {
Path::validate(&value)?;
Ok(PathBuf { inner: value })
PathBuf::new(&value)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always reallocate, we only want to reallocate if we need to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bitwalker Updated. Please take another look, thanks for your time.

}
}

Expand Down Expand Up @@ -574,6 +573,15 @@ mod tests {
assert_eq!(parent.parent().map(|p| p.as_str()), Some("::\"root_ns:root@1.0.0\""));
}

#[test]
fn try_from_string_canonicalizes_like_str() {
let from_str = PathBuf::try_from("foo::\"bar\"").unwrap();
let from_string = PathBuf::try_from(alloc::string::String::from("foo::\"bar\"")).unwrap();

assert_eq!(from_string, from_str);
assert_eq!(from_string.as_str(), "foo::bar");
}

#[test]
fn exec_path() {
let path = PathBuf::new("$exec::bar::baz").unwrap();
Expand Down
Loading