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 5b23bd4 commit f758a6bCopy full SHA for f758a6b
clippy_utils/src/source.rs
@@ -573,8 +573,13 @@ fn snippet_with_applicability_sess<'a>(
573
}
574
575
/// Converts a span to a code snippet. Returns `None` if not available.
576
+#[allow(clippy::unnecessary_wraps)]
577
pub fn snippet_opt(sess: &impl HasSession, span: Span) -> Option<String> {
- sess.sess().source_map().span_to_snippet(span).ok()
578
+ // Experiment: fail loudly if the snippet cannot be obtained
579
+ match sess.sess().source_map().span_to_snippet(span) {
580
+ Ok(v) => Some(v),
581
+ Err(e) => panic!("Error when getting snippet for {span:?}: {e:?}"),
582
+ }
583
584
585
/// Converts a span (from a block) to a code snippet if available, otherwise use default.
0 commit comments