mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(ast): add comment not to use AstBuilder::copy (#3891)
As discussed in #3483, `AstBuilder::copy` is unsound. It's going to be a hard slog removing all uses of it. This PR adds a comment to please not introduce any further usages of it in meantime.
This commit is contained in:
parent
5902331cac
commit
442aca3ba8
1 changed files with 5 additions and 3 deletions
|
|
@ -68,11 +68,13 @@ impl<'a> AstBuilder<'a> {
|
|||
Atom::from(String::from_str_in(value, self.allocator).into_bump_str())
|
||||
}
|
||||
|
||||
/// # SAFETY
|
||||
/// This method is completely unsound and should not be used.
|
||||
/// We need to remove all uses of it. Please don't add any more!
|
||||
/// <https://github.com/oxc-project/oxc/issues/3483>
|
||||
#[inline]
|
||||
pub fn copy<T>(self, src: &T) -> T {
|
||||
// SAFETY:
|
||||
// This should be safe as long as `src` is an reference from the allocator.
|
||||
// But honestly, I'm not really sure if this is safe.
|
||||
// SAFETY: Not safe (see above)
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
std::mem::transmute_copy(src)
|
||||
|
|
|
|||
Loading…
Reference in a new issue