-
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
unstable proc_macro tracked::* rename/restructure #87173
base: master
Are you sure you want to change the base?
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
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;
fn my_proc_macro() {
track_path("my_file.txt"); // returns nothing
let 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 |
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. |
Shouldn't we name the functions |
I'd prefer the one module level variants, which is in line with other macro impls iirc:
|
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 |
It's not necessary to return a I'm not sure whether proc macro bridge can support passing |
Technically this would be possible, but that would require to access the currently private I added an implementation adding a |
Ping from triage: |
@drahnr any updates on this pr? |
@Dylan-DPC If everything goes well, I can take another look at splitting things up next week~ish according along with #87173 (comment) and drop the remaining changes. I frankly forgot about the issue. |
@drahnr any updates on this? |
Back on it. |
0c57e65
to
a46a7ba
Compare
Some changes occurred in src/tools/rust-analyzer cc @rust-lang/rust-analyzer |
This comment has been minimized.
This comment has been minimized.
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
7b4ac2f
to
fa67588
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #118646) made this pull request unmergeable. Please resolve the merge conflicts. |
What's left on this? |
A review, and another rebase, I think. It's been a while. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@drahnr |
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-analyzer
which would need some adaption for the new structure.CC @Xanewok