Avoid silently writing to a file when the involved ty is long
This commit is contained in:
parent
a1dbb61c09
commit
62baa670e3
4 changed files with 30 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue