Uh oh!
There was an error while loading. Please reload this page.
unstable proc_macro tracked::* rename/restructure - #87173
Conversation
rust-highfive
commented
Jul 15, 2021
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
Jul 16, 2021
I'm going to transfer this to the libs API team. I'm not sure what the current library conventions are, but seeing >2 segment paths like use tracked::fs::path as track_path;use tracked::env::var as tracked_env_var;fnmy_proc_macro(){track_path("my_file.txt");// returns nothinglet var = tracked_env_var("MY_VAR");// returns the variable's value} |
Totally understandable, and I don't have a strong opinion, mostly going off of what was discussed in the referenced #84029 issue. If it is at odds with the current naming and module nesting depth, feel free to close. At the very least though, I think it should be unified to either |
joshtriplett
commented
Aug 4, 2021
We discussed this in today's @rust-lang/libs-api meeting. We don't want to see an extra level of submodule nesting here; we should just have Also, separate from this issue, several people in the meeting felt that we shouldn't restrict |
@m-ou-se I'll implement the required changes this week, just wasn't entirely sure what your self assignment implied. |
pksunkara
commented
Aug 11, 2021
Shouldn't we name the functions |
drahnr
commented
Aug 11, 2021
I'd prefer the one module level variants, which is in line with other macro impls iirc:
|
drahnr
commented
Aug 13, 2021
What's meant by |
Pending access to something that can be cast to a byte slice, the impl currently accepts valid UTF-8 only. I am not sure the error handling is as desired. Either way, I'd like some feedback :) Thanks! @rustbot label -S-waiting-on-author +S-waiting-on-review |
petrochenkov
commented
Aug 17, 2021
It's not necessary to return a I'm not sure whether proc macro bridge can support passing |
drahnr
commented
Aug 29, 2021
Technically this would be possible, but that would require to access the currently private I added an implementation adding a |
JohnCSimon
commented
Sep 13, 2021
Ping from triage: |
This comment has been minimized.
This comment has been minimized.
7b4ac2f to
fa67588Compare
This comment has been minimized.
This comment has been minimized.
bors
commented
Dec 5, 2023
☔ The latest upstream changes (presumably #118646) made this pull request unmergeable. Please resolve the merge conflicts. |
rdrpenguin04
commented
May 29, 2024
What's left on this? |
A review, and another rebase, I think. It's been a while. |
m-ou-se
left a comment
There was a problem hiding this comment.
This PR does a few different things at once. One of them is changing the &str type to a PathBuf. That change was requested here and would be fine to merge. The other changes seem unrelated and it's unclear why some of them were made. (E.g. changing the tracking issue, or changing "environment" to "env" in a comment, or reordering some attributes/doc comments, etc.)
| #[unstable(feature = "proc_macro_tracked_env", issue = "99515")] | ||
| #[unstable(feature = "proc_macro_tracked_env", issue = "74690")] |
There was a problem hiding this comment.
Why is the tracking issue changed? #74690 is a closed issue.
| /// interpreted in a platform-specific way at compile time. So, for | ||
| /// instance, an invocation with a Windows path | ||
| /// containing backslashes `\` would not compile correctly on Unix. |
There was a problem hiding this comment.
I find the note on windows/unix paths quite confusing. Who is that note for? What user error is it trying to prevent?
| /// The file is located relative to the current file where the proc-macro | ||
| /// is used (similarly to how modules are found). The provided path is | ||
| /// interpreted in a platform-specific way at compile time. So, for |
There was a problem hiding this comment.
Is it not relative to the current working directory? So if I do File::open("a.txt") and tracked_path::path("a.txt"), can that refer to a different file?
There was a problem hiding this comment.
If I understand the docs correct, this would behave similar to using the include!() family in the macro expansion, which indeed uses a different directory to be relative to than File::open() inside the proc macro. The behavior of include!() is almost certainly what you want. The current working directory that rustc is invoked with when using cargo is effectively undefined.
alex-semenyuk
commented
Dec 27, 2024
@drahnr |
Dylan-DPC
commented
Jan 23, 2025
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
Skgland
commented
Nov 26, 2025
Would it be alright to pick up the "uncontroversial" changes from this i.e. restructuring/renaming and changing AsRef to AsRef? That appear to be the next not blocked step to me. |
unstable proc_macro tracked::* rename/restructure Picking up what should be the uncontroversial part of rust-lang#87173 (closed due to inactivity over two years ago). Part of rust-lang#99515. - move `proc_macro::tracked_env::var` to `proc_macro::tracked::env_var` - move `proc_macro::tracked_path::path` to `proc_macro::tracked::path` - change the argument of `proc_macro::tracked::path` from `AsRef<str>` to `AsRef<Path>`.
Rollup merge of #149400 - Skgland:tracked_mod, r=Amanieu unstable proc_macro tracked::* rename/restructure Picking up what should be the uncontroversial part of #87173 (closed due to inactivity over two years ago). Part of #99515. - move `proc_macro::tracked_env::var` to `proc_macro::tracked::env_var` - move `proc_macro::tracked_path::path` to `proc_macro::tracked::path` - change the argument of `proc_macro::tracked::path` from `AsRef<str>` to `AsRef<Path>`.
unstable proc_macro tracked::* rename/restructure Picking up what should be the uncontroversial part of rust-lang/rust#87173 (closed due to inactivity over two years ago). Part of rust-lang/rust#99515. - move `proc_macro::tracked_env::var` to `proc_macro::tracked::env_var` - move `proc_macro::tracked_path::path` to `proc_macro::tracked::path` - change the argument of `proc_macro::tracked::path` from `AsRef<str>` to `AsRef<Path>`.
Extracted restructure of the unstable
tracked::{fs,env}::*Originally part of #84029
It's slightly clunky to to have three distinct unstable features, since one cannot use two annotations on one
mod tracked {..}declaration.The second thing I am unsure is
rust-analyzerwhich would need some adaption for the new structure.CC @Xanewok