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 Windows parse_prefix #74220

Merged
merged 8 commits into from
Jul 14, 2020
Merged

Refactor Windows parse_prefix #74220

merged 8 commits into from
Jul 14, 2020

Conversation

tesuji
Copy link
Contributor

@tesuji tesuji commented Jul 10, 2020

These changes make me feel more readable.
See the commit messages for more details.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 10, 2020
@tesuji tesuji force-pushed the windows-path-com branch 5 times, most recently from ffd7b1f to cb36cdb Compare July 10, 2020 15:59
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Personally, I would appreciate it if you would (at least briefly) describe the changes and (importantly) the motivation for those changes in the PR description. Otherwise I always have the feeling I am missing some context. And even for regular contributors like you, without knowing what those changes are actually good for, one might think "why should I even bother reviewing?". A simple "I think this refactor makes the code more robust and/or more readable" or "See commit messages for more details" would be enough.

Anyhow, the change look fine to me overall. I left a couple of inline comments though.

src/libstd/sys/windows/path.rs Outdated Show resolved Hide resolved
src/libstd/sys/windows/path.rs Outdated Show resolved Hide resolved
) -> Option<(&'a [u8], &'a [u8])> {
let idx = path.iter().position(|&x| f(x))?;
// Remove the path component separator
// SAFETY: `s[idx + 1..] == s[s.len()..]`
Copy link
Member

Choose a reason for hiding this comment

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

That safety comment is confusing IMO. How about something like this?

// SAFETY: `idx + 1` is never larger than `path.len()` and `path[path.len()..]` 
// is a valid index

Either way, is the unsafe even worth it here? Might this be in a hot loop? I have no idea, but if it's unlikely this function is performance critical, I'd rather avoid the unsafe code.

Copy link
Contributor Author

@tesuji tesuji Jul 12, 2020

Choose a reason for hiding this comment

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

I know it is confusing but I couldn't think of any better comments for it.
Thank you for nice suggestion.

Re unsafe, I was haunted by #73396 and outer unsafe block made me feel too powerful to use unsafe here.
Anyway, Nikita assigned to that issue and it would be resolve by next LLVM update, I will drop the unsafe indexing.

src/libstd/sys/windows/path.rs Outdated Show resolved Hide resolved
src/libstd/sys/windows/path.rs Show resolved Hide resolved
src/libstd/sys/windows/path.rs Outdated Show resolved Hide resolved
src/libstd/sys/windows/path.rs Outdated Show resolved Hide resolved
src/libstd/sys/windows/path.rs Outdated Show resolved Hide resolved
@tesuji
Copy link
Contributor Author

tesuji commented Jul 12, 2020

I am really appreciate your quality reviews. I rebased the patch and revolved
most concerns.

Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@LukasKalbertodt
Copy link
Member

Thanks again, also for quickly addressing my comments. Way faster than my response time :D

@bors r+ rollup=iffy

(Let's also try this new rollup command. I don't expect this to fail or anything, but I am always conservative with tagging a PR as rollup.)

@bors
Copy link
Contributor

bors commented Jul 12, 2020

📌 Commit 967e5e38c168da2df30ae0fc04709ac016835684 has been approved by LukasKalbertodt

@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 Jul 12, 2020
@tesuji
Copy link
Contributor Author

tesuji commented Jul 12, 2020

Hi, I renamed the test function. Also I added a new commit e31898b for reducing unsafe scope in parse_prefix.

@LukasKalbertodt
Copy link
Member

Thanks for the unsafe commit! I can't really verify that the unsafety is safe, but since you just moved stuff around and it apparently worked before, I assume it's all fine :P

@bors r+

@bors
Copy link
Contributor

bors commented Jul 14, 2020

📌 Commit e31898b has been approved by LukasKalbertodt

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jul 14, 2020
…bertodt

Refactor Windows `parse_prefix`

These changes make me feel more readable.
See the commit messages for more details.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 14, 2020
…bertodt

Refactor Windows `parse_prefix`

These changes make me feel more readable.
See the commit messages for more details.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 14, 2020
…arth

Rollup of 15 pull requests

Successful merges:

 - rust-lang#71237 (Add Ayu theme to rustdoc)
 - rust-lang#73720 (Clean up E0704 error explanation)
 - rust-lang#73866 (Obviate #[allow(improper_ctypes_definitions)])
 - rust-lang#73965 (typeck: check for infer before type impls trait)
 - rust-lang#73986 (add (unchecked) indexing methods to raw (and NonNull) slices)
 - rust-lang#74173 (Detect tuple struct incorrectly used as struct pat)
 - rust-lang#74220 (Refactor Windows `parse_prefix`)
 - rust-lang#74227 (Remove an unwrap in layout computation)
 - rust-lang#74239 (Update llvm-project to latest origin/rustc/10.0-2020-05-05 commit )
 - rust-lang#74257 (don't mark linux kernel module targets as a unix environment)
 - rust-lang#74270 (typeck: report placeholder type error w/out span)
 - rust-lang#74296 (Clarify the description for rfind)
 - rust-lang#74310 (Use `ArrayVec` in `SparseBitSet`.)
 - rust-lang#74316 (Remove unnecessary type hints from Wake internals)
 - rust-lang#74324 (Update Clippy)

Failed merges:

r? @ghost
@bors
Copy link
Contributor

bors commented Jul 14, 2020

☔ The latest upstream changes (presumably #74330) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 14, 2020
@bors bors merged commit 063bbc4 into rust-lang:master Jul 14, 2020
@tesuji tesuji deleted the windows-path-com branch July 15, 2020 02:21
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants