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

refactor: replace CStr::from_ptr(ptr).to_str() with from_utf8_unchecked #66

Merged
merged 1 commit into from
Jan 3, 2020
Merged

refactor: replace CStr::from_ptr(ptr).to_str() with from_utf8_unchecked #66

merged 1 commit into from
Jan 3, 2020

Conversation

legendiguess
Copy link
Contributor

closes #53

@codecov
Copy link

codecov bot commented Dec 7, 2019

Codecov Report

Merging #66 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #66      +/-   ##
==========================================
- Coverage   72.09%   72.09%   -0.01%     
==========================================
  Files         109      109              
  Lines        7279     7278       -1     
==========================================
- Hits         5248     5247       -1     
  Misses       2031     2031
Impacted Files Coverage Δ
crates/mun_abi/src/autogen_impl.rs 98.42% <100%> (-0.01%) ⬇️
crates/mun_target/src/spec/windows_msvc_base.rs 100% <0%> (ø) ⬆️
...ates/mun_target/src/spec/x86_64_pc_windows_msvc.rs 100% <0%> (ø) ⬆️
crates/mun_codegen/src/code_gen/linker.rs 35.63% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6896708...1541276. Read the comment docs.

@Wodann Wodann self-requested a review December 9, 2019 16:30
Copy link
Collaborator

@Wodann Wodann left a comment

Choose a reason for hiding this comment

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

Thank you for you PR. Good find to reuse the CStr::from_ptr function to convert a null-terminated C-style string into a u8 slice 👍

I added one request for change, as we only need to replace the UTF-8 validation in the ABI. If you could revert the changes to crates/mun_runtime_capi/src/lib.rs that'd be great :)

There is one other thing that needs to happen before we can merge this PR. Issue #53 depends on issue #52. That issue adds unit tests to validate that our compiler always generates valid UTF-8 strings. Once that issue has been closed, we can guarantee that there will not be any runtime regressions. If you have time, would you be interested in having a look at issue #52 as well? It will introduce you to an important development aspect of Mun; namely regression testing.

crates/mun_runtime_capi/src/lib.rs Outdated Show resolved Hide resolved
@Wodann
Copy link
Collaborator

Wodann commented Dec 10, 2019

Thank you for the improvements. It all looks good now.

I'll still hold on merging until issue #52 has been resolved.

@Wodann Wodann merged commit 66f62a3 into mun-lang:master Jan 3, 2020
@Wodann Wodann added this to the Mun v0.2 milestone May 14, 2020
This pull request was closed.
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 this pull request may close these issues.

Replace CStr::from_ptr(ptr).to_str() occurences with str::from_utf8_unchecked calls
2 participants