Skip to content

Remove duplicate impl of string unescape from parse_format #137995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ops::Range;

use parse::Position::ArgumentNamed;
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
Expand Down Expand Up @@ -335,7 +337,7 @@ fn make_format_args(
return ExpandResult::Ready(Err(guar));
}

let to_span = |inner_span: parse::InnerSpan| {
let to_span = |inner_span: Range<usize>| {
is_source_literal.then(|| {
fmt_span.from_inner(InnerSpan { start: inner_span.start, end: inner_span.end })
})
Expand Down Expand Up @@ -407,7 +409,7 @@ fn make_format_args(
let mut placeholder_index = 0;

for piece in &pieces {
match *piece {
match piece.clone() {
parse::Piece::Lit(s) => {
unfinished_literal.push_str(s);
}
Expand All @@ -417,7 +419,8 @@ fn make_format_args(
unfinished_literal.clear();
}

let span = parser.arg_places.get(placeholder_index).and_then(|&s| to_span(s));
let span =
parser.arg_places.get(placeholder_index).and_then(|s| to_span(s.clone()));
placeholder_index += 1;

let position_span = to_span(position_span);
Expand Down Expand Up @@ -609,7 +612,7 @@ fn make_format_args(
fn invalid_placeholder_type_error(
ecx: &ExtCtxt<'_>,
ty: &str,
ty_span: Option<parse::InnerSpan>,
ty_span: Option<Range<usize>>,
fmt_span: Span,
) {
let sp = ty_span.map(|sp| fmt_span.from_inner(InnerSpan::new(sp.start, sp.end)));
Expand Down
Loading
Loading