The key things to look for on a Shimano rear derailleur are series to figure out if it is 8, 9, 10, or 11 speed and cage length to determine gear capacity. Since you say your Trek has an 8 speed cassette and bottom line parts I'm guessing Shimano 2300. The big question is whether you have a double or triple crank since that affects the cage length needed, doubles typically use a short cage, triples use a mid length cage, the exception is doubles with very wide range cassettes with 30 or 32 tooth cogs which need a mid cage.
Current 105 10 speed is 5700 series and you may still find the occasional 5600 series part, either of these will work with your 2300 shifters, i would avoind the new 5800 series 11 speed part since I think its cable pull ratio is different. If you change to a 105 10 speed shifter then you also need a 10 speed cassette.