Display short types for unimplemented trait
This commit is contained in:
parent
ef324565d0
commit
c0ce0f3c3f
5 changed files with 47 additions and 2 deletions
|
@ -669,6 +669,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||
options.iter().filter_map(|(k, v)| v.clone().map(|v| (*k, v))).collect();
|
||||
|
||||
for command in self.subcommands.iter().chain(Some(self)).rev() {
|
||||
debug!(?command);
|
||||
if let Some(ref condition) = command.condition
|
||||
&& !attr::eval_condition(condition, &tcx.sess, Some(tcx.features()), &mut |cfg| {
|
||||
let value = cfg.value.map(|v| {
|
||||
|
@ -824,7 +825,11 @@ impl<'tcx> OnUnimplementedFormatString {
|
|||
.filter_map(|param| {
|
||||
let value = match param.kind {
|
||||
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
|
||||
trait_ref.args[param.index as usize].to_string()
|
||||
if let Some(ty) = trait_ref.args[param.index as usize].as_type() {
|
||||
tcx.short_ty_string(ty, &mut None)
|
||||
} else {
|
||||
trait_ref.args[param.index as usize].to_string()
|
||||
}
|
||||
}
|
||||
GenericParamDefKind::Lifetime => return None,
|
||||
};
|
||||
|
|
|
@ -3507,7 +3507,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
ObligationCauseCode::OpaqueReturnType(expr_info) => {
|
||||
if let Some((expr_ty, expr_span)) = expr_info {
|
||||
let expr_ty = with_forced_trimmed_paths!(self.ty_to_string(expr_ty));
|
||||
let expr_ty =
|
||||
with_forced_trimmed_paths!(self.tcx.short_ty_string(expr_ty, &mut None));
|
||||
err.span_label(
|
||||
expr_span,
|
||||
with_forced_trimmed_paths!(format!(
|
||||
|
|
|
@ -389,6 +389,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
kind: _,
|
||||
} = *obligation.cause.code()
|
||||
{
|
||||
debug!("ObligationCauseCode::CompareImplItemObligation");
|
||||
return self.report_extra_impl_obligation(
|
||||
span,
|
||||
impl_item_def_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue