Skip to content

Commit

Permalink
Merge #10032
Browse files Browse the repository at this point in the history
10032: Fix missing unsafe block for the nightly change r=lnicola a=oxalica

Fix #10022

Tested via vscode extension.

Co-authored-by: oxalica <[email protected]>
  • Loading branch information
bors[bot] and oxalica authored Aug 26, 2021
2 parents 793389b + 15eccf2 commit 55d4813
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/hir_expand/src/builtin_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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),])}"#
]],
);
}
Expand All @@ -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),])}"#
]],
);
}
Expand Down

0 comments on commit 55d4813

Please sign in to comment.