-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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::file
claims that it returns the name of a file, but it returns a relative path
#117605
Comments
Cargo will invoke rustc for local crates with the workspace root as working directory and for dependencies from crates.io with their source directory as working directory. For local crates it then passes a relative path as filename and for crates.io dependencies the absolute path as filename to rustc. |
I'm not sure I understand this part. Could you give an example? |
If you pass |
Is there any way to test the crates.io behavior without first publishing the crate? EDIT: To clarify, it would be nice to test behavior that relies on (Sorry if this is a little off topic) |
And can I assume that the path would depend on the operating system? E.g. on Windows you would get an absolute path as |
Yes, same behavior applies to git dependencies AFAIK, so you could create a git repo somewhere and depend on it.
Yes |
Closing this as it's not an issue and it works as intended |
@Dylan-DPC Can you tell me why it's "not an issue and working as intended"? I find the documentation to be both factually incorrect and lacking a thorough explanation of how the macro actually behaves. |
Location
https://doc.rust-lang.org/std/macro.file.html
Summary
The docs say:
But in fact, a relative path is returned. For example, if we have
src/main.rs
:This prints "src/main.rs" (on GNU/Linux).
I believe this will be a path relative to the workspace root, though an expert should confirm this.
The text was updated successfully, but these errors were encountered: