I very much apologize for the late response to your post. I hope information will still be useful to you, and to others who may read your post.
What you describe really isn't unusual, although it hadn't happened to you before. When a person is sleeping and dreaming (thus talking in their sleep), they may physically act out some of the dream content. Have you ever seen a sleeping dog moving their feet as thought they were running? It's much the same principle. Erotic dreams are common, and males experience multiple erections throughout the sleep cycle. Most are not even aware of them, nor are their partners, who are also usually asleep. Some couples actually wake up in the middle of having sexual intercourse. Your boyfriend's actions of rubbing against you in a sexual manner is well within the limits of normal, and it's also normal that he might not recall either the dream or his actions. If he was rough or threatening and such events continue, it may be helpful to speak with a therapist. You didn't mention why you found this event to be scary, but your fears may also be helped by speaking with a therapist.
I hope you are doing well, and I wish you the best.
Faye, RN, MSW