1
Fork 0

Rollup merge of #114075 - matthiaskrgr:fmt_args_rustc_3, r=wesleywiser

inline format!() args from rustc_codegen_llvm to the end (4)

r? `@WaffleLapkin`
This commit is contained in:
Matthias Krüger 2023-07-27 06:04:13 +02:00 committed by GitHub
commit fa21a8c6f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
94 changed files with 385 additions and 498 deletions

View file

@ -74,7 +74,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
kind @ StmtKind::Let { pattern, .. } => {
return Err(ParseError {
span: pattern.span,
item_description: format!("{:?}", kind),
item_description: format!("{kind:?}"),
expected: "expression".to_string(),
});
}

View file

@ -774,8 +774,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Not in a closure
debug_assert!(
local == ty::CAPTURE_STRUCT_LOCAL,
"Expected local to be Local(1), found {:?}",
local
"Expected local to be Local(1), found {local:?}"
);
// Not in a closure
debug_assert!(

View file

@ -1627,9 +1627,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// at least the first candidate ought to be tested
assert!(
total_candidate_count > candidates.len(),
"{}, {:#?}",
total_candidate_count,
candidates
"{total_candidate_count}, {candidates:#?}"
);
debug!("tested_candidates: {}", total_candidate_count - candidates.len());
debug!("untested_candidates: {}", candidates.len());

View file

@ -175,16 +175,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
debug_assert_ne!(
target_blocks[idx.index()],
otherwise_block,
"no candidates for tested discriminant: {:?}",
discr,
"no candidates for tested discriminant: {discr:?}",
);
Some((discr.val, target_blocks[idx.index()]))
} else {
debug_assert_eq!(
target_blocks[idx.index()],
otherwise_block,
"found candidates for untested discriminant: {:?}",
discr,
"found candidates for untested discriminant: {discr:?}",
);
None
}

View file

@ -94,8 +94,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
|| body.basic_blocks.has_free_regions()
|| body.var_debug_info.has_free_regions()
|| body.yield_ty().has_free_regions()),
"Unexpected free regions in MIR: {:?}",
body,
"Unexpected free regions in MIR: {body:?}",
);
body
@ -977,9 +976,9 @@ pub(crate) fn parse_float_into_scalar(
match float_ty {
ty::FloatTy::F32 => {
let Ok(rust_f) = num.parse::<f32>() else { return None };
let mut f = num.parse::<Single>().unwrap_or_else(|e| {
panic!("apfloat::ieee::Single failed to parse `{}`: {:?}", num, e)
});
let mut f = num
.parse::<Single>()
.unwrap_or_else(|e| panic!("apfloat::ieee::Single failed to parse `{num}`: {e:?}"));
assert!(
u128::from(rust_f.to_bits()) == f.to_bits(),
@ -1000,9 +999,9 @@ pub(crate) fn parse_float_into_scalar(
}
ty::FloatTy::F64 => {
let Ok(rust_f) = num.parse::<f64>() else { return None };
let mut f = num.parse::<Double>().unwrap_or_else(|e| {
panic!("apfloat::ieee::Double failed to parse `{}`: {:?}", num, e)
});
let mut f = num
.parse::<Double>()
.unwrap_or_else(|e| panic!("apfloat::ieee::Double failed to parse `{num}`: {e:?}"));
assert!(
u128::from(rust_f.to_bits()) == f.to_bits(),

View file

@ -454,17 +454,13 @@ impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
if self.span.eq_ctxt(self.expr_span) {
// Get the span for the empty match body `{}`.
let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.span) {
(format!("\n{}", snippet), " ")
(format!("\n{snippet}"), " ")
} else {
(" ".to_string(), "")
};
suggestion = Some((
self.span.shrink_to_hi().with_hi(self.expr_span.hi()),
format!(
" {{{indentation}{more}_ => todo!(),{indentation}}}",
indentation = indentation,
more = more,
),
format!(" {{{indentation}{more}_ => todo!(),{indentation}}}",),
));
}

View file

@ -229,9 +229,7 @@ impl<'tcx> Cx<'tcx> {
let param_env_ty = self.param_env.and(discr_ty);
let size = tcx
.layout_of(param_env_ty)
.unwrap_or_else(|e| {
panic!("could not compute layout for {:?}: {:?}", param_env_ty, e)
})
.unwrap_or_else(|e| panic!("could not compute layout for {param_env_ty:?}: {e:?}"))
.size;
let lit = ScalarInt::try_from_uint(discr_offset as u128, size).unwrap();

View file

@ -691,7 +691,7 @@ fn non_exhaustive_match<'p, 'tcx>(
err = create_e0004(
cx.tcx.sess,
sp,
format!("non-exhaustive patterns: {} not covered", joined_patterns),
format!("non-exhaustive patterns: {joined_patterns} not covered"),
);
err.span_label(sp, pattern_not_covered_label(&witnesses, &joined_patterns));
patterns_len = witnesses.len();
@ -721,15 +721,13 @@ fn non_exhaustive_match<'p, 'tcx>(
&& matches!(witnesses[0].ctor(), Constructor::NonExhaustive)
{
err.note(format!(
"`{}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \
"`{scrut_ty}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \
exhaustively",
scrut_ty,
));
if cx.tcx.sess.is_nightly_build() {
err.help(format!(
"add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \
enable precise `{}` matching",
scrut_ty,
enable precise `{scrut_ty}` matching",
));
}
}
@ -745,18 +743,13 @@ fn non_exhaustive_match<'p, 'tcx>(
[] if sp.eq_ctxt(expr_span) => {
// Get the span for the empty match body `{}`.
let (indentation, more) = if let Some(snippet) = sm.indentation_before(sp) {
(format!("\n{}", snippet), " ")
(format!("\n{snippet}"), " ")
} else {
(" ".to_string(), "")
};
suggestion = Some((
sp.shrink_to_hi().with_hi(expr_span.hi()),
format!(
" {{{indentation}{more}{pattern} => todo!(),{indentation}}}",
indentation = indentation,
more = more,
pattern = pattern,
),
format!(" {{{indentation}{more}{pattern} => todo!(),{indentation}}}",),
));
}
[only] => {
@ -765,7 +758,7 @@ fn non_exhaustive_match<'p, 'tcx>(
&& let Ok(with_trailing) = sm.span_extend_while(only.span, |c| c.is_whitespace() || c == ',')
&& sm.is_multiline(with_trailing)
{
(format!("\n{}", snippet), true)
(format!("\n{snippet}"), true)
} else {
(" ".to_string(), false)
};
@ -780,7 +773,7 @@ fn non_exhaustive_match<'p, 'tcx>(
};
suggestion = Some((
only.span.shrink_to_hi(),
format!("{}{}{} => todo!()", comma, pre_indentation, pattern),
format!("{comma}{pre_indentation}{pattern} => todo!()"),
));
}
[.., prev, last] => {
@ -803,7 +796,7 @@ fn non_exhaustive_match<'p, 'tcx>(
if let Some(spacing) = spacing {
suggestion = Some((
last.span.shrink_to_hi(),
format!("{}{}{} => todo!()", comma, spacing, pattern),
format!("{comma}{spacing}{pattern} => todo!()"),
));
}
}
@ -900,7 +893,7 @@ fn adt_defined_here<'p, 'tcx>(
for pat in spans {
span.push_span_label(pat, "not covered");
}
err.span_note(span, format!("`{}` defined here", ty));
err.span_note(span, format!("`{ty}` defined here"));
}
}

View file

@ -306,9 +306,9 @@ impl fmt::Debug for IntRange {
let (lo, hi) = self.boundaries();
let bias = self.bias;
let (lo, hi) = (lo ^ bias, hi ^ bias);
write!(f, "{}", lo)?;
write!(f, "{lo}")?;
write!(f, "{}", RangeEnd::Included)?;
write!(f, "{}", hi)
write!(f, "{hi}")
}
}
@ -1619,7 +1619,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
// of `std`). So this branch is only reachable when the feature is enabled and
// the pattern is a box pattern.
let subpattern = self.iter_fields().next().unwrap();
write!(f, "box {:?}", subpattern)
write!(f, "box {subpattern:?}")
}
ty::Adt(..) | ty::Tuple(..) => {
let variant = match self.ty.kind() {
@ -1638,7 +1638,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
write!(f, "(")?;
for p in self.iter_fields() {
write!(f, "{}", start_or_comma())?;
write!(f, "{:?}", p)?;
write!(f, "{p:?}")?;
}
write!(f, ")")
}
@ -1674,11 +1674,11 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
write!(f, "]")
}
&FloatRange(lo, hi, end) => {
write!(f, "{}", lo)?;
write!(f, "{}", end)?;
write!(f, "{}", hi)
write!(f, "{lo}")?;
write!(f, "{end}")?;
write!(f, "{hi}")
}
IntRange(range) => write!(f, "{:?}", range), // Best-effort, will render e.g. `false` as `0..=0`
IntRange(range) => write!(f, "{range:?}"), // Best-effort, will render e.g. `false` as `0..=0`
Wildcard | Missing { .. } | NonExhaustive => write!(f, "_ : {:?}", self.ty),
Or => {
for pat in self.iter_fields() {
@ -1686,7 +1686,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
}
Ok(())
}
Str(value) => write!(f, "{}", value),
Str(value) => write!(f, "{value}"),
Opaque => write!(f, "<constant pattern>"),
}
}

View file

@ -459,7 +459,7 @@ impl<'p, 'tcx> fmt::Debug for PatStack<'p, 'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "+")?;
for pat in self.iter() {
write!(f, " {:?} +", pat)?;
write!(f, " {pat:?} +")?;
}
Ok(())
}
@ -530,7 +530,7 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
let Matrix { patterns: m, .. } = self;
let pretty_printed_matrix: Vec<Vec<String>> =
m.iter().map(|row| row.iter().map(|pat| format!("{:?}", pat)).collect()).collect();
m.iter().map(|row| row.iter().map(|pat| format!("{pat:?}")).collect()).collect();
let column_count = m.iter().map(|row| row.len()).next().unwrap_or(0);
assert!(m.iter().all(|row| row.len() == column_count));