File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
swc_ecma_quote_macros/src/ast Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ swc_core : patch
3+ swc_atoms : patch
4+ swc_ecma_quote_macros : patch
5+ ---
6+
7+ chore(atoms): Fix broken quote macro
Original file line number Diff line number Diff line change @@ -79,6 +79,20 @@ impl Wtf8Atom {
7979 pub fn try_into_atom ( self ) -> Result < Atom , Wtf8Atom > {
8080 self . 0 . try_into_atom ( ) . map ( Atom ) . map_err ( Wtf8Atom )
8181 }
82+
83+ /// Creates a new [Wtf8Atom] from a byte slice.
84+ ///
85+ /// # Safety
86+ ///
87+ /// The caller must ensure that `bytes` is a well-formed WTF-8 byte
88+ /// sequence.
89+ ///
90+ /// See [hstr::wtf8::Wtf8::from_bytes_unchecked] for more details.
91+ pub unsafe fn from_bytes_unchecked ( bytes : & [ u8 ] ) -> Self {
92+ Wtf8Atom ( hstr:: Wtf8Atom :: from (
93+ hstr:: wtf8:: Wtf8 :: from_bytes_unchecked ( bytes) ,
94+ ) )
95+ }
8296}
8397
8498impl Deref for Wtf8Atom {
Original file line number Diff line number Diff line change @@ -41,9 +41,7 @@ impl ToCode for Atom {
4141impl ToCode for Wtf8Atom {
4242 fn to_code ( & self , _: & Ctx ) -> syn:: Expr {
4343 let bytes_literal = LitByteStr :: new ( self . as_bytes ( ) , Span :: call_site ( ) ) ;
44- parse_quote ! ( swc_atoms:: wtf8:: Wtf8Atom :: from( unsafe {
45- swc_atoms:: wtf8:: Wtf8 :: from_bytes_unchecked( #bytes_literal)
46- } ) )
44+ parse_quote ! ( unsafe { swc_atoms:: Wtf8Atom :: from_bytes_unchecked( #bytes_literal) } )
4745 }
4846}
4947
You can’t perform that action at this time.
0 commit comments