If you attach a pistol to a rifle then you have manufactured a short-barreled rifle and must have the appropriate paperwork from the ATF-NFA Branch or else you have committed a felony.
But plenty of dumbshits will do it anyways, just like how they add a vertical foregrip to their pistol and don't realize they, too, are violating the 1934 National Firearms Act and could spend decades in prison.