If your application for long-term resident status has been rejectd and you do not have a valid permit in Sweden or an open application with the Swedish Migration Agency, this means that you do not have the right to be in Sweden. If the Swedish Migration Agency rejects your application while you are in Sweden, you will have a certain amount of time to leave the country. The decision will state how long you have to leave Sweden. If you stay longer than the deadline specified in the decision, you will be in the country illegally.
It is your responsibility to make sure you know what applies to you, so that you leave Sweden within the deadline stated in the decision.
If you have appealed the decision, you have the right to remain in Sweden while your appeal is being examined.
Once the decision has become final and can no longer be appealed, you must leave Sweden.