Remove unnecessary unsafe from format_args expansion
This commit is contained in:
parent
c296e77767
commit
6f819e30e4
@ -199,9 +199,7 @@ macro_rules! format_args {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
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), ])
|
||||
};
|
||||
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), ]);
|
||||
}
|
||||
"##]],
|
||||
);
|
||||
@ -229,9 +227,7 @@ macro_rules! format_args {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
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), ])
|
||||
};
|
||||
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), ]);
|
||||
}
|
||||
"##]],
|
||||
);
|
||||
@ -262,9 +258,7 @@ macro_rules! format_args {
|
||||
fn main() {
|
||||
let _ =
|
||||
/* parse error: expected field name or number */
|
||||
unsafe {
|
||||
std::fmt::Arguments::new_v1(&[], &[std::fmt::ArgumentV1::new(&(a.), std::fmt::Display::fmt), ])
|
||||
};
|
||||
std::fmt::Arguments::new_v1(&[], &[std::fmt::ArgumentV1::new(&(a.), std::fmt::Display::fmt), ]);
|
||||
}
|
||||
"##]],
|
||||
);
|
||||
|
@ -261,13 +261,7 @@ fn format_args_expand(
|
||||
quote! { std::fmt::ArgumentV1::new(&(#arg), std::fmt::Display::fmt), }
|
||||
}.token_trees);
|
||||
let expanded = quote! {
|
||||
// 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])
|
||||
}
|
||||
std::fmt::Arguments::new_v1(&[], &[##arg_tts])
|
||||
};
|
||||
ExpandResult::ok(expanded)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user