-
Notifications
You must be signed in to change notification settings - Fork 13k
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
fs::list_dir should only return the contents of the directory #1919
Comments
I'm not sure how to determine what the correct behavior is. Is Assigning to @brson since he seems to have touched this code. |
The main issue is that there doesn't seem to be an easy way to get a directory listing without accidentally prepending the current directory to every entry returned. So currently, if I want to find the entries in a directory, I need to use fs::list_dir then slice off the section of the string dealing with the current directory. It's much easier to join two paths than it is to remove a path. If I don't want to go about modifying the string that many times (fs::list_dir goes out of its way to prepend the directory name), my only current choice is to start messing around with opendir and readdir in native code. To do something as simple as listing a directory, I really shouldn't have to start messing around with pointers and unsafe code. |
I do appear to have touched this code as I wrote the only bit of code that actually uses it. I don't remember why it behaves the way it does - probably because that is the exact functionality that rustc needed at the time - but let's change it to do the more intuitive thing. @jsternberg are you interested in making the change? |
Oh, cargo uses it more than rustc, so clearly there's a good use case for the current behavior. Maybe we should split it into two functions, or at least make sure there's an easy one-liner to get the current behavior. |
Yea, I can make the change at some point this weekend. If cargo is the only thing that uses it, I'll change that too. |
Fixed by 3a0477c. Thanks @jsternberg |
- Change `#[kani::proof]` expansion so it doesn't include `#[no_mangle]` but includes `[allow(dead_code)]`. (rust-lang#661 and rust-lang#689). - Add a check for harnesses with arguments and merge the checks into one function (rust-lang#1919). Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>
Currently using fs::list_dir will append the directory name to the front of every entry. I think fs::list_dir should only return the contents of the directory, and maybe another utility function should use fs::list_dir to give the current behavior.
The only other way I can see to access the contents of a directory is with os_fs::list_dir, but that seems like it's not supposed to be public. A comment in the source code has:
The text was updated successfully, but these errors were encountered: