Avoid ref when using format! in compiler
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
This commit is contained in:
parent
0cd01aac6a
commit
aef0e346de
23 changed files with 61 additions and 65 deletions
|
@ -505,7 +505,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||||
let nop_inst = fx.bcx.ins().nop();
|
let nop_inst = fx.bcx.ins().nop();
|
||||||
fx.add_comment(
|
fx.add_comment(
|
||||||
nop_inst,
|
nop_inst,
|
||||||
format!("virtual call; self arg pass mode: {:?}", &fn_abi.args[0]),
|
format!("virtual call; self arg pass mode: {:?}", fn_abi.args[0]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -759,7 +759,7 @@ fn link_natively(
|
||||||
sess.dcx().abort_if_errors();
|
sess.dcx().abort_if_errors();
|
||||||
|
|
||||||
// Invoke the system linker
|
// Invoke the system linker
|
||||||
info!("{:?}", &cmd);
|
info!("{cmd:?}");
|
||||||
let retry_on_segfault = env::var("RUSTC_RETRY_LINKER_ON_SEGFAULT").is_ok();
|
let retry_on_segfault = env::var("RUSTC_RETRY_LINKER_ON_SEGFAULT").is_ok();
|
||||||
let unknown_arg_regex =
|
let unknown_arg_regex =
|
||||||
Regex::new(r"(unknown|unrecognized) (command line )?(option|argument)").unwrap();
|
Regex::new(r"(unknown|unrecognized) (command line )?(option|argument)").unwrap();
|
||||||
|
@ -796,7 +796,7 @@ fn link_natively(
|
||||||
cmd.arg(arg);
|
cmd.arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!("{:?}", &cmd);
|
info!("{cmd:?}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ fn link_natively(
|
||||||
cmd.arg(arg);
|
cmd.arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!("{:?}", &cmd);
|
info!("{cmd:?}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,7 +878,7 @@ fn link_natively(
|
||||||
cmd.arg(arg);
|
cmd.arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!("{:?}", &cmd);
|
info!("{cmd:?}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,7 +996,7 @@ fn link_natively(
|
||||||
sess.dcx().emit_err(errors::UnableToExeLinker {
|
sess.dcx().emit_err(errors::UnableToExeLinker {
|
||||||
linker_path,
|
linker_path,
|
||||||
error: e,
|
error: e,
|
||||||
command_formatted: format!("{:?}", &cmd),
|
command_formatted: format!("{cmd:?}"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1567,7 +1567,7 @@ fn print_native_static_libs(
|
||||||
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
|
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
|
||||||
// Prefix for greppability
|
// Prefix for greppability
|
||||||
// Note: This must not be translated as tools are allowed to depend on this exact string.
|
// Note: This must not be translated as tools are allowed to depend on this exact string.
|
||||||
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
|
sess.dcx().note(format!("native-static-libs: {}", lib_args.join(" ")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
sym::link_section => {
|
sym::link_section => {
|
||||||
if let Some(val) = attr.value_str() {
|
if let Some(val) = attr.value_str() {
|
||||||
if val.as_str().bytes().any(|b| b == 0) {
|
if val.as_str().bytes().any(|b| b == 0) {
|
||||||
let msg = format!("illegal null byte in link_section value: `{}`", &val);
|
let msg = format!("illegal null byte in link_section value: `{val}`");
|
||||||
tcx.dcx().span_err(attr.span, msg);
|
tcx.dcx().span_err(attr.span, msg);
|
||||||
} else {
|
} else {
|
||||||
codegen_fn_attrs.link_section = Some(val);
|
codegen_fn_attrs.link_section = Some(val);
|
||||||
|
@ -726,7 +726,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
||||||
if *ordinal <= u16::MAX as u128 {
|
if *ordinal <= u16::MAX as u128 {
|
||||||
Some(ordinal.get() as u16)
|
Some(ordinal.get() as u16)
|
||||||
} else {
|
} else {
|
||||||
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
|
let msg = format!("ordinal value in `link_ordinal` is too large: `{ordinal}`");
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(attr.span, msg)
|
.struct_span_err(attr.span, msg)
|
||||||
.with_note("the value may not exceed `u16::MAX`")
|
.with_note("the value may not exceed `u16::MAX`")
|
||||||
|
|
|
@ -130,7 +130,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
||||||
|
|
||||||
let symbol_name = self.symbol_name(cx.tcx()).name;
|
let symbol_name = self.symbol_name(cx.tcx()).name;
|
||||||
|
|
||||||
debug!("symbol {}", &symbol_name);
|
debug!("symbol {symbol_name}");
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
MonoItem::Static(def_id) => {
|
MonoItem::Static(def_id) => {
|
||||||
|
|
|
@ -253,7 +253,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
|
||||||
|
|
||||||
for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
|
for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
|
||||||
let snake_name = Ident::new(
|
let snake_name = Ident::new(
|
||||||
&format!("{}{}", &crate_prefix, &attr_name.replace('-', "_")),
|
&format!("{crate_prefix}{}", attr_name.replace('-', "_")),
|
||||||
resource_str.span(),
|
resource_str.span(),
|
||||||
);
|
);
|
||||||
if !previous_attrs.insert(snake_name.clone()) {
|
if !previous_attrs.insert(snake_name.clone()) {
|
||||||
|
|
|
@ -651,7 +651,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
||||||
self.path_segment.hir_id,
|
self.path_segment.hir_id,
|
||||||
num_params_to_take,
|
num_params_to_take,
|
||||||
);
|
);
|
||||||
debug!("suggested_args: {:?}", &suggested_args);
|
debug!("suggested_args: {suggested_args:?}");
|
||||||
|
|
||||||
match self.angle_brackets {
|
match self.angle_brackets {
|
||||||
AngleBrackets::Missing => {
|
AngleBrackets::Missing => {
|
||||||
|
|
|
@ -249,7 +249,7 @@ fn check_explicit_predicates<'tcx>(
|
||||||
let explicit_predicates = explicit_map.explicit_predicates_of(tcx, def_id);
|
let explicit_predicates = explicit_map.explicit_predicates_of(tcx, def_id);
|
||||||
|
|
||||||
for (outlives_predicate, &span) in explicit_predicates.as_ref().skip_binder() {
|
for (outlives_predicate, &span) in explicit_predicates.as_ref().skip_binder() {
|
||||||
debug!("outlives_predicate = {:?}", &outlives_predicate);
|
debug!("outlives_predicate = {outlives_predicate:?}");
|
||||||
|
|
||||||
// Careful: If we are inferring the effects of a `dyn Trait<..>`
|
// Careful: If we are inferring the effects of a `dyn Trait<..>`
|
||||||
// type, then when we look up the predicates for `Trait`,
|
// type, then when we look up the predicates for `Trait`,
|
||||||
|
@ -289,12 +289,12 @@ fn check_explicit_predicates<'tcx>(
|
||||||
&& let GenericArgKind::Type(ty) = outlives_predicate.0.unpack()
|
&& let GenericArgKind::Type(ty) = outlives_predicate.0.unpack()
|
||||||
&& ty.walk().any(|arg| arg == self_ty.into())
|
&& ty.walk().any(|arg| arg == self_ty.into())
|
||||||
{
|
{
|
||||||
debug!("skipping self ty = {:?}", &ty);
|
debug!("skipping self ty = {ty:?}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let predicate = explicit_predicates.rebind(*outlives_predicate).instantiate(tcx, args);
|
let predicate = explicit_predicates.rebind(*outlives_predicate).instantiate(tcx, args);
|
||||||
debug!("predicate = {:?}", &predicate);
|
debug!("predicate = {predicate:?}");
|
||||||
insert_outlives_predicate(tcx, predicate.0, predicate.1, span, required_predicates);
|
insert_outlives_predicate(tcx, predicate.0, predicate.1, span, required_predicates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1265,9 +1265,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
match parent_pred {
|
match parent_pred {
|
||||||
None => format!("`{}`", &p),
|
None => format!("`{p}`"),
|
||||||
Some(parent_pred) => match format_pred(*parent_pred) {
|
Some(parent_pred) => match format_pred(*parent_pred) {
|
||||||
None => format!("`{}`", &p),
|
None => format!("`{p}`"),
|
||||||
Some((parent_p, _)) => {
|
Some((parent_p, _)) => {
|
||||||
if !suggested
|
if !suggested
|
||||||
&& !suggested_bounds.contains(pred)
|
&& !suggested_bounds.contains(pred)
|
||||||
|
|
|
@ -112,7 +112,7 @@ pub fn report_unstable(
|
||||||
) {
|
) {
|
||||||
let msg = match reason {
|
let msg = match reason {
|
||||||
Some(r) => format!("use of unstable library feature '{feature}': {r}"),
|
Some(r) => format!("use of unstable library feature '{feature}': {r}"),
|
||||||
None => format!("use of unstable library feature '{}'", &feature),
|
None => format!("use of unstable library feature '{feature}'"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if is_soft {
|
if is_soft {
|
||||||
|
|
|
@ -2627,7 +2627,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
self.prepare_region_info(value);
|
self.prepare_region_info(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("self.used_region_names: {:?}", &self.used_region_names);
|
debug!("self.used_region_names: {:?}", self.used_region_names);
|
||||||
|
|
||||||
let mut empty = true;
|
let mut empty = true;
|
||||||
let mut start_or_continue = |cx: &mut Self, start: &str, cont: &str| {
|
let mut start_or_continue = |cx: &mut Self, start: &str, cont: &str| {
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub fn find_self_call<'tcx>(
|
||||||
local: Local,
|
local: Local,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
) -> Option<(DefId, GenericArgsRef<'tcx>)> {
|
) -> Option<(DefId, GenericArgsRef<'tcx>)> {
|
||||||
debug!("find_self_call(local={:?}): terminator={:?}", local, &body[block].terminator);
|
debug!("find_self_call(local={:?}): terminator={:?}", local, body[block].terminator);
|
||||||
if let Some(Terminator { kind: TerminatorKind::Call { func, args, .. }, .. }) =
|
if let Some(Terminator { kind: TerminatorKind::Call { func, args, .. }, .. }) =
|
||||||
&body[block].terminator
|
&body[block].terminator
|
||||||
{
|
{
|
||||||
|
|
|
@ -688,7 +688,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, '_, 'tcx> {
|
||||||
let init_loc_map = &move_data.init_loc_map;
|
let init_loc_map = &move_data.init_loc_map;
|
||||||
let rev_lookup = &move_data.rev_lookup;
|
let rev_lookup = &move_data.rev_lookup;
|
||||||
|
|
||||||
debug!("initializes move_indexes {:?}", &init_loc_map[location]);
|
debug!("initializes move_indexes {:?}", init_loc_map[location]);
|
||||||
trans.gen_all(init_loc_map[location].iter().copied());
|
trans.gen_all(init_loc_map[location].iter().copied());
|
||||||
|
|
||||||
if let mir::StatementKind::StorageDead(local) = stmt.kind {
|
if let mir::StatementKind::StorageDead(local) = stmt.kind {
|
||||||
|
|
|
@ -102,7 +102,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
| StatementKind::Nop => (),
|
| StatementKind::Nop => (),
|
||||||
|
|
||||||
StatementKind::FakeRead(_) | StatementKind::AscribeUserType(_, _) => {
|
StatementKind::FakeRead(_) | StatementKind::AscribeUserType(_, _) => {
|
||||||
bug!("{:?} not found in this MIR phase!", &statement.kind)
|
bug!("{:?} not found in this MIR phase!", statement.kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,11 +106,11 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
|
||||||
let parent = BasicBlock::from_usize(i);
|
let parent = BasicBlock::from_usize(i);
|
||||||
let Some(opt_data) = evaluate_candidate(tcx, body, parent) else { continue };
|
let Some(opt_data) = evaluate_candidate(tcx, body, parent) else { continue };
|
||||||
|
|
||||||
if !tcx.consider_optimizing(|| format!("EarlyOtherwiseBranch {:?}", &opt_data)) {
|
if !tcx.consider_optimizing(|| format!("EarlyOtherwiseBranch {opt_data:?}")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!("SUCCESS: found optimization possibility to apply: {:?}", &opt_data);
|
trace!("SUCCESS: found optimization possibility to apply: {opt_data:?}");
|
||||||
|
|
||||||
should_cleanup = true;
|
should_cleanup = true;
|
||||||
|
|
||||||
|
|
|
@ -904,7 +904,7 @@ impl<Cx: PatCx> Constructor<Cx> {
|
||||||
// be careful to detect strings here. However a string literal pattern will never
|
// be careful to detect strings here. However a string literal pattern will never
|
||||||
// be reported as a non-exhaustiveness witness, so we can ignore this issue.
|
// be reported as a non-exhaustiveness witness, so we can ignore this issue.
|
||||||
Ref => {
|
Ref => {
|
||||||
write!(f, "&{:?}", &fields.next().unwrap())?;
|
write!(f, "&{:?}", fields.next().unwrap())?;
|
||||||
}
|
}
|
||||||
Slice(slice) => {
|
Slice(slice) => {
|
||||||
write!(f, "[")?;
|
write!(f, "[")?;
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
BuiltinLintDiag::AmbiguousGlobImports { diag },
|
BuiltinLintDiag::AmbiguousGlobImports { diag },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let mut err = struct_span_code_err!(self.dcx(), diag.span, E0659, "{}", &diag.msg);
|
let mut err = struct_span_code_err!(self.dcx(), diag.span, E0659, "{}", diag.msg);
|
||||||
report_ambiguity_error(&mut err, diag);
|
report_ambiguity_error(&mut err, diag);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
@ -798,7 +798,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
ResolutionError::FailedToResolve { segment, label, suggestion, module } => {
|
ResolutionError::FailedToResolve { segment, label, suggestion, module } => {
|
||||||
let mut err =
|
let mut err =
|
||||||
struct_span_code_err!(self.dcx(), span, E0433, "failed to resolve: {}", &label);
|
struct_span_code_err!(self.dcx(), span, E0433, "failed to resolve: {label}");
|
||||||
err.span_label(span, label);
|
err.span_label(span, label);
|
||||||
|
|
||||||
if let Some((suggestions, msg, applicability)) = suggestion {
|
if let Some((suggestions, msg, applicability)) = suggestion {
|
||||||
|
@ -2893,7 +2893,7 @@ fn show_candidates(
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
candidate.0 =
|
candidate.0 =
|
||||||
format!("{add_use}{}{append}{trailing}{additional_newline}", &candidate.0);
|
format!("{add_use}{}{append}{trailing}{additional_newline}", candidate.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
match mode {
|
match mode {
|
||||||
|
|
|
@ -694,7 +694,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),);
|
let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),);
|
||||||
|
|
||||||
let mut diag = struct_span_code_err!(self.dcx(), span, E0432, "{}", &msg);
|
let mut diag = struct_span_code_err!(self.dcx(), span, E0432, "{msg}");
|
||||||
|
|
||||||
if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.iter().last() {
|
if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.iter().last() {
|
||||||
diag.note(note.clone());
|
diag.note(note.clone());
|
||||||
|
|
|
@ -339,7 +339,7 @@ pub fn strip_generics_from_path(path_str: &str) -> Result<Box<str>, MalformedGen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("path_str: {:?}\nstripped segments: {:?}", path_str, &stripped_segments);
|
debug!("path_str: {path_str:?}\nstripped segments: {stripped_segments:?}");
|
||||||
|
|
||||||
let stripped_path = stripped_segments.join("::");
|
let stripped_path = stripped_segments.join("::");
|
||||||
|
|
||||||
|
|
|
@ -238,12 +238,12 @@ fn encode_predicate<'tcx>(
|
||||||
match predicate.as_ref().skip_binder() {
|
match predicate.as_ref().skip_binder() {
|
||||||
ty::ExistentialPredicate::Trait(trait_ref) => {
|
ty::ExistentialPredicate::Trait(trait_ref) => {
|
||||||
let name = encode_ty_name(tcx, trait_ref.def_id);
|
let name = encode_ty_name(tcx, trait_ref.def_id);
|
||||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
let _ = write!(s, "u{}{}", name.len(), name);
|
||||||
s.push_str(&encode_args(tcx, trait_ref.args, trait_ref.def_id, true, dict, options));
|
s.push_str(&encode_args(tcx, trait_ref.args, trait_ref.def_id, true, dict, options));
|
||||||
}
|
}
|
||||||
ty::ExistentialPredicate::Projection(projection) => {
|
ty::ExistentialPredicate::Projection(projection) => {
|
||||||
let name = encode_ty_name(tcx, projection.def_id);
|
let name = encode_ty_name(tcx, projection.def_id);
|
||||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
let _ = write!(s, "u{}{}", name.len(), name);
|
||||||
s.push_str(&encode_args(tcx, projection.args, projection.def_id, true, dict, options));
|
s.push_str(&encode_args(tcx, projection.args, projection.def_id, true, dict, options));
|
||||||
match projection.term.unpack() {
|
match projection.term.unpack() {
|
||||||
TermKind::Ty(ty) => s.push_str(&encode_ty(tcx, ty, dict, options)),
|
TermKind::Ty(ty) => s.push_str(&encode_ty(tcx, ty, dict, options)),
|
||||||
|
@ -258,7 +258,7 @@ fn encode_predicate<'tcx>(
|
||||||
}
|
}
|
||||||
ty::ExistentialPredicate::AutoTrait(def_id) => {
|
ty::ExistentialPredicate::AutoTrait(def_id) => {
|
||||||
let name = encode_ty_name(tcx, *def_id);
|
let name = encode_ty_name(tcx, *def_id);
|
||||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
let _ = write!(s, "u{}{}", name.len(), name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
compress(dict, DictKey::Predicate(*predicate.as_ref().skip_binder()), &mut s);
|
compress(dict, DictKey::Predicate(*predicate.as_ref().skip_binder()), &mut s);
|
||||||
|
@ -416,7 +416,7 @@ pub fn encode_ty<'tcx>(
|
||||||
// A<array-length><element-type>
|
// A<array-length><element-type>
|
||||||
let len = len.eval_target_usize(tcx, ty::ParamEnv::reveal_all());
|
let len = len.eval_target_usize(tcx, ty::ParamEnv::reveal_all());
|
||||||
let mut s = String::from("A");
|
let mut s = String::from("A");
|
||||||
let _ = write!(s, "{}", &len);
|
let _ = write!(s, "{len}");
|
||||||
s.push_str(&encode_ty(tcx, *ty0, dict, options));
|
s.push_str(&encode_ty(tcx, *ty0, dict, options));
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
typeid.push_str(&s);
|
typeid.push_str(&s);
|
||||||
|
@ -492,13 +492,13 @@ pub fn encode_ty<'tcx>(
|
||||||
// calling convention (or extern types [i.e., ty::Foreign]) as <length><name>, where
|
// calling convention (or extern types [i.e., ty::Foreign]) as <length><name>, where
|
||||||
// <name> is <unscoped-name>.
|
// <name> is <unscoped-name>.
|
||||||
let name = tcx.item_name(def_id).to_string();
|
let name = tcx.item_name(def_id).to_string();
|
||||||
let _ = write!(s, "{}{}", name.len(), &name);
|
let _ = write!(s, "{}{}", name.len(), name);
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
} else {
|
} else {
|
||||||
// u<length><name>[I<element-type1..element-typeN>E], where <element-type> is
|
// u<length><name>[I<element-type1..element-typeN>E], where <element-type> is
|
||||||
// <subst>, as vendor extended type.
|
// <subst>, as vendor extended type.
|
||||||
let name = encode_ty_name(tcx, def_id);
|
let name = encode_ty_name(tcx, def_id);
|
||||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
let _ = write!(s, "u{}{}", name.len(), name);
|
||||||
s.push_str(&encode_args(tcx, args, def_id, false, dict, options));
|
s.push_str(&encode_args(tcx, args, def_id, false, dict, options));
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ pub fn encode_ty<'tcx>(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let name = tcx.item_name(*def_id).to_string();
|
let name = tcx.item_name(*def_id).to_string();
|
||||||
let _ = write!(s, "{}{}", name.len(), &name);
|
let _ = write!(s, "{}{}", name.len(), name);
|
||||||
}
|
}
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
typeid.push_str(&s);
|
typeid.push_str(&s);
|
||||||
|
@ -542,7 +542,7 @@ pub fn encode_ty<'tcx>(
|
||||||
// as vendor extended type.
|
// as vendor extended type.
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
let name = encode_ty_name(tcx, *def_id);
|
let name = encode_ty_name(tcx, *def_id);
|
||||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
let _ = write!(s, "u{}{}", name.len(), name);
|
||||||
s.push_str(&encode_args(tcx, args, *def_id, false, dict, options));
|
s.push_str(&encode_args(tcx, args, *def_id, false, dict, options));
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
typeid.push_str(&s);
|
typeid.push_str(&s);
|
||||||
|
@ -553,7 +553,7 @@ pub fn encode_ty<'tcx>(
|
||||||
// as vendor extended type.
|
// as vendor extended type.
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
let name = encode_ty_name(tcx, *def_id);
|
let name = encode_ty_name(tcx, *def_id);
|
||||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
let _ = write!(s, "u{}{}", name.len(), name);
|
||||||
let parent_args = tcx.mk_args(args.as_coroutine_closure().parent_args());
|
let parent_args = tcx.mk_args(args.as_coroutine_closure().parent_args());
|
||||||
s.push_str(&encode_args(tcx, parent_args, *def_id, false, dict, options));
|
s.push_str(&encode_args(tcx, parent_args, *def_id, false, dict, options));
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
|
@ -565,7 +565,7 @@ pub fn encode_ty<'tcx>(
|
||||||
// as vendor extended type.
|
// as vendor extended type.
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
let name = encode_ty_name(tcx, *def_id);
|
let name = encode_ty_name(tcx, *def_id);
|
||||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
let _ = write!(s, "u{}{}", name.len(), name);
|
||||||
// Encode parent args only
|
// Encode parent args only
|
||||||
s.push_str(&encode_args(
|
s.push_str(&encode_args(
|
||||||
tcx,
|
tcx,
|
||||||
|
@ -588,7 +588,7 @@ pub fn encode_ty<'tcx>(
|
||||||
s.push('E');
|
s.push('E');
|
||||||
compress(dict, DictKey::Ty(Ty::new_imm_ref(tcx, *region, *ty0), TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(Ty::new_imm_ref(tcx, *region, *ty0), TyQ::None), &mut s);
|
||||||
if ty.is_mutable_ptr() {
|
if ty.is_mutable_ptr() {
|
||||||
s = format!("{}{}", "U3mut", &s);
|
s = format!("{}{}", "U3mut", s);
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::Mut), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::Mut), &mut s);
|
||||||
}
|
}
|
||||||
typeid.push_str(&s);
|
typeid.push_str(&s);
|
||||||
|
@ -600,10 +600,10 @@ pub fn encode_ty<'tcx>(
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
s.push_str(&encode_ty(tcx, *ptr_ty, dict, options));
|
s.push_str(&encode_ty(tcx, *ptr_ty, dict, options));
|
||||||
if !ty.is_mutable_ptr() {
|
if !ty.is_mutable_ptr() {
|
||||||
s = format!("{}{}", "K", &s);
|
s = format!("{}{}", "K", s);
|
||||||
compress(dict, DictKey::Ty(*ptr_ty, TyQ::Const), &mut s);
|
compress(dict, DictKey::Ty(*ptr_ty, TyQ::Const), &mut s);
|
||||||
};
|
};
|
||||||
s = format!("{}{}", "P", &s);
|
s = format!("{}{}", "P", s);
|
||||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
typeid.push_str(&s);
|
typeid.push_str(&s);
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
|
||||||
s.push('C');
|
s.push('C');
|
||||||
s.push_str(&to_disambiguator(tcx.stable_crate_id(def_path.krate).as_u64()));
|
s.push_str(&to_disambiguator(tcx.stable_crate_id(def_path.krate).as_u64()));
|
||||||
let crate_name = tcx.crate_name(def_path.krate).to_string();
|
let crate_name = tcx.crate_name(def_path.krate).to_string();
|
||||||
let _ = write!(s, "{}{}", crate_name.len(), &crate_name);
|
let _ = write!(s, "{}{}", crate_name.len(), crate_name);
|
||||||
|
|
||||||
// Disambiguators and names
|
// Disambiguators and names
|
||||||
def_path.data.reverse();
|
def_path.data.reverse();
|
||||||
|
|
|
@ -65,15 +65,13 @@ impl<I: Interner> fmt::Debug for ConstKind<I> {
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Param(param) => write!(f, "{param:?}"),
|
Param(param) => write!(f, "{param:?}"),
|
||||||
Infer(var) => write!(f, "{:?}", &var),
|
Infer(var) => write!(f, "{var:?}"),
|
||||||
Bound(debruijn, var) => crate::debug_bound_var(f, *debruijn, var),
|
Bound(debruijn, var) => crate::debug_bound_var(f, *debruijn, var),
|
||||||
Placeholder(placeholder) => write!(f, "{placeholder:?}"),
|
Placeholder(placeholder) => write!(f, "{placeholder:?}"),
|
||||||
Unevaluated(uv) => {
|
Unevaluated(uv) => write!(f, "{uv:?}"),
|
||||||
write!(f, "{:?}", &uv)
|
Value(ty, valtree) => write!(f, "({valtree:?}: {ty:?})"),
|
||||||
}
|
|
||||||
Value(ty, valtree) => write!(f, "({valtree:?}: {:?})", &ty),
|
|
||||||
Error(_) => write!(f, "{{const error}}"),
|
Error(_) => write!(f, "{{const error}}"),
|
||||||
Expr(expr) => write!(f, "{:?}", &expr),
|
Expr(expr) => write!(f, "{expr:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ impl<I: Interner> fmt::Debug for RegionKind<I> {
|
||||||
|
|
||||||
ReStatic => f.write_str("'static"),
|
ReStatic => f.write_str("'static"),
|
||||||
|
|
||||||
ReVar(vid) => write!(f, "{:?}", &vid),
|
ReVar(vid) => write!(f, "{vid:?}"),
|
||||||
|
|
||||||
RePlaceholder(placeholder) => write!(f, "{placeholder:?}"),
|
RePlaceholder(placeholder) => write!(f, "{placeholder:?}"),
|
||||||
|
|
||||||
|
|
|
@ -367,18 +367,16 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
|
||||||
}
|
}
|
||||||
Foreign(d) => f.debug_tuple("Foreign").field(d).finish(),
|
Foreign(d) => f.debug_tuple("Foreign").field(d).finish(),
|
||||||
Str => write!(f, "str"),
|
Str => write!(f, "str"),
|
||||||
Array(t, c) => write!(f, "[{:?}; {:?}]", &t, &c),
|
Array(t, c) => write!(f, "[{t:?}; {c:?}]"),
|
||||||
Pat(t, p) => write!(f, "pattern_type!({:?} is {:?})", &t, &p),
|
Pat(t, p) => write!(f, "pattern_type!({t:?} is {p:?})"),
|
||||||
Slice(t) => write!(f, "[{:?}]", &t),
|
Slice(t) => write!(f, "[{:?}]", &t),
|
||||||
RawPtr(ty, mutbl) => write!(f, "*{} {:?}", mutbl.ptr_str(), ty),
|
RawPtr(ty, mutbl) => write!(f, "*{} {:?}", mutbl.ptr_str(), ty),
|
||||||
Ref(r, t, m) => write!(f, "&{:?} {}{:?}", r, m.prefix_str(), t),
|
Ref(r, t, m) => write!(f, "&{:?} {}{:?}", r, m.prefix_str(), t),
|
||||||
FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&s).finish(),
|
FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&s).finish(),
|
||||||
FnPtr(s) => write!(f, "{:?}", &s),
|
FnPtr(s) => write!(f, "{s:?}"),
|
||||||
Dynamic(p, r, repr) => match repr {
|
Dynamic(p, r, repr) => match repr {
|
||||||
DynKind::Dyn => write!(f, "dyn {:?} + {:?}", &p, &r),
|
DynKind::Dyn => write!(f, "dyn {p:?} + {r:?}"),
|
||||||
DynKind::DynStar => {
|
DynKind::DynStar => write!(f, "dyn* {p:?} + {r:?}"),
|
||||||
write!(f, "dyn* {:?} + {:?}", &p, &r)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Closure(d, s) => f.debug_tuple("Closure").field(d).field(&s).finish(),
|
Closure(d, s) => f.debug_tuple("Closure").field(d).field(&s).finish(),
|
||||||
CoroutineClosure(d, s) => f.debug_tuple("CoroutineClosure").field(d).field(&s).finish(),
|
CoroutineClosure(d, s) => f.debug_tuple("CoroutineClosure").field(d).field(&s).finish(),
|
||||||
|
@ -392,7 +390,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
write!(f, ", ")?;
|
write!(f, ", ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{:?}", &ty)?;
|
write!(f, "{ty:?}")?;
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
// unary tuples need a trailing comma
|
// unary tuples need a trailing comma
|
||||||
|
@ -1050,7 +1048,7 @@ impl<I: Interner> fmt::Debug for FnSig<I> {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
write!(f, ", ")?;
|
write!(f, ", ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{:?}", &ty)?;
|
write!(f, "{ty:?}")?;
|
||||||
}
|
}
|
||||||
if *c_variadic {
|
if *c_variadic {
|
||||||
if inputs.is_empty() {
|
if inputs.is_empty() {
|
||||||
|
|
|
@ -179,7 +179,7 @@ fn pretty_terminator_head<W: Write>(writer: &mut W, terminator: &TerminatorKind)
|
||||||
if !expected {
|
if !expected {
|
||||||
write!(writer, "!")?;
|
write!(writer, "!")?;
|
||||||
}
|
}
|
||||||
write!(writer, "{}, ", &pretty_operand(cond))?;
|
write!(writer, "{}, ", pretty_operand(cond))?;
|
||||||
pretty_assert_message(writer, msg)?;
|
pretty_assert_message(writer, msg)?;
|
||||||
write!(writer, ")")
|
write!(writer, ")")
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ fn pretty_ty_const(ct: &TyConst) -> String {
|
||||||
fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
|
fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
|
||||||
match rval {
|
match rval {
|
||||||
Rvalue::AddressOf(mutability, place) => {
|
Rvalue::AddressOf(mutability, place) => {
|
||||||
write!(writer, "&raw {}(*{:?})", &pretty_mut(*mutability), place)
|
write!(writer, "&raw {}(*{:?})", pretty_mut(*mutability), place)
|
||||||
}
|
}
|
||||||
Rvalue::Aggregate(aggregate_kind, operands) => {
|
Rvalue::Aggregate(aggregate_kind, operands) => {
|
||||||
// FIXME: Add pretty_aggregate function that returns a pretty string
|
// FIXME: Add pretty_aggregate function that returns a pretty string
|
||||||
|
@ -336,13 +336,13 @@ fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
|
||||||
write!(writer, ")")
|
write!(writer, ")")
|
||||||
}
|
}
|
||||||
Rvalue::BinaryOp(bin, op1, op2) => {
|
Rvalue::BinaryOp(bin, op1, op2) => {
|
||||||
write!(writer, "{:?}({}, {})", bin, &pretty_operand(op1), pretty_operand(op2))
|
write!(writer, "{:?}({}, {})", bin, pretty_operand(op1), pretty_operand(op2))
|
||||||
}
|
}
|
||||||
Rvalue::Cast(_, op, ty) => {
|
Rvalue::Cast(_, op, ty) => {
|
||||||
write!(writer, "{} as {}", pretty_operand(op), ty)
|
write!(writer, "{} as {}", pretty_operand(op), ty)
|
||||||
}
|
}
|
||||||
Rvalue::CheckedBinaryOp(bin, op1, op2) => {
|
Rvalue::CheckedBinaryOp(bin, op1, op2) => {
|
||||||
write!(writer, "Checked{:?}({}, {})", bin, &pretty_operand(op1), pretty_operand(op2))
|
write!(writer, "Checked{:?}({}, {})", bin, pretty_operand(op1), pretty_operand(op2))
|
||||||
}
|
}
|
||||||
Rvalue::CopyForDeref(deref) => {
|
Rvalue::CopyForDeref(deref) => {
|
||||||
write!(writer, "CopyForDeref({:?})", deref)
|
write!(writer, "CopyForDeref({:?})", deref)
|
||||||
|
@ -363,7 +363,7 @@ fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
|
||||||
write!(writer, "{kind}{:?}", place)
|
write!(writer, "{kind}{:?}", place)
|
||||||
}
|
}
|
||||||
Rvalue::Repeat(op, cnst) => {
|
Rvalue::Repeat(op, cnst) => {
|
||||||
write!(writer, "{} \" \" {}", &pretty_operand(op), &pretty_ty_const(cnst))
|
write!(writer, "{} \" \" {}", pretty_operand(op), pretty_ty_const(cnst))
|
||||||
}
|
}
|
||||||
Rvalue::ShallowInitBox(_, _) => Ok(()),
|
Rvalue::ShallowInitBox(_, _) => Ok(()),
|
||||||
Rvalue::ThreadLocalRef(item) => {
|
Rvalue::ThreadLocalRef(item) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue