Skip to content

Commit 14ef432

Browse files
zackmdavismark-i-m
authored andcommitted
span_to_snippet return value is a Result, not an Option
1 parent 95bdeac commit 14ef432

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/diag.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let mut err = sess.struct_span_err(sp, "oh no! this is an error!");
5656
// In some cases, you might need to check if `sp` is generated by a macro to
5757
// avoid printing weird errors about macro-generated code.
5858
59-
if let Some(snippet) = sess.codemap().span_to_snippet(sp) {
59+
if let Ok(snippet) = sess.codemap().span_to_snippet(sp) {
6060
// Use the snippet to generate a suggested fix
6161
err.span_suggestion(suggestion_sp, "try using a qux here", format!("qux {}", snip));
6262
} else {
@@ -90,7 +90,7 @@ For example, to make our `qux` suggestion machine-applicable, we would do:
9090
```rust,ignore
9191
let mut err = sess.struct_span_err(sp, "oh no! this is an error!");
9292
93-
if let Some(snippet) = sess.codemap().span_to_snippet(sp) {
93+
if let Ok(snippet) = sess.codemap().span_to_snippet(sp) {
9494
// Add applicability info!
9595
err.span_suggestion_with_applicability(
9696
suggestion_sp,

0 commit comments

Comments
 (0)