I know I'm a bit late to the party here, and perhaps this should be combined with the other answer, but here goes:
Pastry dough is made of butter, flour and water1; worked together with specific techniques, and shaped into a specific final form. Pastry dough is typically light and flaky with a tender inside. Anything made with pastry dough (sweet or savory) can be "a pastry".*
1) In place of butter, any fat (such as shortening or lard) may be used. A flavor enhancing liquid (such as brandy) for may be used in place of plain water.
Pastry includes croissants, some pie crusts, Danishes, tarts, baklava, pat a choux, as well as things made with phyllo dough or puff pastry.
Baked goods made with batter (batter can be poured) or which are constructed via the creaming method (beating sugar into fat creates air bubbles) are not pastry. This includes cake, cookies (biscuits in the UK), standard doughnuts, waffles, meringues, graham cracker pie crusts and quick-bread style muffins. Dough made with yeast or little fat is not pastry; this includes bread, rolls,
While a "pastry chef" is a chef who specializes in desserts, and a "pastry shop" would serve all kinds of sweets, I think that these terms have come about because it sounds better than "dessert chef".