Preheat the oven to 180C/350F/Gas 4. Grease a 20cm/8in cake tin with butter.
For the cake, bring a little water to the boil in a pan. Reduce the heat until the water is simmering, then suspend a heatproof bowl over the water, making sure that the bottom of the bowl does not touch the water.
Add the stout and dark chocolate pieces to the heatproof bowl and heat gently until melted. Once melted, remove the bowl from the heat and set aside to cool.
In a separate bowl, beat together the butter and sugar until light, fluffy and well combined, using either a food processor or electric whisk.
Add the eggs one at a time, beating well between each addition.
Pour in the cooled chocolate-and-stout mixture and beat until well combined. Fold in the flour.
Spoon the cake mixture into the prepared tin and bake in the middle of the oven for 30-35 minutes, or until a skewer inserted into the centre of the cake comes out clean.
Remove the cake from the oven and set aside to cool in the tin for a few minutes, then remove from the tin and set aside to cool completely on a wire rack.
Meanwhile, for the icing, repeat the process of bringing a little water to the boil in a pan. Reduce the heat until the water is simmering, then suspend a heatproof bowl over the water, making sure that the bottom of the bowl does not touch the water.
Add the chocolate, butter and stout to the bowl, stirring until just melted. Remove the bowl from the heat and set the mixture aside to cool slightly.
When the melted chocolate mixture has cooled, transfer it to a food processor, add the icing sugar and pulse until smooth and well combined. (Alternatively, whisk in the icing sugar using a hand-held electric mixer.)
When the cake has completely cooled, spread the icing evenly over the top and sides, then sprinkle over the chopped hazelnuts. When the icing has dried, serve.