1
Fork 0

Remove some explicit self.infcx for fcx, which derefs into infcx

This commit is contained in:
Michael Goulet 2022-07-22 18:49:35 +00:00
parent 6dbae3ad19
commit aaa9989c2f
14 changed files with 68 additions and 77 deletions

View file

@ -488,7 +488,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate { ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate {
trait_ref: ty::TraitRef { trait_ref: ty::TraitRef {
def_id: t.def_id(), def_id: t.def_id(),
substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]), substs: self.tcx.mk_substs_trait(outer_ty, &[]),
}, },
constness: t.constness, constness: t.constness,
polarity: t.polarity, polarity: t.polarity,
@ -496,9 +496,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let obl = Obligation::new( let obl = Obligation::new(
o.cause.clone(), o.cause.clone(),
self.param_env, self.param_env,
pred.to_predicate(self.infcx.tcx), pred.to_predicate(self.tcx),
); );
suggest_box &= self.infcx.predicate_must_hold_modulo_regions(&obl); suggest_box &= self.predicate_must_hold_modulo_regions(&obl);
if !suggest_box { if !suggest_box {
// We've encountered some obligation that didn't hold, so the // We've encountered some obligation that didn't hold, so the
// return expression can't just be boxed. We don't need to // return expression can't just be boxed. We don't need to

View file

@ -376,7 +376,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.param_env, self.param_env,
*predicate, *predicate,
); );
let result = self.infcx.evaluate_obligation(&obligation); let result = self.evaluate_obligation(&obligation);
self.tcx self.tcx
.sess .sess
.struct_span_err( .struct_span_err(

View file

@ -96,7 +96,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx.typeck_root_def_id(expr_def_id.to_def_id()), self.tcx.typeck_root_def_id(expr_def_id.to_def_id()),
); );
let tupled_upvars_ty = self.infcx.next_ty_var(TypeVariableOrigin { let tupled_upvars_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic, kind: TypeVariableOriginKind::ClosureSynthetic,
span: self.tcx.hir().span(expr.hir_id), span: self.tcx.hir().span(expr.hir_id),
}); });
@ -141,7 +141,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Create a type variable (for now) to represent the closure kind. // Create a type variable (for now) to represent the closure kind.
// It will be unified during the upvar inference phase (`upvar.rs`) // It will be unified during the upvar inference phase (`upvar.rs`)
None => self.infcx.next_ty_var(TypeVariableOrigin { None => self.next_ty_var(TypeVariableOrigin {
// FIXME(eddyb) distinguish closure kind inference variables from the rest. // FIXME(eddyb) distinguish closure kind inference variables from the rest.
kind: TypeVariableOriginKind::ClosureSynthetic, kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr.span, span: expr.span,
@ -531,7 +531,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// //
// [c1]: https://github.com/rust-lang/rust/pull/45072#issuecomment-341089706 // [c1]: https://github.com/rust-lang/rust/pull/45072#issuecomment-341089706
// [c2]: https://github.com/rust-lang/rust/pull/45072#issuecomment-341096796 // [c2]: https://github.com/rust-lang/rust/pull/45072#issuecomment-341096796
self.infcx.commit_if_ok(|_| { self.commit_if_ok(|_| {
let mut all_obligations = vec![]; let mut all_obligations = vec![];
// The liberated version of this signature should be a subtype // The liberated version of this signature should be a subtype
@ -544,7 +544,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected_sigs.liberated_sig.inputs(), // `liberated_sig` is E'. expected_sigs.liberated_sig.inputs(), // `liberated_sig` is E'.
) { ) {
// Instantiate (this part of..) S to S', i.e., with fresh variables. // Instantiate (this part of..) S to S', i.e., with fresh variables.
let supplied_ty = self.infcx.replace_bound_vars_with_fresh_vars( let supplied_ty = self.replace_bound_vars_with_fresh_vars(
hir_ty.span, hir_ty.span,
LateBoundRegionConversionTime::FnCall, LateBoundRegionConversionTime::FnCall,
supplied_sig.inputs().rebind(supplied_ty), supplied_sig.inputs().rebind(supplied_ty),
@ -557,7 +557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
all_obligations.extend(obligations); all_obligations.extend(obligations);
} }
let supplied_output_ty = self.infcx.replace_bound_vars_with_fresh_vars( let supplied_output_ty = self.replace_bound_vars_with_fresh_vars(
decl.output.span(), decl.output.span(),
LateBoundRegionConversionTime::FnCall, LateBoundRegionConversionTime::FnCall,
supplied_sig.output(), supplied_sig.output(),

View file

@ -241,13 +241,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
make_adjustments: impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>, make_adjustments: impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>,
) -> CoerceResult<'tcx> { ) -> CoerceResult<'tcx> {
debug!("coerce_from_inference_variable(a={:?}, b={:?})", a, b); debug!("coerce_from_inference_variable(a={:?}, b={:?})", a, b);
assert!(a.is_ty_var() && self.infcx.shallow_resolve(a) == a); assert!(a.is_ty_var() && self.shallow_resolve(a) == a);
assert!(self.infcx.shallow_resolve(b) == b); assert!(self.shallow_resolve(b) == b);
if b.is_ty_var() { if b.is_ty_var() {
// Two unresolved type variables: create a `Coerce` predicate. // Two unresolved type variables: create a `Coerce` predicate.
let target_ty = if self.use_lub { let target_ty = if self.use_lub {
self.infcx.next_ty_var(TypeVariableOrigin { self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::LatticeVariable, kind: TypeVariableOriginKind::LatticeVariable,
span: self.cause.span, span: self.cause.span,
}) })
@ -991,7 +991,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.autoderef(rustc_span::DUMMY_SP, expr_ty).nth(1).and_then(|(deref_ty, _)| { self.autoderef(rustc_span::DUMMY_SP, expr_ty).nth(1).and_then(|(deref_ty, _)| {
self.infcx self.infcx
.type_implements_trait( .type_implements_trait(
self.infcx.tcx.lang_items().deref_mut_trait()?, self.tcx.lang_items().deref_mut_trait()?,
expr_ty, expr_ty,
ty::List::empty(), ty::List::empty(),
self.param_env, self.param_env,

View file

@ -815,7 +815,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, ref expr), hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, ref expr),
_, _,
&ty::Ref(_, checked, _), &ty::Ref(_, checked, _),
) if self.infcx.can_sub(self.param_env, checked, expected).is_ok() => { ) if self.can_sub(self.param_env, checked, expected).is_ok() => {
// We have `&T`, check if what was expected was `T`. If so, // We have `&T`, check if what was expected was `T`. If so,
// we may want to suggest removing a `&`. // we may want to suggest removing a `&`.
if sm.is_imported(expr.span) { if sm.is_imported(expr.span) {
@ -959,7 +959,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// For this suggestion to make sense, the type would need to be `Copy`, // For this suggestion to make sense, the type would need to be `Copy`,
// or we have to be moving out of a `Box<T>` // or we have to be moving out of a `Box<T>`
if self.infcx.type_is_copy_modulo_regions(self.param_env, expected, sp) if self.type_is_copy_modulo_regions(self.param_env, expected, sp)
// FIXME(compiler-errors): We can actually do this if the checked_ty is // FIXME(compiler-errors): We can actually do this if the checked_ty is
// `steps` layers of boxes, not just one, but this is easier and most likely. // `steps` layers of boxes, not just one, but this is easier and most likely.
|| (checked_ty.is_box() && steps == 1) || (checked_ty.is_box() && steps == 1)

View file

@ -2235,7 +2235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
base: &'tcx hir::Expr<'tcx>, base: &'tcx hir::Expr<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
) { ) {
let output_ty = match self.infcx.get_impl_future_output_ty(ty) { let output_ty = match self.get_impl_future_output_ty(ty) {
Some(output_ty) => self.resolve_vars_if_possible(output_ty), Some(output_ty) => self.resolve_vars_if_possible(output_ty),
_ => return, _ => return,
}; };

View file

@ -218,9 +218,9 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
.diverging_type_vars .diverging_type_vars
.borrow() .borrow()
.iter() .iter()
.map(|&ty| self.infcx.shallow_resolve(ty)) .map(|&ty| self.shallow_resolve(ty))
.filter_map(|ty| ty.ty_vid()) .filter_map(|ty| ty.ty_vid())
.map(|vid| self.infcx.root_var(vid)) .map(|vid| self.root_var(vid))
.collect(); .collect();
debug!( debug!(
"calculate_diverging_fallback: diverging_type_vars={:?}", "calculate_diverging_fallback: diverging_type_vars={:?}",
@ -236,7 +236,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
let mut diverging_vids = vec![]; let mut diverging_vids = vec![];
let mut non_diverging_vids = vec![]; let mut non_diverging_vids = vec![];
for unsolved_vid in unsolved_vids { for unsolved_vid in unsolved_vids {
let root_vid = self.infcx.root_var(unsolved_vid); let root_vid = self.root_var(unsolved_vid);
debug!( debug!(
"calculate_diverging_fallback: unsolved_vid={:?} root_vid={:?} diverges={:?}", "calculate_diverging_fallback: unsolved_vid={:?} root_vid={:?} diverges={:?}",
unsolved_vid, unsolved_vid,
@ -271,7 +271,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
// variables. (Note that this set consists of "root variables".) // variables. (Note that this set consists of "root variables".)
let mut roots_reachable_from_non_diverging = DepthFirstSearch::new(&coercion_graph); let mut roots_reachable_from_non_diverging = DepthFirstSearch::new(&coercion_graph);
for &non_diverging_vid in &non_diverging_vids { for &non_diverging_vid in &non_diverging_vids {
let root_vid = self.infcx.root_var(non_diverging_vid); let root_vid = self.root_var(non_diverging_vid);
if roots_reachable_from_diverging.visited(root_vid) { if roots_reachable_from_diverging.visited(root_vid) {
continue; continue;
} }
@ -294,7 +294,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
diverging_fallback.reserve(diverging_vids.len()); diverging_fallback.reserve(diverging_vids.len());
for &diverging_vid in &diverging_vids { for &diverging_vid in &diverging_vids {
let diverging_ty = self.tcx.mk_ty_var(diverging_vid); let diverging_ty = self.tcx.mk_ty_var(diverging_vid);
let root_vid = self.infcx.root_var(diverging_vid); let root_vid = self.root_var(diverging_vid);
let can_reach_non_diverging = coercion_graph let can_reach_non_diverging = coercion_graph
.depth_first_search(root_vid) .depth_first_search(root_vid)
.any(|n| roots_reachable_from_non_diverging.visited(n)); .any(|n| roots_reachable_from_non_diverging.visited(n));
@ -302,7 +302,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
let mut relationship = ty::FoundRelationships { self_in_trait: false, output: false }; let mut relationship = ty::FoundRelationships { self_in_trait: false, output: false };
for (vid, rel) in relationships.iter() { for (vid, rel) in relationships.iter() {
if self.infcx.root_var(*vid) == root_vid { if self.root_var(*vid) == root_vid {
relationship.self_in_trait |= rel.self_in_trait; relationship.self_in_trait |= rel.self_in_trait;
relationship.output |= rel.output; relationship.output |= rel.output;
} }
@ -387,12 +387,12 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
}) })
.collect(); .collect();
debug!("create_coercion_graph: coercion_edges={:?}", coercion_edges); debug!("create_coercion_graph: coercion_edges={:?}", coercion_edges);
let num_ty_vars = self.infcx.num_ty_vars(); let num_ty_vars = self.num_ty_vars();
VecGraph::new(num_ty_vars, coercion_edges) VecGraph::new(num_ty_vars, coercion_edges)
} }
/// If `ty` is an unresolved type variable, returns its root vid. /// If `ty` is an unresolved type variable, returns its root vid.
fn root_vid(&self, ty: Ty<'tcx>) -> Option<ty::TyVid> { fn root_vid(&self, ty: Ty<'tcx>) -> Option<ty::TyVid> {
Some(self.infcx.root_var(self.infcx.shallow_resolve(ty).ty_vid()?)) Some(self.root_var(self.shallow_resolve(ty).ty_vid()?))
} }
} }

View file

@ -185,12 +185,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !method.substs.is_empty() { if !method.substs.is_empty() {
let method_generics = self.tcx.generics_of(method.def_id); let method_generics = self.tcx.generics_of(method.def_id);
if !method_generics.params.is_empty() { if !method_generics.params.is_empty() {
let user_type_annotation = self.infcx.probe(|_| { let user_type_annotation = self.probe(|_| {
let user_substs = UserSubsts { let user_substs = UserSubsts {
substs: InternalSubsts::for_item(self.tcx, method.def_id, |param, _| { substs: InternalSubsts::for_item(self.tcx, method.def_id, |param, _| {
let i = param.index as usize; let i = param.index as usize;
if i < method_generics.parent_count { if i < method_generics.parent_count {
self.infcx.var_for_def(DUMMY_SP, param) self.var_for_def(DUMMY_SP, param)
} else { } else {
method.substs[i] method.substs[i]
} }
@ -198,7 +198,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
user_self_ty: None, // not relevant here user_self_ty: None, // not relevant here
}; };
self.infcx.canonicalize_user_type_annotation(UserType::TypeOf( self.canonicalize_user_type_annotation(UserType::TypeOf(
method.def_id, method.def_id,
user_substs, user_substs,
)) ))
@ -236,7 +236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!("fcx {}", self.tag()); debug!("fcx {}", self.tag());
if Self::can_contain_user_lifetime_bounds((substs, user_self_ty)) { if Self::can_contain_user_lifetime_bounds((substs, user_self_ty)) {
let canonicalized = self.infcx.canonicalize_user_type_annotation(UserType::TypeOf( let canonicalized = self.canonicalize_user_type_annotation(UserType::TypeOf(
def_id, def_id,
UserSubsts { substs, user_self_ty }, UserSubsts { substs, user_self_ty },
)); ));
@ -480,7 +480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!("to_ty_saving_user_provided_ty: ty={:?}", ty); debug!("to_ty_saving_user_provided_ty: ty={:?}", ty);
if Self::can_contain_user_lifetime_bounds(ty) { if Self::can_contain_user_lifetime_bounds(ty) {
let c_ty = self.infcx.canonicalize_response(UserType::Ty(ty)); let c_ty = self.canonicalize_response(UserType::Ty(ty));
debug!("to_ty_saving_user_provided_ty: c_ty={:?}", c_ty); debug!("to_ty_saving_user_provided_ty: c_ty={:?}", c_ty);
self.typeck_results.borrow_mut().user_provided_types_mut().insert(ast_ty.hir_id, c_ty); self.typeck_results.borrow_mut().user_provided_types_mut().insert(ast_ty.hir_id, c_ty);
} }
@ -764,7 +764,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let ty::subst::GenericArgKind::Type(ty) = ty.unpack() if let ty::subst::GenericArgKind::Type(ty) = ty.unpack()
&& let ty::Opaque(def_id, _) = *ty.kind() && let ty::Opaque(def_id, _) = *ty.kind()
&& let Some(def_id) = def_id.as_local() && let Some(def_id) = def_id.as_local()
&& self.infcx.opaque_type_origin(def_id, DUMMY_SP).is_some() { && self.opaque_type_origin(def_id, DUMMY_SP).is_some() {
return None; return None;
} }
} }
@ -826,7 +826,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else { } else {
self.tcx.bound_type_of(def_id) self.tcx.bound_type_of(def_id)
}; };
let substs = self.infcx.fresh_substs_for_item(span, def_id); let substs = self.fresh_substs_for_item(span, def_id);
let ty = item_ty.subst(self.tcx, substs); let ty = item_ty.subst(self.tcx, substs);
self.write_resolution(hir_id, Ok((def_kind, def_id))); self.write_resolution(hir_id, Ok((def_kind, def_id)));

View file

@ -1520,21 +1520,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// ``` /// ```
fn get_expr_coercion_span(&self, expr: &hir::Expr<'_>) -> rustc_span::Span { fn get_expr_coercion_span(&self, expr: &hir::Expr<'_>) -> rustc_span::Span {
let check_in_progress = |elem: &hir::Expr<'_>| { let check_in_progress = |elem: &hir::Expr<'_>| {
self.in_progress_typeck_results self.typeck_results.borrow().node_type_opt(elem.hir_id).filter(|ty| !ty.is_never()).map(
.and_then(|typeck_results| typeck_results.borrow().node_type_opt(elem.hir_id)) |_| match elem.kind {
.and_then(|ty| { // Point at the tail expression when possible.
if ty.is_never() { hir::ExprKind::Block(block, _) => block.expr.map_or(block.span, |e| e.span),
None _ => elem.span,
} else { },
Some(match elem.kind { )
// Point at the tail expression when possible.
hir::ExprKind::Block(block, _) => {
block.expr.map_or(block.span, |e| e.span)
}
_ => elem.span,
})
}
})
}; };
if let hir::ExprKind::If(_, _, Some(el)) = expr.kind { if let hir::ExprKind::If(_, _, Some(el)) = expr.kind {

View file

@ -343,7 +343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result<R, MethodError<'tcx>>, OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result<R, MethodError<'tcx>>,
{ {
let mut orig_values = OriginalQueryValues::default(); let mut orig_values = OriginalQueryValues::default();
let param_env_and_self_ty = self.infcx.canonicalize_query( let param_env_and_self_ty = self.canonicalize_query(
ParamEnvAnd { param_env: self.param_env, value: self_ty }, ParamEnvAnd { param_env: self.param_env, value: self_ty },
&mut orig_values, &mut orig_values,
); );
@ -351,7 +351,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let steps = if mode == Mode::MethodCall { let steps = if mode == Mode::MethodCall {
self.tcx.method_autoderef_steps(param_env_and_self_ty) self.tcx.method_autoderef_steps(param_env_and_self_ty)
} else { } else {
self.infcx.probe(|_| { self.probe(|_| {
// Mode::Path - the deref steps is "trivial". This turns // Mode::Path - the deref steps is "trivial". This turns
// our CanonicalQuery into a "trivial" QueryResponse. This // our CanonicalQuery into a "trivial" QueryResponse. This
// is a bit inefficient, but I don't think that writing // is a bit inefficient, but I don't think that writing

View file

@ -865,27 +865,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.join("\n"); .join("\n");
let actual_prefix = actual.prefix_string(self.tcx); let actual_prefix = actual.prefix_string(self.tcx);
info!("unimplemented_traits.len() == {}", unimplemented_traits.len()); info!("unimplemented_traits.len() == {}", unimplemented_traits.len());
let (primary_message, label) = if unimplemented_traits.len() == 1 let (primary_message, label) =
&& unimplemented_traits_only if unimplemented_traits.len() == 1 && unimplemented_traits_only {
{ unimplemented_traits
unimplemented_traits .into_iter()
.into_iter() .next()
.next() .map(|(_, (trait_ref, obligation))| {
.map(|(_, (trait_ref, obligation))| { if trait_ref.self_ty().references_error()
if trait_ref.self_ty().references_error() || actual.references_error()
|| actual.references_error() {
{ // Avoid crashing.
// Avoid crashing. return (None, None);
return (None, None); }
} let OnUnimplementedNote { message, label, .. } =
let OnUnimplementedNote { message, label, .. } = self.on_unimplemented_note(trait_ref, &obligation);
self.infcx.on_unimplemented_note(trait_ref, &obligation); (message, label)
(message, label) })
}) .unwrap_or((None, None))
.unwrap_or((None, None)) } else {
} else { (None, None)
(None, None) };
};
let primary_message = primary_message.unwrap_or_else(|| format!( let primary_message = primary_message.unwrap_or_else(|| format!(
"the {item_kind} `{item_name}` exists for {actual_prefix} `{ty_str}`, but its trait bounds were not satisfied" "the {item_kind} `{item_name}` exists for {actual_prefix} `{ty_str}`, but its trait bounds were not satisfied"
)); ));
@ -1648,7 +1647,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call: &hir::Expr<'_>, call: &hir::Expr<'_>,
span: Span, span: Span,
) { ) {
let output_ty = match self.infcx.get_impl_future_output_ty(ty) { let output_ty = match self.get_impl_future_output_ty(ty) {
Some(output_ty) => self.resolve_vars_if_possible(output_ty).skip_binder(), Some(output_ty) => self.resolve_vars_if_possible(output_ty).skip_binder(),
_ => return, _ => return,
}; };

View file

@ -475,7 +475,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
suggest_deref_binop(lhs_deref_ty); suggest_deref_binop(lhs_deref_ty);
} else if is_assign == IsAssign::No } else if is_assign == IsAssign::No
&& let Ref(_, lhs_deref_ty, _) = lhs_ty.kind() { && let Ref(_, lhs_deref_ty, _) = lhs_ty.kind() {
if self.infcx.type_is_copy_modulo_regions(self.param_env, *lhs_deref_ty, lhs_expr.span) { if self.type_is_copy_modulo_regions(self.param_env, *lhs_deref_ty, lhs_expr.span) {
suggest_deref_binop(*lhs_deref_ty); suggest_deref_binop(*lhs_deref_ty);
} }
} }
@ -523,7 +523,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => None, _ => None,
}; };
self.infcx.suggest_restricting_param_bound( self.suggest_restricting_param_bound(
&mut err, &mut err,
trait_pred, trait_pred,
proj_pred, proj_pred,
@ -740,7 +740,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
error.obligation.predicate.to_opt_poly_trait_pred() error.obligation.predicate.to_opt_poly_trait_pred()
}); });
for pred in predicates { for pred in predicates {
self.infcx.suggest_restricting_param_bound( self.suggest_restricting_param_bound(
&mut err, &mut err,
pred, pred,
None, None,

View file

@ -948,7 +948,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let root_var_min_capture_list = min_captures.and_then(|m| m.get(&var_hir_id))?; let root_var_min_capture_list = min_captures.and_then(|m| m.get(&var_hir_id))?;
let ty = self.infcx.resolve_vars_if_possible(self.node_ty(var_hir_id)); let ty = self.resolve_vars_if_possible(self.node_ty(var_hir_id));
let ty = match closure_clause { let ty = match closure_clause {
hir::CaptureBy::Value => ty, // For move closure the capture kind should be by value hir::CaptureBy::Value => ty, // For move closure the capture kind should be by value
@ -1064,7 +1064,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
closure_clause: hir::CaptureBy, closure_clause: hir::CaptureBy,
var_hir_id: hir::HirId, var_hir_id: hir::HirId,
) -> Option<FxHashSet<UpvarMigrationInfo>> { ) -> Option<FxHashSet<UpvarMigrationInfo>> {
let ty = self.infcx.resolve_vars_if_possible(self.node_ty(var_hir_id)); let ty = self.resolve_vars_if_possible(self.node_ty(var_hir_id));
if !ty.has_significant_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local())) { if !ty.has_significant_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local())) {
debug!("does not have significant drop"); debug!("does not have significant drop");

View file

@ -748,7 +748,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
// (e.g. keep `for<'a>` named `for<'a>`). // (e.g. keep `for<'a>` named `for<'a>`).
// This allows NLL to generate error messages that // This allows NLL to generate error messages that
// refer to the higher-ranked lifetime names written by the user. // refer to the higher-ranked lifetime names written by the user.
EraseEarlyRegions { tcx: self.infcx.tcx }.fold_ty(t) EraseEarlyRegions { tcx: self.tcx }.fold_ty(t)
} }
Err(_) => { Err(_) => {
debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t); debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t);
@ -766,7 +766,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> { fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
match self.infcx.fully_resolve(ct) { match self.infcx.fully_resolve(ct) {
Ok(ct) => self.infcx.tcx.erase_regions(ct), Ok(ct) => self.tcx.erase_regions(ct),
Err(_) => { Err(_) => {
debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct); debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct);
self.report_const_error(ct); self.report_const_error(ct);