-
Notifications
You must be signed in to change notification settings - Fork 13.3k
enable PathBuf
usage in proc_macro bridge, tracked::path
#88909
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
#![feature(track_path)] | ||
#![feature(proc_macro_tracked_env,proc_macro_tracked_path)] | ||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
use proc_macro::*; | ||
|
||
use std::str; | ||
|
||
#[proc_macro] | ||
pub fn access_tracked_paths(_: TokenStream) -> TokenStream { | ||
tracked_path::path("emojis.txt"); | ||
|
||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is undefined behavior though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #87173 it would be possible to safely construct a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest including the |
||
}; | ||
tracked_path::path(invalid); | ||
|
||
TokenStream::new() | ||
} |
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.
Nit (here and in the other files as well): types are usually imported directly, without parent module.