mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Avoid silently writing to a file when the involved ty is long
This commit is contained in:
parent
a1dbb61c09
commit
62baa670e3
@ -1054,6 +1054,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
bound_list.into_iter().map(|(_, path)| path).collect::<Vec<_>>().join("\n");
|
||||
let actual_prefix = rcvr_ty.prefix_string(self.tcx);
|
||||
info!("unimplemented_traits.len() == {}", unimplemented_traits.len());
|
||||
let mut long_ty_file = None;
|
||||
let (primary_message, label) = if unimplemented_traits.len() == 1
|
||||
&& unimplemented_traits_only
|
||||
{
|
||||
@ -1066,8 +1067,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Avoid crashing.
|
||||
return (None, None);
|
||||
}
|
||||
let OnUnimplementedNote { message, label, .. } =
|
||||
self.err_ctxt().on_unimplemented_note(trait_ref, &obligation);
|
||||
let OnUnimplementedNote { message, label, .. } = self
|
||||
.err_ctxt()
|
||||
.on_unimplemented_note(trait_ref, &obligation, &mut long_ty_file);
|
||||
(message, label)
|
||||
})
|
||||
.unwrap()
|
||||
@ -1081,6 +1083,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
)
|
||||
});
|
||||
err.primary_message(primary_message);
|
||||
if let Some(file) = long_ty_file {
|
||||
err.note(format!(
|
||||
"the full name for the type has been written to '{}'",
|
||||
file.display(),
|
||||
));
|
||||
err.note(
|
||||
"consider using `--verbose` to print the full type name to the console",
|
||||
);
|
||||
}
|
||||
if let Some(label) = label {
|
||||
custom_span_label = true;
|
||||
err.span_label(span, label);
|
||||
|
@ -111,9 +111,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
&self,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
long_ty_file: &mut Option<PathBuf>,
|
||||
) -> OnUnimplementedNote {
|
||||
let mut long_ty_file = None;
|
||||
|
||||
let (def_id, args) = self
|
||||
.impl_similar_to(trait_ref, obligation)
|
||||
.unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().args));
|
||||
@ -268,7 +267,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
}));
|
||||
|
||||
if let Ok(Some(command)) = OnUnimplementedDirective::of_item(self.tcx, def_id) {
|
||||
command.evaluate(self.tcx, trait_ref, &flags, &mut long_ty_file)
|
||||
command.evaluate(self.tcx, trait_ref, &flags, long_ty_file)
|
||||
} else {
|
||||
OnUnimplementedNote::default()
|
||||
}
|
||||
|
@ -445,13 +445,16 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
file.display(),
|
||||
));
|
||||
|
||||
let mut long_ty_file = None;
|
||||
|
||||
let OnUnimplementedNote {
|
||||
message,
|
||||
label,
|
||||
notes,
|
||||
parent_label,
|
||||
append_const_msg,
|
||||
} = self.on_unimplemented_note(trait_ref, &obligation);
|
||||
} = self.on_unimplemented_note(trait_ref, &obligation, &mut long_ty_file);
|
||||
|
||||
let have_alt_message = message.is_some() || label.is_some();
|
||||
let is_try_conversion = self.is_try_conversion(span, trait_ref.def_id());
|
||||
let is_unsize =
|
||||
@ -506,6 +509,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
|
||||
let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg);
|
||||
|
||||
if let Some(long_ty_file) = long_ty_file {
|
||||
err.note(format!(
|
||||
"the full name for the type has been written to '{}'",
|
||||
long_ty_file.display(),
|
||||
));
|
||||
err.note("consider using `--verbose` to print the full type name to the console");
|
||||
}
|
||||
let mut suggested = false;
|
||||
if is_try_conversion {
|
||||
suggested = self.try_conversion_context(&obligation, trait_ref.skip_binder(), &mut err);
|
||||
@ -753,6 +763,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
return err.emit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
err
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ LL | | ))))))))))),
|
||||
LL | | )))))))))))
|
||||
| |_______________- return type was inferred to be `Option<Option<Option<...>>>` here
|
||||
|
|
||||
= note: the full name for the type has been written to '$TEST_BUILD_DIR/traits/on_unimplemented_long_types/on_unimplemented_long_types.long-type-hash.txt'
|
||||
= note: consider using `--verbose` to print the full type name to the console
|
||||
= help: the trait `std::fmt::Display` is not implemented for `Option<Option<Option<...>>>`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
= note: the full name for the type has been written to '$TEST_BUILD_DIR/traits/on_unimplemented_long_types/on_unimplemented_long_types.long-type-hash.txt'
|
||||
|
Loading…
Reference in New Issue
Block a user