Auto merge of #91769 - estebank:type-trait-bound-span-2, r=oli-obk
Tweak assoc type obligation spans * Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors r? `@oli-obk` This is a(n uncontroversial) subset of #85799.
This commit is contained in:
commit
229d0a9412
92 changed files with 503 additions and 257 deletions
|
@ -638,7 +638,11 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
self.expr_ty = fcx.structurally_resolved_type(self.expr.span, self.expr_ty);
|
||||
self.cast_ty = fcx.structurally_resolved_type(self.cast_span, self.cast_ty);
|
||||
|
||||
if !fcx.type_is_known_to_be_sized_modulo_regions(self.cast_ty, self.span) {
|
||||
debug!("check_cast({}, {:?} as {:?})", self.expr.hir_id, self.expr_ty, self.cast_ty);
|
||||
|
||||
if !fcx.type_is_known_to_be_sized_modulo_regions(self.cast_ty, self.span)
|
||||
&& !self.cast_ty.has_infer_types()
|
||||
{
|
||||
self.report_cast_to_unsized_type(fcx);
|
||||
} else if self.expr_ty.references_error() || self.cast_ty.references_error() {
|
||||
// No sense in giving duplicate error messages
|
||||
|
|
|
@ -730,7 +730,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
|
|||
let abi = sig.header.abi;
|
||||
fn_maybe_err(tcx, item.ident.span, abi);
|
||||
}
|
||||
hir::TraitItemKind::Type(.., Some(_default)) => {
|
||||
hir::TraitItemKind::Type(.., Some(default)) => {
|
||||
let assoc_item = tcx.associated_item(item.def_id);
|
||||
let trait_substs =
|
||||
InternalSubsts::identity_for_item(tcx, it.def_id.to_def_id());
|
||||
|
@ -738,7 +738,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
|
|||
tcx,
|
||||
assoc_item,
|
||||
assoc_item,
|
||||
item.span,
|
||||
default.span,
|
||||
ty::TraitRef { def_id: it.def_id.to_def_id(), substs: trait_substs },
|
||||
);
|
||||
}
|
||||
|
@ -987,12 +987,12 @@ pub(super) fn check_impl_items_against_trait<'tcx>(
|
|||
opt_trait_span,
|
||||
);
|
||||
}
|
||||
hir::ImplItemKind::TyAlias(_) => {
|
||||
hir::ImplItemKind::TyAlias(impl_ty) => {
|
||||
let opt_trait_span = tcx.hir().span_if_local(ty_trait_item.def_id);
|
||||
compare_ty_impl(
|
||||
tcx,
|
||||
&ty_impl_item,
|
||||
impl_item.span,
|
||||
impl_ty.span,
|
||||
&ty_trait_item,
|
||||
impl_trait_ref,
|
||||
opt_trait_span,
|
||||
|
|
|
@ -379,6 +379,7 @@ fn compare_predicate_entailment<'tcx>(
|
|||
found: impl_fty,
|
||||
})),
|
||||
&terr,
|
||||
false,
|
||||
);
|
||||
diag.emit();
|
||||
return Err(ErrorReported);
|
||||
|
@ -734,8 +735,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
|||
tcx.sess,
|
||||
impl_span,
|
||||
E0050,
|
||||
"method `{}` has {} but the declaration in \
|
||||
trait `{}` has {}",
|
||||
"method `{}` has {} but the declaration in trait `{}` has {}",
|
||||
trait_m.ident,
|
||||
potentially_plural_count(impl_number_args, "parameter"),
|
||||
tcx.def_path_str(trait_m.def_id),
|
||||
|
@ -1069,6 +1069,7 @@ crate fn compare_const_impl<'tcx>(
|
|||
found: impl_ty,
|
||||
})),
|
||||
&terr,
|
||||
false,
|
||||
);
|
||||
diag.emit();
|
||||
}
|
||||
|
@ -1099,7 +1100,8 @@ crate fn compare_ty_impl<'tcx>(
|
|||
let _: Result<(), ErrorReported> = (|| {
|
||||
compare_number_of_generics(tcx, impl_ty, impl_ty_span, trait_ty, trait_item_span)?;
|
||||
|
||||
compare_type_predicate_entailment(tcx, impl_ty, impl_ty_span, trait_ty, impl_trait_ref)?;
|
||||
let sp = tcx.def_span(impl_ty.def_id);
|
||||
compare_type_predicate_entailment(tcx, impl_ty, sp, trait_ty, impl_trait_ref)?;
|
||||
|
||||
check_type_bounds(tcx, trait_ty, impl_ty, impl_ty_span, impl_trait_ref)
|
||||
})();
|
||||
|
|
|
@ -683,7 +683,8 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
|
||||
let (method_sig, span) = match impl_item.kind {
|
||||
hir::ImplItemKind::Fn(ref sig, _) => (Some(sig), impl_item.span),
|
||||
hir::ImplItemKind::TyAlias(ty) => (None, ty.span),
|
||||
// Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.
|
||||
hir::ImplItemKind::TyAlias(ty) if ty.span != DUMMY_SP => (None, ty.span),
|
||||
_ => (None, impl_item.span),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue