-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
enable PathBuf
usage in proc_macro bridge, tracked::path
#88909
enable PathBuf
usage in proc_macro bridge, tracked::path
#88909
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
The job Click to see the possible cause of the failure (guessed by this bot)
|
@@ -406,7 +407,7 @@ impl server::FreeFunctions for Rustc<'_> { | |||
} | |||
|
|||
fn track_path(&mut self, path: &str) { | |||
self.sess.file_depinfo.borrow_mut().insert(Symbol::intern(path)); | |||
self.sess.file_depinfo.borrow_mut().insert(path::PathBuf::from(path)); |
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.
self.sess.file_depinfo.borrow_mut().insert(path::PathBuf::from(path)); | |
self.sess.file_depinfo.borrow_mut().insert(PathBuf::from(path)); |
Nit (here and in the other files as well): types are usually imported directly, without parent module.
// currently only valid utf-8 paths are supported | ||
let invalid = [1_u8, 2,123, 254, 0, 0, 1, 1]; | ||
let invalid: &str = unsafe { | ||
str::from_utf8_unchecked(&invalid[..]) |
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 is undefined behavior though.
I don't think UB is something that we should be testing.
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.
In #87173 it would be possible to safely construct a PathBuf
that is not a valid UTF-8 path and then pass it to libproc_macro.
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 suggest including the AsRef<Path>
part of #87173 into this PR and using it to avoid the UB here.
What is the purpose of changing this internally, if the user-facing interface in |
Technically the limitation does not need to be there, since the internal representation of a |
@rustbot label -S-waiting-on-author +S-waiting-on-review |
@drahnr (Also, #88909 (comment) wasn't addressed.) |
Ping from triage: |
Sorry for lagging behind on this. Will resume working on this soon. |
Thanks, please adjust the label with |
☔ The latest upstream changes (presumably #87264) made this pull request unmergeable. Please resolve the merge conflicts. |
triage: @drahnr any updates? |
Extracted from #87173
Adds limited
PathBuf
support for convenience to theproc_macro
-bridge code. Currently does not handle invalid utf-t cases gracefully.@rustbot assign @petrochenkov