The fetus is considered legally slaughtered with the legal slaughtering of its mother Sunan Ibn Majah 3199

Arabic hadith text
حَدَّثَنَا أَبُو كُرَيْبٍ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ الْمُبَارَكِ، وَأَبُو خَالِدٍ الأَحْمَرُ وَعَبْدَةُ بْنُ سُلَيْمَانَ عَنْ مُجَالِدٍ، عَنْ أَبِي الْوَدَّاكِ، عَنْ أَبِي سَعِيدٍ، قَالَ سَأَلْنَا رَسُولَ اللَّهِ ـ صلى الله عليه وسلم ـ عَنِ الْجَنِينِ فَقَالَ ‏"‏كُلُوهُ إِنْ شِئْتُمْ فَإِنَّ ذَكَاةَ الْجَنِينِ ذَكَاةُ أُمِّهِ ‏"
Translation
It wasnarrated that Abu Sa’eed said

“We asked the Messenger ofAllah(ﷺ) about the fetus. He said: ‘Eat it if you wish, for it isconsidered legally slaughtered with the slaughtering of its mother.’”