Uplift TypeError
This commit is contained in:
parent
c74efbca71
commit
82ef3ad980
16 changed files with 217 additions and 194 deletions
|
@ -71,6 +71,7 @@ use rustc_hir::lang_items::LangItem;
|
|||
use rustc_macros::extension;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::dep_graph::DepContext;
|
||||
use rustc_middle::ty::error::TypeErrorToStringExt;
|
||||
use rustc_middle::ty::print::{with_forced_trimmed_paths, PrintError, PrintTraitRefExt as _};
|
||||
use rustc_middle::ty::relate::{self, RelateResult, TypeRelation};
|
||||
use rustc_middle::ty::Upcast;
|
||||
|
|
|
@ -21,13 +21,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
sp: Span,
|
||||
body_owner_def_id: DefId,
|
||||
) {
|
||||
use ty::error::TypeError::*;
|
||||
debug!("note_and_explain_type_err err={:?} cause={:?}", err, cause);
|
||||
|
||||
let tcx = self.tcx;
|
||||
|
||||
match err {
|
||||
ArgumentSorts(values, _) | Sorts(values) => {
|
||||
TypeError::ArgumentSorts(values, _) | TypeError::Sorts(values) => {
|
||||
match (*values.expected.kind(), *values.found.kind()) {
|
||||
(ty::Closure(..), ty::Closure(..)) => {
|
||||
diag.note("no two closures, even if identical, have the same type");
|
||||
|
@ -483,7 +482,7 @@ impl<T> Trait<T> for X {
|
|||
values.found.kind(),
|
||||
);
|
||||
}
|
||||
CyclicTy(ty) => {
|
||||
TypeError::CyclicTy(ty) => {
|
||||
// Watch out for various cases of cyclic types and try to explain.
|
||||
if ty.is_closure() || ty.is_coroutine() || ty.is_coroutine_closure() {
|
||||
diag.note(
|
||||
|
@ -494,7 +493,7 @@ impl<T> Trait<T> for X {
|
|||
);
|
||||
}
|
||||
}
|
||||
TargetFeatureCast(def_id) => {
|
||||
TypeError::TargetFeatureCast(def_id) => {
|
||||
let target_spans = tcx.get_attrs(def_id, sym::target_feature).map(|attr| attr.span);
|
||||
diag.note(
|
||||
"functions with `#[target_feature]` can only be coerced to `unsafe` function pointers"
|
||||
|
|
|
@ -276,7 +276,7 @@ impl<'a, 'b, 'tcx> LeakCheck<'a, 'b, 'tcx> {
|
|||
other_region: ty::Region<'tcx>,
|
||||
) -> TypeError<'tcx> {
|
||||
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
|
||||
TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound.kind, other_region)
|
||||
TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound, other_region)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue