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 d8301d7 commit ce1f1b1Copy full SHA for ce1f1b1
clippy_utils/src/source.rs
@@ -514,8 +514,13 @@ fn snippet_with_applicability_sess<'a>(
514
}
515
516
/// Converts a span to a code snippet. Returns `None` if not available.
517
+#[allow(clippy::unnecessary_wraps)]
518
pub fn snippet_opt(sess: &impl HasSession, span: Span) -> Option<String> {
- sess.sess().source_map().span_to_snippet(span).ok()
519
+ // Experiment: fail loudly if the snippet cannot be obtained
520
+ match sess.sess().source_map().span_to_snippet(span) {
521
+ Ok(v) => Some(v),
522
+ Err(e) => panic!("Error when getting snippet for {span:?}: {e:?}"),
523
+ }
524
525
526
/// Converts a span (from a block) to a code snippet if available, otherwise use default.
0 commit comments