Make the crust: Mix flour and salt in a bowl. Cut in cold butter until crumbly, then add ice water, one tablespoon at a time, until the dough holds together. Shape into a disk, wrap in plastic, and chill for 30 minutes.
Roll and bake: Preheat oven to 375°F (190°C). Roll out the dough and press it into a 9-inch pie dish. Prick the bottom with a fork, line with parchment, and add pie weights. Bake for 15 minutes, remove weights, and bake another 5–7 minutes until golden. Let cool.
Make the filling: In a saucepan, whisk sugar, cocoa, cornstarch, and salt. Slowly whisk in milk until smooth. Cook over medium heat, stirring constantly, until thick (8–10 minutes).
Temper the eggs: Beat egg yolks in a bowl. Slowly whisk in some of the hot chocolate mixture, then pour it back into the saucepan. Cook for 2 more minutes, stirring until smooth. Remove from heat and mix in butter and vanilla.
Assemble and chill: Pour the warm filling into the crust. Let cool for 30 minutes, then cover with plastic wrap (pressed onto the surface) and refrigerate for at least 4 hours.
Whip and garnish: Beat heavy cream, powdered sugar, and vanilla until soft peaks form. Spread or pipe onto the pie. Garnish with chocolate shavings or cocoa powder.