mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Rollup merge of #85033 - lcnr:nits2, r=jackh726
some further small cleanups
This commit is contained in:
commit
42848090b5
@ -720,11 +720,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
pub(in super::super) fn select_obligations_where_possible(
|
pub(in super::super) fn select_obligations_where_possible(
|
||||||
&self,
|
&self,
|
||||||
fallback_has_occurred: bool,
|
fallback_has_occurred: bool,
|
||||||
mutate_fullfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
|
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
|
||||||
) {
|
) {
|
||||||
let result = self.fulfillment_cx.borrow_mut().select_where_possible(self);
|
let result = self.fulfillment_cx.borrow_mut().select_where_possible(self);
|
||||||
if let Err(mut errors) = result {
|
if let Err(mut errors) = result {
|
||||||
mutate_fullfillment_errors(&mut errors);
|
mutate_fulfillment_errors(&mut errors);
|
||||||
self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred);
|
self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -986,7 +986,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
error.obligation.predicate.kind().skip_binder()
|
error.obligation.predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
// If any of the type arguments in this path segment caused the
|
// If any of the type arguments in this path segment caused the
|
||||||
// `FullfillmentError`, point at its span (#61860).
|
// `FulfillmentError`, point at its span (#61860).
|
||||||
for arg in path
|
for arg in path
|
||||||
.segments
|
.segments
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -43,7 +43,7 @@ struct CheckWfFcxBuilder<'tcx> {
|
|||||||
impl<'tcx> CheckWfFcxBuilder<'tcx> {
|
impl<'tcx> CheckWfFcxBuilder<'tcx> {
|
||||||
fn with_fcx<F>(&mut self, f: F)
|
fn with_fcx<F>(&mut self, f: F)
|
||||||
where
|
where
|
||||||
F: for<'b> FnOnce(&FnCtxt<'b, 'tcx>, TyCtxt<'tcx>) -> Vec<Ty<'tcx>>,
|
F: for<'b> FnOnce(&FnCtxt<'b, 'tcx>) -> Vec<Ty<'tcx>>,
|
||||||
{
|
{
|
||||||
let id = self.id;
|
let id = self.id;
|
||||||
let span = self.span;
|
let span = self.span;
|
||||||
@ -56,7 +56,7 @@ impl<'tcx> CheckWfFcxBuilder<'tcx> {
|
|||||||
// empty `param_env`.
|
// empty `param_env`.
|
||||||
check_false_global_bounds(&fcx, span, id);
|
check_false_global_bounds(&fcx, span, id);
|
||||||
}
|
}
|
||||||
let wf_tys = f(&fcx, fcx.tcx);
|
let wf_tys = f(&fcx);
|
||||||
fcx.select_all_obligations_or_error();
|
fcx.select_all_obligations_or_error();
|
||||||
fcx.regionck_item(id, span, &wf_tys);
|
fcx.regionck_item(id, span, &wf_tys);
|
||||||
});
|
});
|
||||||
@ -388,7 +388,7 @@ fn check_associated_item(
|
|||||||
debug!("check_associated_item: {:?}", item_id);
|
debug!("check_associated_item: {:?}", item_id);
|
||||||
|
|
||||||
let code = ObligationCauseCode::MiscObligation;
|
let code = ObligationCauseCode::MiscObligation;
|
||||||
for_id(tcx, item_id, span).with_fcx(|fcx, tcx| {
|
for_id(tcx, item_id, span).with_fcx(|fcx| {
|
||||||
let item = fcx.tcx.associated_item(fcx.tcx.hir().local_def_id(item_id));
|
let item = fcx.tcx.associated_item(fcx.tcx.hir().local_def_id(item_id));
|
||||||
|
|
||||||
let (mut implied_bounds, self_ty) = match item.container {
|
let (mut implied_bounds, self_ty) = match item.container {
|
||||||
@ -409,7 +409,6 @@ fn check_associated_item(
|
|||||||
let sig = fcx.normalize_associated_types_in(span, sig);
|
let sig = fcx.normalize_associated_types_in(span, sig);
|
||||||
let hir_sig = sig_if_method.expect("bad signature for method");
|
let hir_sig = sig_if_method.expect("bad signature for method");
|
||||||
check_fn_or_method(
|
check_fn_or_method(
|
||||||
tcx,
|
|
||||||
fcx,
|
fcx,
|
||||||
item.ident.span,
|
item.ident.span,
|
||||||
sig,
|
sig,
|
||||||
@ -467,9 +466,9 @@ fn check_type_defn<'tcx, F>(
|
|||||||
) where
|
) where
|
||||||
F: for<'fcx> FnMut(&FnCtxt<'fcx, 'tcx>) -> Vec<AdtVariant<'tcx>>,
|
F: for<'fcx> FnMut(&FnCtxt<'fcx, 'tcx>) -> Vec<AdtVariant<'tcx>>,
|
||||||
{
|
{
|
||||||
for_item(tcx, item).with_fcx(|fcx, fcx_tcx| {
|
for_item(tcx, item).with_fcx(|fcx| {
|
||||||
let variants = lookup_fields(fcx);
|
let variants = lookup_fields(fcx);
|
||||||
let packed = fcx.tcx.adt_def(item.def_id).repr.packed();
|
let packed = tcx.adt_def(item.def_id).repr.packed();
|
||||||
|
|
||||||
for variant in &variants {
|
for variant in &variants {
|
||||||
// For DST, or when drop needs to copy things around, all
|
// For DST, or when drop needs to copy things around, all
|
||||||
@ -477,15 +476,14 @@ fn check_type_defn<'tcx, F>(
|
|||||||
let needs_drop_copy = || {
|
let needs_drop_copy = || {
|
||||||
packed && {
|
packed && {
|
||||||
let ty = variant.fields.last().unwrap().ty;
|
let ty = variant.fields.last().unwrap().ty;
|
||||||
let ty = fcx.tcx.erase_regions(ty);
|
let ty = tcx.erase_regions(ty);
|
||||||
if ty.needs_infer() {
|
if ty.needs_infer() {
|
||||||
fcx_tcx
|
tcx.sess
|
||||||
.sess
|
|
||||||
.delay_span_bug(item.span, &format!("inference variables in {:?}", ty));
|
.delay_span_bug(item.span, &format!("inference variables in {:?}", ty));
|
||||||
// Just treat unresolved type expression as if it needs drop.
|
// Just treat unresolved type expression as if it needs drop.
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
ty.needs_drop(fcx_tcx, fcx_tcx.param_env(item.def_id))
|
ty.needs_drop(tcx, tcx.param_env(item.def_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -497,7 +495,7 @@ fn check_type_defn<'tcx, F>(
|
|||||||
let last = idx == variant.fields.len() - 1;
|
let last = idx == variant.fields.len() - 1;
|
||||||
fcx.register_bound(
|
fcx.register_bound(
|
||||||
field.ty,
|
field.ty,
|
||||||
fcx.tcx.require_lang_item(LangItem::Sized, None),
|
tcx.require_lang_item(LangItem::Sized, None),
|
||||||
traits::ObligationCause::new(
|
traits::ObligationCause::new(
|
||||||
field.span,
|
field.span,
|
||||||
fcx.body_id,
|
fcx.body_id,
|
||||||
@ -524,11 +522,10 @@ fn check_type_defn<'tcx, F>(
|
|||||||
|
|
||||||
// Explicit `enum` discriminant values must const-evaluate successfully.
|
// Explicit `enum` discriminant values must const-evaluate successfully.
|
||||||
if let Some(discr_def_id) = variant.explicit_discr {
|
if let Some(discr_def_id) = variant.explicit_discr {
|
||||||
let discr_substs =
|
let discr_substs = InternalSubsts::identity_for_item(tcx, discr_def_id.to_def_id());
|
||||||
InternalSubsts::identity_for_item(fcx.tcx, discr_def_id.to_def_id());
|
|
||||||
|
|
||||||
let cause = traits::ObligationCause::new(
|
let cause = traits::ObligationCause::new(
|
||||||
fcx.tcx.def_span(discr_def_id),
|
tcx.def_span(discr_def_id),
|
||||||
fcx.body_id,
|
fcx.body_id,
|
||||||
traits::MiscObligation,
|
traits::MiscObligation,
|
||||||
);
|
);
|
||||||
@ -539,12 +536,12 @@ fn check_type_defn<'tcx, F>(
|
|||||||
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
|
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
|
||||||
discr_substs,
|
discr_substs,
|
||||||
)
|
)
|
||||||
.to_predicate(fcx.tcx),
|
.to_predicate(tcx),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_where_clauses(tcx, fcx, item.span, item.def_id.to_def_id(), None);
|
check_where_clauses(fcx, item.span, item.def_id.to_def_id(), None);
|
||||||
|
|
||||||
// No implied bounds in a struct definition.
|
// No implied bounds in a struct definition.
|
||||||
vec![]
|
vec![]
|
||||||
@ -569,8 +566,9 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for_item(tcx, item).with_fcx(|fcx, _| {
|
// FIXME: this shouldn't use an `FnCtxt` at all.
|
||||||
check_where_clauses(tcx, fcx, item.span, item.def_id.to_def_id(), None);
|
for_item(tcx, item).with_fcx(|fcx| {
|
||||||
|
check_where_clauses(fcx, item.span, item.def_id.to_def_id(), None);
|
||||||
|
|
||||||
vec![]
|
vec![]
|
||||||
});
|
});
|
||||||
@ -610,20 +608,12 @@ fn check_item_fn(
|
|||||||
span: Span,
|
span: Span,
|
||||||
decl: &hir::FnDecl<'_>,
|
decl: &hir::FnDecl<'_>,
|
||||||
) {
|
) {
|
||||||
for_id(tcx, item_id, span).with_fcx(|fcx, tcx| {
|
for_id(tcx, item_id, span).with_fcx(|fcx| {
|
||||||
let def_id = fcx.tcx.hir().local_def_id(item_id);
|
let def_id = tcx.hir().local_def_id(item_id);
|
||||||
let sig = fcx.tcx.fn_sig(def_id);
|
let sig = tcx.fn_sig(def_id);
|
||||||
let sig = fcx.normalize_associated_types_in(span, sig);
|
let sig = fcx.normalize_associated_types_in(span, sig);
|
||||||
let mut implied_bounds = vec![];
|
let mut implied_bounds = vec![];
|
||||||
check_fn_or_method(
|
check_fn_or_method(fcx, ident.span, sig, decl, def_id.to_def_id(), &mut implied_bounds);
|
||||||
tcx,
|
|
||||||
fcx,
|
|
||||||
ident.span,
|
|
||||||
sig,
|
|
||||||
decl,
|
|
||||||
def_id.to_def_id(),
|
|
||||||
&mut implied_bounds,
|
|
||||||
);
|
|
||||||
implied_bounds
|
implied_bounds
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -631,7 +621,7 @@ fn check_item_fn(
|
|||||||
fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_foreign_ty: bool) {
|
fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_foreign_ty: bool) {
|
||||||
debug!("check_item_type: {:?}", item_id);
|
debug!("check_item_type: {:?}", item_id);
|
||||||
|
|
||||||
for_id(tcx, item_id, ty_span).with_fcx(|fcx, tcx| {
|
for_id(tcx, item_id, ty_span).with_fcx(|fcx| {
|
||||||
let ty = tcx.type_of(tcx.hir().local_def_id(item_id));
|
let ty = tcx.type_of(tcx.hir().local_def_id(item_id));
|
||||||
let item_ty = fcx.normalize_associated_types_in(ty_span, ty);
|
let item_ty = fcx.normalize_associated_types_in(ty_span, ty);
|
||||||
|
|
||||||
@ -647,7 +637,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo
|
|||||||
if forbid_unsized {
|
if forbid_unsized {
|
||||||
fcx.register_bound(
|
fcx.register_bound(
|
||||||
item_ty,
|
item_ty,
|
||||||
fcx.tcx.require_lang_item(LangItem::Sized, None),
|
tcx.require_lang_item(LangItem::Sized, None),
|
||||||
traits::ObligationCause::new(ty_span, fcx.body_id, traits::MiscObligation),
|
traits::ObligationCause::new(ty_span, fcx.body_id, traits::MiscObligation),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -665,13 +655,13 @@ fn check_impl<'tcx>(
|
|||||||
) {
|
) {
|
||||||
debug!("check_impl: {:?}", item);
|
debug!("check_impl: {:?}", item);
|
||||||
|
|
||||||
for_item(tcx, item).with_fcx(|fcx, tcx| {
|
for_item(tcx, item).with_fcx(|fcx| {
|
||||||
match *ast_trait_ref {
|
match *ast_trait_ref {
|
||||||
Some(ref ast_trait_ref) => {
|
Some(ref ast_trait_ref) => {
|
||||||
// `#[rustc_reservation_impl]` impls are not real impls and
|
// `#[rustc_reservation_impl]` impls are not real impls and
|
||||||
// therefore don't need to be WF (the trait's `Self: Trait` predicate
|
// therefore don't need to be WF (the trait's `Self: Trait` predicate
|
||||||
// won't hold).
|
// won't hold).
|
||||||
let trait_ref = fcx.tcx.impl_trait_ref(item.def_id).unwrap();
|
let trait_ref = tcx.impl_trait_ref(item.def_id).unwrap();
|
||||||
let trait_ref =
|
let trait_ref =
|
||||||
fcx.normalize_associated_types_in(ast_trait_ref.path.span, trait_ref);
|
fcx.normalize_associated_types_in(ast_trait_ref.path.span, trait_ref);
|
||||||
let obligations = traits::wf::trait_obligations(
|
let obligations = traits::wf::trait_obligations(
|
||||||
@ -687,7 +677,7 @@ fn check_impl<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let self_ty = fcx.tcx.type_of(item.def_id);
|
let self_ty = tcx.type_of(item.def_id);
|
||||||
let self_ty = fcx.normalize_associated_types_in(item.span, self_ty);
|
let self_ty = fcx.normalize_associated_types_in(item.span, self_ty);
|
||||||
fcx.register_wf_obligation(
|
fcx.register_wf_obligation(
|
||||||
self_ty.into(),
|
self_ty.into(),
|
||||||
@ -697,7 +687,7 @@ fn check_impl<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_where_clauses(tcx, fcx, item.span, item.def_id.to_def_id(), None);
|
check_where_clauses(fcx, item.span, item.def_id.to_def_id(), None);
|
||||||
|
|
||||||
fcx.impl_implied_bounds(item.def_id.to_def_id(), item.span)
|
fcx.impl_implied_bounds(item.def_id.to_def_id(), item.span)
|
||||||
});
|
});
|
||||||
@ -705,15 +695,15 @@ fn check_impl<'tcx>(
|
|||||||
|
|
||||||
/// Checks where-clauses and inline bounds that are declared on `def_id`.
|
/// Checks where-clauses and inline bounds that are declared on `def_id`.
|
||||||
fn check_where_clauses<'tcx, 'fcx>(
|
fn check_where_clauses<'tcx, 'fcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
fcx: &FnCtxt<'fcx, 'tcx>,
|
fcx: &FnCtxt<'fcx, 'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
return_ty: Option<(Ty<'tcx>, Span)>,
|
return_ty: Option<(Ty<'tcx>, Span)>,
|
||||||
) {
|
) {
|
||||||
debug!("check_where_clauses(def_id={:?}, return_ty={:?})", def_id, return_ty);
|
debug!("check_where_clauses(def_id={:?}, return_ty={:?})", def_id, return_ty);
|
||||||
|
let tcx = fcx.tcx;
|
||||||
|
|
||||||
let predicates = fcx.tcx.predicates_of(def_id);
|
let predicates = tcx.predicates_of(def_id);
|
||||||
let generics = tcx.generics_of(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
|
|
||||||
let is_our_default = |def: &ty::GenericParamDef| match def.kind {
|
let is_our_default = |def: &ty::GenericParamDef| match def.kind {
|
||||||
@ -734,14 +724,14 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
match param.kind {
|
match param.kind {
|
||||||
GenericParamDefKind::Type { .. } => {
|
GenericParamDefKind::Type { .. } => {
|
||||||
if is_our_default(¶m) {
|
if is_our_default(¶m) {
|
||||||
let ty = fcx.tcx.type_of(param.def_id);
|
let ty = tcx.type_of(param.def_id);
|
||||||
// Ignore dependent defaults -- that is, where the default of one type
|
// Ignore dependent defaults -- that is, where the default of one type
|
||||||
// parameter includes another (e.g., `<T, U = T>`). In those cases, we can't
|
// parameter includes another (e.g., `<T, U = T>`). In those cases, we can't
|
||||||
// be sure if it will error or not as user might always specify the other.
|
// be sure if it will error or not as user might always specify the other.
|
||||||
if !ty.needs_subst() {
|
if !ty.needs_subst() {
|
||||||
fcx.register_wf_obligation(
|
fcx.register_wf_obligation(
|
||||||
ty.into(),
|
ty.into(),
|
||||||
fcx.tcx.def_span(param.def_id),
|
tcx.def_span(param.def_id),
|
||||||
ObligationCauseCode::MiscObligation,
|
ObligationCauseCode::MiscObligation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -754,7 +744,7 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
let default_ct = tcx.const_param_default(param.def_id);
|
let default_ct = tcx.const_param_default(param.def_id);
|
||||||
fcx.register_wf_obligation(
|
fcx.register_wf_obligation(
|
||||||
default_ct.into(),
|
default_ct.into(),
|
||||||
fcx.tcx.def_span(param.def_id),
|
tcx.def_span(param.def_id),
|
||||||
ObligationCauseCode::MiscObligation,
|
ObligationCauseCode::MiscObligation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -772,17 +762,17 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
// For more examples see tests `defaults-well-formedness.rs` and `type-check-defaults.rs`.
|
// For more examples see tests `defaults-well-formedness.rs` and `type-check-defaults.rs`.
|
||||||
//
|
//
|
||||||
// First we build the defaulted substitution.
|
// First we build the defaulted substitution.
|
||||||
let substs = InternalSubsts::for_item(fcx.tcx, def_id, |param, _| {
|
let substs = InternalSubsts::for_item(tcx, def_id, |param, _| {
|
||||||
match param.kind {
|
match param.kind {
|
||||||
GenericParamDefKind::Lifetime => {
|
GenericParamDefKind::Lifetime => {
|
||||||
// All regions are identity.
|
// All regions are identity.
|
||||||
fcx.tcx.mk_param_from_def(param)
|
tcx.mk_param_from_def(param)
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericParamDefKind::Type { .. } => {
|
GenericParamDefKind::Type { .. } => {
|
||||||
// If the param has a default, ...
|
// If the param has a default, ...
|
||||||
if is_our_default(param) {
|
if is_our_default(param) {
|
||||||
let default_ty = fcx.tcx.type_of(param.def_id);
|
let default_ty = tcx.type_of(param.def_id);
|
||||||
// ... and it's not a dependent default, ...
|
// ... and it's not a dependent default, ...
|
||||||
if !default_ty.needs_subst() {
|
if !default_ty.needs_subst() {
|
||||||
// ... then substitute it with the default.
|
// ... then substitute it with the default.
|
||||||
@ -790,7 +780,7 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fcx.tcx.mk_param_from_def(param)
|
tcx.mk_param_from_def(param)
|
||||||
}
|
}
|
||||||
GenericParamDefKind::Const { .. } => {
|
GenericParamDefKind::Const { .. } => {
|
||||||
// FIXME(const_generics_defaults): I(@lcnr) feel like always
|
// FIXME(const_generics_defaults): I(@lcnr) feel like always
|
||||||
@ -811,7 +801,7 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fcx.tcx.mk_param_from_def(param)
|
tcx.mk_param_from_def(param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -848,7 +838,7 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
}
|
}
|
||||||
let mut param_count = CountParams::default();
|
let mut param_count = CountParams::default();
|
||||||
let has_region = pred.visit_with(&mut param_count).is_break();
|
let has_region = pred.visit_with(&mut param_count).is_break();
|
||||||
let substituted_pred = pred.subst(fcx.tcx, substs);
|
let substituted_pred = pred.subst(tcx, substs);
|
||||||
// Don't check non-defaulted params, dependent defaults (including lifetimes)
|
// Don't check non-defaulted params, dependent defaults (including lifetimes)
|
||||||
// or preds with multiple params.
|
// or preds with multiple params.
|
||||||
if substituted_pred.has_param_types_or_consts()
|
if substituted_pred.has_param_types_or_consts()
|
||||||
@ -879,14 +869,14 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
traits::Obligation::new(cause, fcx.param_env, pred)
|
traits::Obligation::new(cause, fcx.param_env, pred)
|
||||||
});
|
});
|
||||||
|
|
||||||
let predicates = predicates.instantiate_identity(fcx.tcx);
|
let predicates = predicates.instantiate_identity(tcx);
|
||||||
|
|
||||||
if let Some((mut return_ty, span)) = return_ty {
|
if let Some((mut return_ty, span)) = return_ty {
|
||||||
if return_ty.has_infer_types_or_consts() {
|
if return_ty.has_infer_types_or_consts() {
|
||||||
fcx.select_obligations_where_possible(false, |_| {});
|
fcx.select_obligations_where_possible(false, |_| {});
|
||||||
return_ty = fcx.resolve_vars_if_possible(return_ty);
|
return_ty = fcx.resolve_vars_if_possible(return_ty);
|
||||||
}
|
}
|
||||||
check_opaque_types(tcx, fcx, def_id.expect_local(), span, return_ty);
|
check_opaque_types(fcx, def_id.expect_local(), span, return_ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
let predicates = fcx.normalize_associated_types_in(span, predicates);
|
let predicates = fcx.normalize_associated_types_in(span, predicates);
|
||||||
@ -905,7 +895,6 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_fn_or_method<'fcx, 'tcx>(
|
fn check_fn_or_method<'fcx, 'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
fcx: &FnCtxt<'fcx, 'tcx>,
|
fcx: &FnCtxt<'fcx, 'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
sig: ty::PolyFnSig<'tcx>,
|
sig: ty::PolyFnSig<'tcx>,
|
||||||
@ -930,7 +919,7 @@ fn check_fn_or_method<'fcx, 'tcx>(
|
|||||||
// FIXME(#25759) return types should not be implied bounds
|
// FIXME(#25759) return types should not be implied bounds
|
||||||
implied_bounds.push(sig.output());
|
implied_bounds.push(sig.output());
|
||||||
|
|
||||||
check_where_clauses(tcx, fcx, span, def_id, Some((sig.output(), hir_decl.output.span())));
|
check_where_clauses(fcx, span, def_id, Some((sig.output(), hir_decl.output.span())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks "defining uses" of opaque `impl Trait` types to ensure that they meet the restrictions
|
/// Checks "defining uses" of opaque `impl Trait` types to ensure that they meet the restrictions
|
||||||
@ -953,15 +942,16 @@ fn check_fn_or_method<'fcx, 'tcx>(
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
fn check_opaque_types<'fcx, 'tcx>(
|
fn check_opaque_types<'fcx, 'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
fcx: &FnCtxt<'fcx, 'tcx>,
|
fcx: &FnCtxt<'fcx, 'tcx>,
|
||||||
fn_def_id: LocalDefId,
|
fn_def_id: LocalDefId,
|
||||||
span: Span,
|
span: Span,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) {
|
) {
|
||||||
trace!("check_opaque_types(ty={:?})", ty);
|
trace!("check_opaque_types(fn_def_id={:?}, ty={:?})", fn_def_id, ty);
|
||||||
|
let tcx = fcx.tcx;
|
||||||
|
|
||||||
ty.fold_with(&mut ty::fold::BottomUpFolder {
|
ty.fold_with(&mut ty::fold::BottomUpFolder {
|
||||||
tcx: fcx.tcx,
|
tcx,
|
||||||
ty_op: |ty| {
|
ty_op: |ty| {
|
||||||
if let ty::Opaque(def_id, substs) = *ty.kind() {
|
if let ty::Opaque(def_id, substs) = *ty.kind() {
|
||||||
trace!("check_opaque_types: opaque_ty, {:?}, {:?}", def_id, substs);
|
trace!("check_opaque_types: opaque_ty, {:?}, {:?}", def_id, substs);
|
||||||
|
Loading…
Reference in New Issue
Block a user