]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #21980 - pnkfelix:more-robust-span-to-snippet, r=huonw
authorManish Goregaokar <manishsmail@gmail.com>
Fri, 6 Feb 2015 00:06:15 +0000 (05:36 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Fri, 6 Feb 2015 10:51:03 +0000 (16:21 +0530)
commitce3a4afd73415c8e89f4d445a546013c461c061f
treef347ec15b44fad9c2bb5ad89dd8963fbff68f505
parent60c9f560708fe5d5774abad53895eb52e6fd7276
parentfa9d2230a65689289f64c897ad30c83251762320
Rollup merge of #21980 - pnkfelix:more-robust-span-to-snippet, r=huonw

 This can be considered partial work on #8256.

The main observable change: macro expansion sometimes results in spans where `lo > hi`; so for now, when we have such a span, do not attempt to return a snippet result.

(Longer term, we might think about whether we could still present a snippet for the cases where this arises, e.g. perhaps by showing the whole macro as the snippet, assuming that is the sole cause of such spans; or by somehow looking up the closest AST node that holds both `lo` and `hi`, and showing that.)

As a drive-by, revised the API to return a `Result` rather than an `Option`, with better information-packed error value that should help us (and maybe also our users) identify the causes of such problems in the future.  Ideally the call-sites that really want an actual snippet would be updated to catch the newly added `Err` case and print something meaningful about it, but that is not part of this PR.