Don't print host effect param in pretty path_generic_args
This commit is contained in:
parent
08587a56f1
commit
f1bf874fb1
11 changed files with 46 additions and 42 deletions
|
@ -641,6 +641,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
&mut self,
|
||||
print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>,
|
||||
_args: &[GenericArg<'tcx>],
|
||||
_params: &[ty::GenericParamDef],
|
||||
) -> Result<(), PrintError> {
|
||||
print_prefix(self)
|
||||
}
|
||||
|
@ -1236,9 +1237,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
(&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => {
|
||||
let did1 = def1.did();
|
||||
let did2 = def2.did();
|
||||
let sub_no_defaults_1 =
|
||||
let (sub_no_defaults_1, _) =
|
||||
self.tcx.generics_of(did1).own_args_no_defaults(self.tcx, sub1);
|
||||
let sub_no_defaults_2 =
|
||||
let (sub_no_defaults_2, _) =
|
||||
self.tcx.generics_of(did2).own_args_no_defaults(self.tcx, sub2);
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
let path1 = self.tcx.def_path_str(did1);
|
||||
|
|
|
@ -757,6 +757,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||
.tcx
|
||||
.generics_of(def.did())
|
||||
.own_args_no_defaults(self.tcx, args)
|
||||
.0
|
||||
.iter()
|
||||
.map(|&arg| self.arg_cost(arg))
|
||||
.sum::<usize>()
|
||||
|
@ -1185,7 +1186,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
|
|||
}
|
||||
let args = self.infcx.resolve_vars_if_possible(args);
|
||||
let generic_args =
|
||||
&generics.own_args_no_defaults(tcx, args)[generics.own_counts().lifetimes..];
|
||||
&generics.own_args_no_defaults(tcx, args).0[generics.own_counts().lifetimes..];
|
||||
let span = match expr.kind {
|
||||
ExprKind::MethodCall(path, ..) => path.ident.span,
|
||||
_ => expr.span,
|
||||
|
|
|
@ -116,7 +116,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
// FIXME: extract this logic for use in other diagnostics.
|
||||
let (trait_ref, assoc_args) = proj.trait_ref_and_own_args(tcx);
|
||||
let item_name = tcx.item_name(proj.def_id);
|
||||
let item_args = self.format_generic_args(assoc_args);
|
||||
let item_args = self.format_generic_args(proj.def_id, assoc_args);
|
||||
|
||||
// Here, we try to see if there's an existing
|
||||
// trait implementation that matches the one that
|
||||
|
@ -775,7 +775,7 @@ fn foo(&self) -> Self::T { String::new() }
|
|||
let span = Span::new(pos, pos, span.ctxt(), span.parent());
|
||||
(span, format!(", {} = {}", assoc.ident(tcx), ty))
|
||||
} else {
|
||||
let item_args = self.format_generic_args(assoc_args);
|
||||
let item_args = self.format_generic_args(assoc.def_id, assoc_args);
|
||||
(span.shrink_to_hi(), format!("<{}{} = {}>", assoc.ident(tcx), item_args, ty))
|
||||
};
|
||||
diag.span_suggestion_verbose(span, msg(), sugg, MaybeIncorrect);
|
||||
|
@ -784,9 +784,13 @@ fn foo(&self) -> Self::T { String::new() }
|
|||
false
|
||||
}
|
||||
|
||||
pub fn format_generic_args(&self, args: &[ty::GenericArg<'tcx>]) -> String {
|
||||
pub fn format_generic_args(
|
||||
&self,
|
||||
assoc_def_id: DefId,
|
||||
args: &[ty::GenericArg<'tcx>],
|
||||
) -> String {
|
||||
FmtPrinter::print_string(self.tcx, hir::def::Namespace::TypeNS, |cx| {
|
||||
cx.path_generic_args(|_| Ok(()), args)
|
||||
cx.path_generic_args(|_| Ok(()), args, &self.infcx.tcx.generics_of(assoc_def_id).params)
|
||||
})
|
||||
.expect("could not write to `String`.")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue