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

[std] Osstr lossy example #56142

Merged
merged 1 commit into from
Dec 14, 2018
Merged

[std] Osstr lossy example #56142

merged 1 commit into from
Dec 14, 2018

Conversation

jnqnfe
Copy link
Contributor

@jnqnfe jnqnfe commented Nov 21, 2018

No description provided.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 21, 2018
@alexcrichton
Copy link
Member

Thanks for the PR! Can this be implemented as an example without making it memory unsafe though? As-is this is susceptible to future breakage because the example itself is exhibiting memory unsafety.

@jnqnfe
Copy link
Contributor Author

jnqnfe commented Nov 28, 2018

Thanks for the PR! Can this be implemented as an example without making it memory unsafe though? As-is this is susceptible to future breakage because the example itself is exhibiting memory unsafety.

The only options are (as far as I can see)
a) doing it the way I have, via an unchecked String
b) transmuting a byte array, which I'd assume you'd object to more
c) splitting the example to work differently on different platforms, to take advantage of the from-byte-slice unix extension method, which would be a mess

otherwise the OsStr methods in std would need to be extended to provide a cleaner solution

fyi, this and a couple of other similar push requests were a precursor to a further push request to extend OsStr handling in std to allow splitting, as needed by an upcoming v2.0 of my cmd-line arg parsing library (which is currently having to transmute). I started investigating how best to implement that, but never got around to finishing. The best solution for that would likely be to just open up from/to byte array methods, perhaps with method names like to_storage_byes to try to help reinforce the message that OsStr does not store the string in the OS form on some platforms.

@alexcrichton
Copy link
Member

Yes to implement this the best way would be via the OS extension traits such as OsStr::from_bytes on Unix.

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 3, 2018
@XAMPPRocky
Copy link
Member

Triage; @jnqnfe Hello, have you been able to get back to this PR?

@jnqnfe jnqnfe force-pushed the osstr_lossy_example branch from d89c4d0 to 0008e0d Compare December 12, 2018 18:16
@jnqnfe
Copy link
Contributor Author

jnqnfe commented Dec 12, 2018

@Aaronepower @alexcrichton Yes, sorry for the delay, I'm largely working offline with no internet from home.

I've reworked the change as suggested. I also fixed it so that it will actually work correctly on Windows, having corrected a misunderstanding from not examining closely enough what the Windows/WTF-8 to-lossy code was doing.

@alexcrichton
Copy link
Member

@bors: r+

Looks good to me, thanks!

@bors
Copy link
Contributor

bors commented Dec 12, 2018

📌 Commit 0008e0d has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 12, 2018
@bors
Copy link
Contributor

bors commented Dec 13, 2018

⌛ Testing commit 0008e0d with merge 9d1f8f1c6ed41d9d60ec402a1c345b2838cfe6e6...

@bors
Copy link
Contributor

bors commented Dec 13, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 13, 2018
@rust-highfive
Copy link
Collaborator

The job dist-i686-freebsd of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
Building stage2 tool cargo (i686-unknown-freebsd)
[01:08:29]  Downloading crates ...
[01:08:49] warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
[01:09:09] warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
[01:09:29] error: failed to download from `https://crates.io/api/v1/crates/openssl-src/111.1.0+1.1.1a/download`
[01:09:29] Caused by:
[01:09:29]   [6] Couldn't resolve host name (Could not resolve host: crates.io)
[01:09:29] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "i686-unknown-freebsd" "-j" "4" "--release" "--locked" "--color" "always" "--manifest-path" "/checkout/src/tools/cargo/Cargo.toml" "--features" "rustc-workspace-hack/all-static" "--message-format" "json"
[01:09:29] expected success, got: exit code: 101
---
travis_time:end:22f3fd00:start=1544685027560141474,finish=1544685027571474577,duration=11333103
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0ed8d9f4
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:07bdec5d
travis_time:start:07bdec5d
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0161be90
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@kennytm
Copy link
Member

kennytm commented Dec 13, 2018

@bors retry travis-ci/travis-ci#9696

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 13, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Dec 13, 2018
@jnqnfe jnqnfe mentioned this pull request Dec 13, 2018
@bors
Copy link
Contributor

bors commented Dec 13, 2018

⌛ Testing commit 0008e0d with merge 5900dae...

bors added a commit that referenced this pull request Dec 13, 2018
@bors
Copy link
Contributor

bors commented Dec 14, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 5900dae to master...

@bors bors merged commit 0008e0d into rust-lang:master Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants