[Changed Subscribers] D10839: rhg: propogate error coming from HgError::Abort to CommandError

SimonSapin phabricator at mercurial-scm.org
Mon Jun 7 15:00:27 UTC 2021


SimonSapin added inline comments.

INLINE COMMENTS

> error.rs:131-133
> +            ConfigError::Other(HgError::Abort(message, exit_code)) => {
> +                CommandError::abort_with_exit_code(message, exit_code)
> +            }

I believe this case is unnecessary since it is already handled in `impl From<HgError> for CommandError`

> error.rs:134
> +            }
> +            ConfigError::Other(_) => error.into(),
>          }

This change looks like a bug. Previously this line was calling into `HgError::into` which calls `impl From<HgError> for CommandError`, but now this it calls `ConfigError::into` such that `impl From<ConfigError> for CommandError` ends up recursively calling itself until the stack overflows.

The standard library defines this blanket `impl` to connect the `From` and `Into` traits:

  impl<T, U> Into<U> for T
  where
      U: From<T>,
  {
      fn into(self) -> U {
          U::from(self)
      }
  }

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10839/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D10839

To: pulkit, #hg-reviewers
Cc: SimonSapin, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210607/6697f8c3/attachment-0002.html>


More information about the Mercurial-patches mailing list