review comments and rebase
This commit is contained in:
parent
1db02b8a43
commit
f479e262d6
3 changed files with 10 additions and 12 deletions
|
@ -334,7 +334,7 @@ pub fn same_type_modulo_infer<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
|
||||||
| (&ty::Infer(ty::InferTy::TyVar(_)), _)
|
| (&ty::Infer(ty::InferTy::TyVar(_)), _)
|
||||||
| (_, &ty::Infer(ty::InferTy::TyVar(_))) => true,
|
| (_, &ty::Infer(ty::InferTy::TyVar(_))) => true,
|
||||||
(&ty::Ref(reg_a, ty_a, mut_a), &ty::Ref(reg_b, ty_b, mut_b)) => {
|
(&ty::Ref(reg_a, ty_a, mut_a), &ty::Ref(reg_b, ty_b, mut_b)) => {
|
||||||
reg_a == reg_b && mut_a == mut_b && same_type_modulo_infer(ty_a, ty_b)
|
reg_a == reg_b && mut_a == mut_b && same_type_modulo_infer(*ty_a, *ty_b)
|
||||||
}
|
}
|
||||||
_ => a == b,
|
_ => a == b,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1441,7 +1441,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
if !value.needs_infer() {
|
if !value.needs_infer() {
|
||||||
return value; // Avoid duplicated subst-folding.
|
return value; // Avoid duplicated subst-folding.
|
||||||
}
|
}
|
||||||
let mut r = InferenceLiteralEraser { infcx: self };
|
let mut r = InferenceLiteralEraser { tcx: self.tcx };
|
||||||
value.fold_with(&mut r)
|
value.fold_with(&mut r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1798,19 +1798,19 @@ impl<'tcx> TyOrConstInferVar<'tcx> {
|
||||||
|
|
||||||
/// Replace `{integer}` with `i32` and `{float}` with `f64`.
|
/// Replace `{integer}` with `i32` and `{float}` with `f64`.
|
||||||
/// Used only for diagnostics.
|
/// Used only for diagnostics.
|
||||||
struct InferenceLiteralEraser<'a, 'tcx> {
|
struct InferenceLiteralEraser<'tcx> {
|
||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'a, 'tcx> {
|
impl<'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'tcx> {
|
||||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||||
self.infcx.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Infer(ty::IntVar(_) | ty::FreshIntTy(_)) => self.tcx().types.i32,
|
ty::Infer(ty::IntVar(_) | ty::FreshIntTy(_)) => self.tcx.types.i32,
|
||||||
ty::Infer(ty::FloatVar(_) | ty::FreshFloatTy(_)) => self.tcx().types.f64,
|
ty::Infer(ty::FloatVar(_) | ty::FreshFloatTy(_)) => self.tcx.types.f64,
|
||||||
_ => ty.super_fold_with(self),
|
_ => ty.super_fold_with(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let param_hir_id = tcx.hir().local_def_id_to_hir_id(param_local_id);
|
let param_hir_id = tcx.hir().local_def_id_to_hir_id(param_local_id);
|
||||||
let param_name = tcx.hir().ty_param_name(param_hir_id);
|
let param_name = tcx.hir().ty_param_name(param_hir_id);
|
||||||
let param_type = tcx.infer_ctxt().enter(|infcx| {
|
let param_type = tcx.infer_ctxt().enter(|infcx| {
|
||||||
infcx.resolve_numeric_literals_with_default(
|
infcx.resolve_numeric_literals_with_default(tcx.type_of(param.def_id))
|
||||||
infcx.resolve_vars_if_possible(tcx.type_of(param.def_id)),
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
if param_type.is_suggestable() {
|
if param_type.is_suggestable() {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue