mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +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");
|
bound_list.into_iter().map(|(_, path)| path).collect::<Vec<_>>().join("\n");
|
||||||
let actual_prefix = rcvr_ty.prefix_string(self.tcx);
|
let actual_prefix = rcvr_ty.prefix_string(self.tcx);
|
||||||
info!("unimplemented_traits.len() == {}", unimplemented_traits.len());
|
info!("unimplemented_traits.len() == {}", unimplemented_traits.len());
|
||||||
|
let mut long_ty_file = None;
|
||||||
let (primary_message, label) = if unimplemented_traits.len() == 1
|
let (primary_message, label) = if unimplemented_traits.len() == 1
|
||||||
&& unimplemented_traits_only
|
&& unimplemented_traits_only
|
||||||
{
|
{
|
||||||
@ -1066,8 +1067,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// Avoid crashing.
|
// Avoid crashing.
|
||||||
return (None, None);
|
return (None, None);
|
||||||
}
|
}
|
||||||
let OnUnimplementedNote { message, label, .. } =
|
let OnUnimplementedNote { message, label, .. } = self
|
||||||
self.err_ctxt().on_unimplemented_note(trait_ref, &obligation);
|
.err_ctxt()
|
||||||
|
.on_unimplemented_note(trait_ref, &obligation, &mut long_ty_file);
|
||||||
(message, label)
|
(message, label)
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -1081,6 +1083,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
)
|
)
|
||||||
});
|
});
|
||||||
err.primary_message(primary_message);
|
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 {
|
if let Some(label) = label {
|
||||||
custom_span_label = true;
|
custom_span_label = true;
|
||||||
err.span_label(span, label);
|
err.span_label(span, label);
|
||||||
|
@ -111,9 +111,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
|
long_ty_file: &mut Option<PathBuf>,
|
||||||
) -> OnUnimplementedNote {
|
) -> OnUnimplementedNote {
|
||||||
let mut long_ty_file = None;
|
|
||||||
|
|
||||||
let (def_id, args) = self
|
let (def_id, args) = self
|
||||||
.impl_similar_to(trait_ref, obligation)
|
.impl_similar_to(trait_ref, obligation)
|
||||||
.unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().args));
|
.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) {
|
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 {
|
} else {
|
||||||
OnUnimplementedNote::default()
|
OnUnimplementedNote::default()
|
||||||
}
|
}
|
||||||
|
@ -445,13 +445,16 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
file.display(),
|
file.display(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
let mut long_ty_file = None;
|
||||||
|
|
||||||
let OnUnimplementedNote {
|
let OnUnimplementedNote {
|
||||||
message,
|
message,
|
||||||
label,
|
label,
|
||||||
notes,
|
notes,
|
||||||
parent_label,
|
parent_label,
|
||||||
append_const_msg,
|
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 have_alt_message = message.is_some() || label.is_some();
|
||||||
let is_try_conversion = self.is_try_conversion(span, trait_ref.def_id());
|
let is_try_conversion = self.is_try_conversion(span, trait_ref.def_id());
|
||||||
let is_unsize =
|
let is_unsize =
|
||||||
@ -506,6 +509,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
|
|
||||||
let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg);
|
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;
|
let mut suggested = false;
|
||||||
if is_try_conversion {
|
if is_try_conversion {
|
||||||
suggested = self.try_conversion_context(&obligation, trait_ref.skip_binder(), &mut err);
|
suggested = self.try_conversion_context(&obligation, trait_ref.skip_binder(), &mut err);
|
||||||
@ -753,6 +763,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
return err.emit();
|
return err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ LL | | ))))))))))),
|
|||||||
LL | | )))))))))))
|
LL | | )))))))))))
|
||||||
| |_______________- return type was inferred to be `Option<Option<Option<...>>>` here
|
| |_______________- 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<...>>>`
|
= 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: 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'
|
= 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