Replace proc_macro APIs with proc_macro2 APIs in ostd_macros

This commit is contained in:
jiangjianfeng
2025-06-09 02:13:31 +00:00
committed by Tate, Hongliang Tian
parent 74f322caa4
commit ead5a70444
2 changed files with 6 additions and 8 deletions

View File

@ -12,7 +12,7 @@ repository ="https://github.com/asterinas/asterinas"
proc-macro = true
[dependencies]
proc-macro2 = "1.0.78"
proc-macro2 = { version = "1.0.95", features = ["span-locations"] }
quote = "1.0.35"
rand = "0.8.5"
syn = { version = "2.0.48", features = ["full"] }

View File

@ -320,11 +320,9 @@ pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
};
let package_name = std::env::var("CARGO_PKG_NAME").unwrap();
let span = proc_macro::Span::call_site();
let source = span.source_file().path();
let source = source.to_str().unwrap();
let line = span.line();
let col = span.column();
let span = proc_macro2::Span::call_site();
let line = span.start().line;
let col = span.start().column;
let register_ktest_item = if package_name.as_str() == "ostd" {
quote! {
@ -338,7 +336,7 @@ pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
module_path: module_path!(),
fn_name: stringify!(#fn_name),
package: #package_name,
source: #source,
source: file!(),
line: #line,
col: #col,
},
@ -356,7 +354,7 @@ pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
module_path: module_path!(),
fn_name: stringify!(#fn_name),
package: #package_name,
source: #source,
source: file!(),
line: #line,
col: #col,
},