We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8b1782 commit ed9d6c5Copy full SHA for ed9d6c5
clippy_utils/src/source.rs
@@ -513,8 +513,13 @@ fn snippet_with_applicability_sess<'a>(
513
}
514
515
/// Converts a span to a code snippet. Returns `None` if not available.
516
+#[allow(clippy::unnecessary_wraps)]
517
pub fn snippet_opt(sess: &impl HasSession, span: Span) -> Option<String> {
- sess.sess().source_map().span_to_snippet(span).ok()
518
+ // Experiment: fail loudly if the snippet cannot be obtained
519
+ match sess.sess().source_map().span_to_snippet(span) {
520
+ Ok(v) => Some(v),
521
+ Err(e) => panic!("Error when getting snippet for {span:?}: {e:?}"),
522
+ }
523
524
525
/// Converts a span (from a block) to a code snippet if available, otherwise use default.
0 commit comments