Cherry-picked from https://github.com/elixir-lang/elixir/commit/6f2c669a98c33d3c98a50c023b0434bb79041c89