Mining companies have dug themselves out of a hole