Skip to content

Commit 88c3a20

Browse files
committed
Fixing span by extending it to the first character
1 parent 4042468 commit 88c3a20

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_expand/src/base.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_span::edition::Edition;
2222
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId};
2323
use rustc_span::source_map::SourceMap;
2424
use rustc_span::symbol::{kw, sym, Ident, Symbol};
25-
use rustc_span::{FileName, Span, DUMMY_SP};
25+
use rustc_span::{BytePos, FileName, Span, DUMMY_SP};
2626
use smallvec::{smallvec, SmallVec};
2727

2828
use std::default::Default;
@@ -1228,8 +1228,9 @@ pub fn expr_to_spanned_string<'a>(
12281228
ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)),
12291229
ast::LitKind::ByteStr(_) => {
12301230
let mut err = cx.struct_span_err(l.span, err_msg);
1231+
let span = expr.span.shrink_to_lo();
12311232
err.span_suggestion(
1232-
expr.span,
1233+
span.with_hi(span.lo() + BytePos(1)),
12331234
"consider removing the leading `b`",
12341235
"",
12351236
Applicability::MaybeIncorrect,

0 commit comments

Comments
 (0)