mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Merge #10032
10032: Fix missing unsafe block for the nightly change r=lnicola a=oxalica Fix #10022 Tested via vscode extension. Co-authored-by: oxalica <oxalicc@pm.me>
This commit is contained in:
commit
55d4813561
1 changed files with 9 additions and 3 deletions
|
@ -256,7 +256,13 @@ fn format_args_expand(
|
|||
quote! { std::fmt::ArgumentV1::new(&(#arg), std::fmt::Display::fmt), }
|
||||
}.token_trees);
|
||||
let expanded = quote! {
|
||||
std::fmt::Arguments::new_v1(&[], &[##arg_tts])
|
||||
// It's unsafe since https://github.com/rust-lang/rust/pull/83302
|
||||
// Wrap an unsafe block to avoid false-positive `missing-unsafe` lint.
|
||||
// FIXME: Currently we don't have `unused_unsafe` lint so an extra unsafe block won't cause issues on early
|
||||
// stable rust-src.
|
||||
unsafe {
|
||||
std::fmt::Arguments::new_v1(&[], &[##arg_tts])
|
||||
}
|
||||
};
|
||||
ExpandResult::ok(expanded)
|
||||
}
|
||||
|
@ -762,7 +768,7 @@ mod tests {
|
|||
format_args!("{} {:?}", arg1(a, b, c), arg2);
|
||||
"#,
|
||||
expect![[
|
||||
r#"std::fmt::Arguments::new_v1(&[], &[std::fmt::ArgumentV1::new(&(arg1(a,b,c)),std::fmt::Display::fmt),std::fmt::ArgumentV1::new(&(arg2),std::fmt::Display::fmt),])"#
|
||||
r#"unsafe{std::fmt::Arguments::new_v1(&[], &[std::fmt::ArgumentV1::new(&(arg1(a,b,c)),std::fmt::Display::fmt),std::fmt::ArgumentV1::new(&(arg2),std::fmt::Display::fmt),])}"#
|
||||
]],
|
||||
);
|
||||
}
|
||||
|
@ -779,7 +785,7 @@ mod tests {
|
|||
format_args!("{} {:?}", a::<A,B>(), b);
|
||||
"#,
|
||||
expect![[
|
||||
r#"std::fmt::Arguments::new_v1(&[], &[std::fmt::ArgumentV1::new(&(a::<A,B>()),std::fmt::Display::fmt),std::fmt::ArgumentV1::new(&(b),std::fmt::Display::fmt),])"#
|
||||
r#"unsafe{std::fmt::Arguments::new_v1(&[], &[std::fmt::ArgumentV1::new(&(a::<A,B>()),std::fmt::Display::fmt),std::fmt::ArgumentV1::new(&(b),std::fmt::Display::fmt),])}"#
|
||||
]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue