As @moonboots has commented, it depends on what sort of transition you want..
If you were using a sub-d modelling approach, you would keep your pre-subdivision topology to a minimum:
By having only 8 vertices in the circumference of the cup, you make picking a hole with a matching number of vertices from the torus relatively simple:
Allowing you to use Bridge Edge Loops to make your basic fillet. There's a certain amount of adjustment you can make in the tool itself.
After the bridge is made, you can tweak with tools such as:
- The shipped add-on Loop Tools > Circle for the profiles, not forgetting it has an 'Influence' setting, allowing you to interpolate between rectangular and circular
- CtrlB bevelling edge-loops, to tighten corners, create creases..
- Vertex Menu > Smooth, use with care..
- With 'Normal' as you Transform Orientation, and 'Individual Origins'as your Pivot Point, you can make tiny adjustments to individual vertices along their normals.
This shows a basic smooth join, after subdivision, (and a Bevel modifier by angle to sharpen the ridges in the cup):
By having the topology straight and simple, it's relatively easy to make variations, using, for example. simple extrusions of faces along their normals.