merge need_type_info_err(_const)
This commit is contained in:
parent
e0bc267512
commit
45d92b43e3
13 changed files with 148 additions and 131 deletions
|
@ -20,7 +20,6 @@ use rustc_hir::Node;
|
|||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::ty::error::ExpectedFound;
|
||||
use rustc_middle::ty::fold::TypeFolder;
|
||||
use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_middle::ty::{
|
||||
self, fast_reject, AdtKind, SubtypePredicate, ToPolyTraitRef, ToPredicate, Ty, TyCtxt,
|
||||
TypeFoldable, WithConstness,
|
||||
|
@ -1513,10 +1512,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// check upstream for type errors and don't add the obligations to
|
||||
// begin with in those cases.
|
||||
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
|
||||
self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0282).emit();
|
||||
self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0282).emit();
|
||||
return;
|
||||
}
|
||||
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0283);
|
||||
let mut err =
|
||||
self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0283);
|
||||
err.note(&format!("cannot satisfy `{}`", predicate));
|
||||
if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code {
|
||||
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
|
||||
|
@ -1580,17 +1580,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
match arg.unpack() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
span_bug!(span, "unexpected well formed predicate: {:?}", lt)
|
||||
}
|
||||
GenericArgKind::Type(ty) => {
|
||||
self.need_type_info_err(body_id, span, ty, ErrorCode::E0282)
|
||||
}
|
||||
GenericArgKind::Const(ct) => {
|
||||
self.need_type_info_err_const(body_id, span, ct, ErrorCode::E0282)
|
||||
}
|
||||
}
|
||||
self.need_type_info_err(body_id, span, arg, ErrorCode::E0282)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Subtype(data) => {
|
||||
|
@ -1601,7 +1591,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let SubtypePredicate { a_is_expected: _, a, b } = data;
|
||||
// both must be type variables, or the other would've been instantiated
|
||||
assert!(a.is_ty_var() && b.is_ty_var());
|
||||
self.need_type_info_err(body_id, span, a, ErrorCode::E0282)
|
||||
self.need_type_info_err(body_id, span, a.into(), ErrorCode::E0282)
|
||||
}
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
let trait_ref = ty::Binder::bind(data).to_poly_trait_ref(self.tcx);
|
||||
|
@ -1612,7 +1602,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
if self_ty.needs_infer() && ty.needs_infer() {
|
||||
// We do this for the `foo.collect()?` case to produce a suggestion.
|
||||
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
|
||||
let mut err =
|
||||
self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0284);
|
||||
err.note(&format!("cannot satisfy `{}`", predicate));
|
||||
err
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue