1use std::borrow::Cow;
2use std::iter;
3
4use rustc_abi::{CanonAbi, ExternAbi};
5use rustc_ast::util::parser::ExprPrecedence;
6use rustc_attr_ir::find_attr;
7use rustc_attr_ir::lang_items::LangItem;
8use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
9use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey, msg};
10use rustc_hir::def::{self, CtorKind, Namespace, Res};
11use rustc_hir::def_id::DefId;
12use rustc_hir::{self as hir, HirId};
13use rustc_hir_analysis::autoderef::Autoderef;
14use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
15use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode, WellFormedLoc};
16use rustc_middle::ty::adjustment::{
17 Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
18};
19use rustc_middle::ty::{self, FnSig, GenericArgs, Ty, TyCtxt, TypeVisitableExt, Unnormalized};
20use rustc_span::def_id::LocalDefId;
21use rustc_span::{Ident, Span, bug, sym};
22use rustc_target::spec::{AbiMap, AbiMapping};
23use rustc_trait_selection::error_reporting::traits::DefIdOrName;
24use rustc_trait_selection::infer::InferCtxtExt as _;
25use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
26use tracing::{debug, instrument};
27
28use super::method::MethodCallee;
29use super::method::probe::ProbeScope;
30use super::{Expectation, FnCtxt, TupleArgumentsFlag};
31use crate::diagnostics;
32use crate::method::TreatNotYetDefinedOpaques;
33use crate::method::confirm::ConfirmContext;
34use crate::method::probe::{IsSuggestion, Mode};
35
36#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for
SplatLoweringInfo<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::FnDef(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "FnDef",
&__self_0),
Self::FnPtr(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "FnPtr",
&__self_0),
Self::Error(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Error",
&__self_0),
}
}
}Debug, #[automatically_derived]impl<'tcx> ::core::marker::Copy for
SplatLoweringInfo<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
::core::clone::TrivialClone for SplatLoweringInfo<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
SplatLoweringInfo<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for SplatLoweringInfo<'tcx>
{
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<DefId>;
let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<ErrorGuaranteed>;
}
}Eq, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
SplatLoweringInfo<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for
SplatLoweringInfo<'tcx> {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::FnDef(__self_0), Self::FnDef(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::FnPtr(__self_0), Self::FnPtr(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Error(__self_0), Self::Error(__arg1_0)) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq)]
38pub(crate) enum SplatLoweringInfo<'tcx> {
39 FnDef(DefId),
42 FnPtr(Ty<'tcx>),
44 Error(ErrorGuaranteed),
46}
47
48pub(crate) fn check_legal_trait_for_method_call(
52 tcx: TyCtxt<'_>,
53 span: Span,
54 receiver: Option<Span>,
55 expr_span: Span,
56 trait_id: DefId,
57 body_def_id: DefId,
58) -> Result<(), ErrorGuaranteed> {
59 if tcx.is_lang_item(trait_id, LangItem::Drop)
60 && !tcx.is_lang_item(tcx.parent(body_def_id), LangItem::Drop)
62 {
63 let sugg = match receiver.filter(|s| !s.is_empty()) {
64 Some(receiver) => receiver
65 .find_ancestor_inside_same_ctxt(expr_span)
66 .filter(|receiver| !receiver.is_empty())
67 .map(|receiver| diagnostics::ExplicitDestructorCallSugg::Snippet {
68 lo: expr_span.shrink_to_lo().to(receiver.shrink_to_lo()),
69 hi: receiver.shrink_to_hi().to(expr_span.shrink_to_hi()),
70 }),
71 None => Some(diagnostics::ExplicitDestructorCallSugg::Empty(span)),
72 };
73 return Err(tcx.dcx().emit_err(diagnostics::ExplicitDestructorCall { span, sugg }));
74 }
75 tcx.ensure_result().coherent_trait(trait_id)
76}
77
78#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for CallStep<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Builtin(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Builtin", &__self_0),
Self::DeferredClosure(__self_0, __self_1) =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DeferredClosure", __self_0, &__self_1),
Self::Overloaded(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Overloaded", &__self_0),
}
}
}Debug)]
80enum CallStep<'tcx> {
81 Builtin(Ty<'tcx>),
84 DeferredClosure(LocalDefId, ty::FnSig<'tcx>),
86 Overloaded(MethodCallee<'tcx>),
88}
89
90impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
91 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::INFO <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("check_expr_call",
"rustc_hir_typeck::callee", ::tracing::Level::INFO,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs"),
::tracing_core::__macro_support::Option::Some(91u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::callee"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("call_expr")
}> =
::tracing::__macro_support::FieldName::new("call_expr");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("callee_expr")
}> =
::tracing::__macro_support::FieldName::new("callee_expr");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("arg_exprs")
}> =
::tracing::__macro_support::FieldName::new("arg_exprs");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("expected")
}> =
::tracing::__macro_support::FieldName::new("expected");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::INFO <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::INFO <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&call_expr)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&callee_expr)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&arg_exprs)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&expected)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: Ty<'tcx> = loop {};
return __tracing_attr_fake_return;
}
{
let original_callee_ty =
match &callee_expr.kind {
hir::ExprKind::Path(hir::QPath::Resolved(..) |
hir::QPath::TypeRelative(..)) =>
self.check_expr_with_expectation_and_args(callee_expr,
Expectation::NoExpectation, Some((call_expr, arg_exprs))),
_ => self.check_expr(callee_expr),
};
let expr_ty =
self.deeply_resolve_ignoring_regions_with_obligations(original_callee_ty);
let mut autoderef = self.autoderef(callee_expr.span, expr_ty);
let mut result = None;
while result.is_none() && autoderef.next().is_some() {
result =
self.try_overloaded_call_step(call_expr, callee_expr,
arg_exprs, &autoderef);
}
match *autoderef.final_ty().kind() {
ty::FnDef(def_id, _) => {
let abi =
self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi();
self.check_call_abi(abi, call_expr.span);
}
ty::FnPtr(_, header) => {
self.check_call_abi(header.abi(), call_expr.span);
}
_ => {}
}
if self.is_scalable_vector_ctor(autoderef.final_ty()) {
let mut err =
self.dcx().create_err(diagnostics::ScalableVectorCtor {
span: callee_expr.span,
ty: autoderef.final_ty(),
});
err.span_label(callee_expr.span,
"you can create scalable vectors using intrinsics");
Ty::new_error(self.tcx, err.emit_err());
}
self.register_predicates(autoderef.into_obligations());
let output =
match result {
None => {
for arg in arg_exprs { self.check_expr(arg); }
if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) =
&callee_expr.kind && let [segment] = path.segments {
self.dcx().try_steal_modify_and_emit_err(segment.ident.span,
StashKey::CallIntoMethod,
|err|
{
self.suggest_call_as_method(err, segment, arg_exprs,
call_expr, expected);
});
}
let guar =
self.report_invalid_callee(call_expr, callee_expr, expr_ty,
arg_exprs);
Ty::new_error(self.tcx, guar)
}
Some(CallStep::Builtin(callee_ty)) => {
self.confirm_builtin_call(call_expr, callee_expr, callee_ty,
arg_exprs, expected)
}
Some(CallStep::DeferredClosure(def_id, fn_sig)) => {
self.confirm_deferred_closure_call(call_expr, arg_exprs,
expected, def_id, fn_sig)
}
Some(CallStep::Overloaded(method_callee)) => {
self.confirm_overloaded_call(call_expr, arg_exprs, expected,
method_callee)
}
};
self.register_wf_obligation(output.into(), call_expr.span,
ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)));
output
}
}
}#[tracing::instrument(skip(self))]
92 pub(crate) fn check_expr_call(
93 &self,
94 call_expr: &'tcx hir::Expr<'tcx>,
95 callee_expr: &'tcx hir::Expr<'tcx>,
96 arg_exprs: &'tcx [hir::Expr<'tcx>],
97 expected: Expectation<'tcx>,
98 ) -> Ty<'tcx> {
99 let original_callee_ty = match &callee_expr.kind {
100 hir::ExprKind::Path(hir::QPath::Resolved(..) | hir::QPath::TypeRelative(..)) => self
101 .check_expr_with_expectation_and_args(
102 callee_expr,
103 Expectation::NoExpectation,
104 Some((call_expr, arg_exprs)),
105 ),
106 _ => self.check_expr(callee_expr),
107 };
108
109 let expr_ty = self.deeply_resolve_ignoring_regions_with_obligations(original_callee_ty);
110
111 let mut autoderef = self.autoderef(callee_expr.span, expr_ty);
112 let mut result = None;
113 while result.is_none() && autoderef.next().is_some() {
114 result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef);
115 }
116
117 match *autoderef.final_ty().kind() {
118 ty::FnDef(def_id, _) => {
119 let abi = self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi();
120 self.check_call_abi(abi, call_expr.span);
121 }
122 ty::FnPtr(_, header) => {
123 self.check_call_abi(header.abi(), call_expr.span);
124 }
125 _ => { }
126 }
127
128 if self.is_scalable_vector_ctor(autoderef.final_ty()) {
129 let mut err = self.dcx().create_err(diagnostics::ScalableVectorCtor {
130 span: callee_expr.span,
131 ty: autoderef.final_ty(),
132 });
133 err.span_label(callee_expr.span, "you can create scalable vectors using intrinsics");
134 Ty::new_error(self.tcx, err.emit_err());
135 }
136
137 self.register_predicates(autoderef.into_obligations());
138
139 let output = match result {
140 None => {
141 for arg in arg_exprs {
144 self.check_expr(arg);
145 }
146
147 if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &callee_expr.kind
148 && let [segment] = path.segments
149 {
150 self.dcx().try_steal_modify_and_emit_err(
151 segment.ident.span,
152 StashKey::CallIntoMethod,
153 |err| {
154 self.suggest_call_as_method(
156 err, segment, arg_exprs, call_expr, expected,
157 );
158 },
159 );
160 }
161
162 let guar = self.report_invalid_callee(call_expr, callee_expr, expr_ty, arg_exprs);
163 Ty::new_error(self.tcx, guar)
164 }
165
166 Some(CallStep::Builtin(callee_ty)) => {
167 self.confirm_builtin_call(call_expr, callee_expr, callee_ty, arg_exprs, expected)
168 }
169
170 Some(CallStep::DeferredClosure(def_id, fn_sig)) => {
171 self.confirm_deferred_closure_call(call_expr, arg_exprs, expected, def_id, fn_sig)
172 }
173
174 Some(CallStep::Overloaded(method_callee)) => {
175 self.confirm_overloaded_call(call_expr, arg_exprs, expected, method_callee)
176 }
177 };
178
179 self.register_wf_obligation(
181 output.into(),
182 call_expr.span,
183 ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)),
184 );
185
186 output
187 }
188
189 pub(crate) fn check_call_abi(&self, abi: ExternAbi, span: Span) {
194 let canon_abi = match AbiMap::from_target(&self.sess().target).canonize_abi(abi, false) {
195 AbiMapping::Direct(canon_abi) | AbiMapping::Deprecated(canon_abi) => canon_abi,
196 AbiMapping::Invalid => {
197 let guar = self.dcx().span_delayed_bug(
200 span,
201 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("invalid abi for platform should have reported an error: {0}",
abi))
})format!("invalid abi for platform should have reported an error: {abi}"),
202 );
203 self.set_tainted_by_errors(guar);
204 return;
205 }
206 };
207
208 match canon_abi {
209 CanonAbi::Custom
211 | CanonAbi::Interrupt(_) => {
214 let err = crate::diagnostics::AbiCannotBeCalled { span, abi };
215 self.tcx.dcx().emit_err(err);
216 }
217
218 CanonAbi::GpuKernel => {
220 let err = crate::diagnostics::GpuKernelAbiCannotBeCalled { span };
221 self.tcx.dcx().emit_err(err);
222 }
223
224 CanonAbi::C
225 | CanonAbi::Rust
226 | CanonAbi::RustCold
227 | CanonAbi::RustPreserveNone
228 | CanonAbi::RustTail
229 | CanonAbi::Swift
230 | CanonAbi::Arm(_)
231 | CanonAbi::X86(_) => {}
232 }
233 }
234
235 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("try_overloaded_call_step",
"rustc_hir_typeck::callee", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs"),
::tracing_core::__macro_support::Option::Some(235u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::callee"),
::tracing_core::field::FieldSet::new(&[],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{ meta.fields().value_set_all(&[]) })
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: Option<CallStep<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
let adjusted_ty =
self.deeply_resolve_ignoring_regions_with_obligations(autoderef.final_ty());
match *adjusted_ty.kind() {
ty::FnDef(..) | ty::FnPtr(..) => {
let adjustments = self.adjust_steps(autoderef);
self.apply_adjustments(callee_expr, adjustments);
return Some(CallStep::Builtin(adjusted_ty));
}
ty::Closure(def_id, args) if
self.closure_kind(adjusted_ty).is_none() => {
let def_id = def_id.expect_local();
let closure_sig = args.as_closure().sig();
let closure_sig =
self.instantiate_binder_with_fresh_vars(call_expr.span,
BoundRegionConversionTime::FnCall, closure_sig);
let adjustments = self.adjust_steps(autoderef);
self.record_deferred_call_resolution(def_id,
DeferredCallResolution {
call_expr,
callee_expr,
closure_ty: adjusted_ty,
adjustments,
fn_sig: closure_sig,
});
return Some(CallStep::DeferredClosure(def_id, closure_sig));
}
ty::CoroutineClosure(def_id, args) if
self.closure_kind(adjusted_ty).is_none() => {
let def_id = def_id.expect_local();
let closure_args = args.as_coroutine_closure();
let coroutine_closure_sig =
self.instantiate_binder_with_fresh_vars(call_expr.span,
BoundRegionConversionTime::FnCall,
closure_args.coroutine_closure_sig());
let tupled_upvars_ty = self.next_ty_var(callee_expr.span);
let kind_ty = self.next_ty_var(callee_expr.span);
let call_sig =
self.tcx.mk_fn_sig([coroutine_closure_sig.tupled_inputs_ty],
coroutine_closure_sig.to_coroutine(self.tcx,
closure_args.parent_args(), kind_ty,
self.tcx.coroutine_for_closure(def_id), tupled_upvars_ty),
coroutine_closure_sig.fn_sig_kind);
let adjustments = self.adjust_steps(autoderef);
self.record_deferred_call_resolution(def_id,
DeferredCallResolution {
call_expr,
callee_expr,
closure_ty: adjusted_ty,
adjustments,
fn_sig: call_sig,
});
return Some(CallStep::DeferredClosure(def_id, call_sig));
}
ty::Ref(..) if autoderef.step_count() == 0 => {
return None;
}
ty::Infer(ty::TyVar(vid)) => {
if !self.has_opaques_with_sub_unified_hidden_type(vid) {
self.type_must_be_known_at_this_point(autoderef.span(),
adjusted_ty);
return None;
}
}
ty::Error(_) => { return None; }
_ => {}
}
self.try_overloaded_call_traits(call_expr, adjusted_ty,
Some(arg_exprs)).or_else(||
self.try_overloaded_call_traits(call_expr, adjusted_ty,
None)).map(|(autoref, method)|
{
let mut adjustments = self.adjust_steps(autoderef);
adjustments.extend(autoref);
self.apply_adjustments(callee_expr, adjustments);
CallStep::Overloaded(method)
})
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs:235",
"rustc_hir_typeck::callee", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs"),
::tracing_core::__macro_support::Option::Some(235u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::callee"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self, call_expr, callee_expr, arg_exprs, autoderef), ret)]
236 fn try_overloaded_call_step(
237 &self,
238 call_expr: &'tcx hir::Expr<'tcx>,
239 callee_expr: &'tcx hir::Expr<'tcx>,
240 arg_exprs: &'tcx [hir::Expr<'tcx>],
241 autoderef: &Autoderef<'a, 'tcx>,
242 ) -> Option<CallStep<'tcx>> {
243 let adjusted_ty =
244 self.deeply_resolve_ignoring_regions_with_obligations(autoderef.final_ty());
245
246 match *adjusted_ty.kind() {
248 ty::FnDef(..) | ty::FnPtr(..) => {
249 let adjustments = self.adjust_steps(autoderef);
250 self.apply_adjustments(callee_expr, adjustments);
251 return Some(CallStep::Builtin(adjusted_ty));
252 }
253
254 ty::Closure(def_id, args) if self.closure_kind(adjusted_ty).is_none() => {
258 let def_id = def_id.expect_local();
259 let closure_sig = args.as_closure().sig();
260 let closure_sig = self.instantiate_binder_with_fresh_vars(
261 call_expr.span,
262 BoundRegionConversionTime::FnCall,
263 closure_sig,
264 );
265 let adjustments = self.adjust_steps(autoderef);
266 self.record_deferred_call_resolution(
267 def_id,
268 DeferredCallResolution {
269 call_expr,
270 callee_expr,
271 closure_ty: adjusted_ty,
272 adjustments,
273 fn_sig: closure_sig,
274 },
275 );
276 return Some(CallStep::DeferredClosure(def_id, closure_sig));
277 }
278
279 ty::CoroutineClosure(def_id, args) if self.closure_kind(adjusted_ty).is_none() => {
285 let def_id = def_id.expect_local();
286 let closure_args = args.as_coroutine_closure();
287 let coroutine_closure_sig = self.instantiate_binder_with_fresh_vars(
288 call_expr.span,
289 BoundRegionConversionTime::FnCall,
290 closure_args.coroutine_closure_sig(),
291 );
292 let tupled_upvars_ty = self.next_ty_var(callee_expr.span);
293 let kind_ty = self.next_ty_var(callee_expr.span);
298 let call_sig = self.tcx.mk_fn_sig(
299 [coroutine_closure_sig.tupled_inputs_ty],
300 coroutine_closure_sig.to_coroutine(
301 self.tcx,
302 closure_args.parent_args(),
303 kind_ty,
304 self.tcx.coroutine_for_closure(def_id),
305 tupled_upvars_ty,
306 ),
307 coroutine_closure_sig.fn_sig_kind,
308 );
309 let adjustments = self.adjust_steps(autoderef);
310 self.record_deferred_call_resolution(
311 def_id,
312 DeferredCallResolution {
313 call_expr,
314 callee_expr,
315 closure_ty: adjusted_ty,
316 adjustments,
317 fn_sig: call_sig,
318 },
319 );
320 return Some(CallStep::DeferredClosure(def_id, call_sig));
321 }
322
323 ty::Ref(..) if autoderef.step_count() == 0 => {
336 return None;
337 }
338
339 ty::Infer(ty::TyVar(vid)) => {
340 if !self.has_opaques_with_sub_unified_hidden_type(vid) {
343 self.type_must_be_known_at_this_point(autoderef.span(), adjusted_ty);
344 return None;
345 }
346 }
347
348 ty::Error(_) => {
349 return None;
350 }
351
352 _ => {}
353 }
354
355 self.try_overloaded_call_traits(call_expr, adjusted_ty, Some(arg_exprs))
363 .or_else(|| self.try_overloaded_call_traits(call_expr, adjusted_ty, None))
364 .map(|(autoref, method)| {
365 let mut adjustments = self.adjust_steps(autoderef);
366 adjustments.extend(autoref);
367 self.apply_adjustments(callee_expr, adjustments);
368 CallStep::Overloaded(method)
369 })
370 }
371
372 fn try_overloaded_call_traits(
373 &self,
374 call_expr: &hir::Expr<'_>,
375 adjusted_ty: Ty<'tcx>,
376 opt_arg_exprs: Option<&'tcx [hir::Expr<'tcx>]>,
377 ) -> Option<(Option<Adjustment<'tcx>>, MethodCallee<'tcx>)> {
378 let call_trait_choices = if self.shallow_resolve(adjusted_ty).is_coroutine_closure() {
391 [
392 (self.tcx.lang_items().async_fn_trait(), sym::async_call, true),
393 (self.tcx.lang_items().async_fn_mut_trait(), sym::async_call_mut, true),
394 (self.tcx.lang_items().async_fn_once_trait(), sym::async_call_once, false),
395 (self.tcx.lang_items().fn_trait(), sym::call, true),
396 (self.tcx.lang_items().fn_mut_trait(), sym::call_mut, true),
397 (self.tcx.lang_items().fn_once_trait(), sym::call_once, false),
398 ]
399 } else {
400 [
401 (self.tcx.lang_items().fn_trait(), sym::call, true),
402 (self.tcx.lang_items().fn_mut_trait(), sym::call_mut, true),
403 (self.tcx.lang_items().fn_once_trait(), sym::call_once, false),
404 (self.tcx.lang_items().async_fn_trait(), sym::async_call, true),
405 (self.tcx.lang_items().async_fn_mut_trait(), sym::async_call_mut, true),
406 (self.tcx.lang_items().async_fn_once_trait(), sym::async_call_once, false),
407 ]
408 };
409
410 for (opt_trait_def_id, method_name, borrow) in call_trait_choices {
412 let Some(trait_def_id) = opt_trait_def_id else { continue };
413
414 let opt_input_type = opt_arg_exprs.map(|arg_exprs| {
415 Ty::new_tup_from_iter(self.tcx, arg_exprs.iter().map(|e| self.next_ty_var(e.span)))
416 });
417
418 if let Some(ok) = self.lookup_method_for_operator(
425 self.misc(call_expr.span),
426 method_name,
427 trait_def_id,
428 adjusted_ty,
429 opt_input_type,
430 TreatNotYetDefinedOpaques::AsRigid,
431 ) {
432 let method = self.register_infer_ok_obligations(ok);
433 let mut autoref = None;
434 if borrow {
435 let ty::Ref(_, _, mutbl) = *method.sig.inputs()[0].kind() else {
438 ::rustc_span::macros::bug_impl(None,
format_args!("Expected `FnMut`/`Fn` to take receiver by-ref/by-mut"),
Location::caller())bug!("Expected `FnMut`/`Fn` to take receiver by-ref/by-mut")
439 };
440
441 let mutbl = AutoBorrowMutability::new(mutbl, AllowTwoPhase::No);
445
446 autoref = Some(Adjustment {
447 kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)),
448 target: method.sig.inputs()[0],
449 });
450 }
451
452 return Some((autoref, method));
453 }
454 }
455
456 None
457 }
458
459 fn is_scalable_vector_ctor(&self, callee_ty: Ty<'_>) -> bool {
460 if let ty::FnDef(def_id, _) = *callee_ty.kind()
461 && let def::DefKind::Ctor(def::CtorOf::Struct, _) = self.tcx.def_kind(def_id)
462 {
463 self.tcx
464 .opt_parent(def_id)
465 .and_then(|id| self.tcx.adt_def(id).repr().scalable)
466 .is_some()
467 } else {
468 false
469 }
470 }
471
472 fn identify_bad_closure_def_and_call(
475 &self,
476 err: &mut Diag<'_>,
477 hir_id: hir::HirId,
478 callee_node: &hir::ExprKind<'_>,
479 callee_span: Span,
480 ) {
481 let hir::ExprKind::Block(..) = callee_node else {
482 return;
484 };
485
486 let fn_decl_span = if let hir::Node::Expr(&hir::Expr {
487 kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }),
488 ..
489 }) = self.tcx.parent_hir_node(hir_id)
490 {
491 fn_decl_span
492 } else if let Some((
493 _,
494 hir::Node::Expr(&hir::Expr {
495 hir_id: parent_hir_id,
496 kind:
497 hir::ExprKind::Closure(&hir::Closure {
498 kind:
499 hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
500 hir::CoroutineDesugaring::Async,
501 hir::CoroutineSource::Closure,
502 )),
503 ..
504 }),
505 ..
506 }),
507 )) = self.tcx.hir_parent_iter(hir_id).nth(3)
508 {
509 let hir::Node::Expr(&hir::Expr {
512 kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }),
513 ..
514 }) = self.tcx.parent_hir_node(parent_hir_id)
515 else {
516 return;
517 };
518 fn_decl_span
519 } else {
520 return;
521 };
522
523 let start = fn_decl_span.shrink_to_lo();
524 let end = callee_span.shrink_to_hi();
525 err.multipart_suggestion(
526 "if you meant to create this closure and immediately call it, surround the \
527 closure with parentheses",
528 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[(start, "(".to_string()), (end, ")".to_string())]))vec![(start, "(".to_string()), (end, ")".to_string())],
529 Applicability::MaybeIncorrect,
530 );
531 }
532
533 fn maybe_suggest_bad_array_definition(
536 &self,
537 err: &mut Diag<'_>,
538 call_expr: &'tcx hir::Expr<'tcx>,
539 callee_expr: &'tcx hir::Expr<'tcx>,
540 ) -> bool {
541 let parent_node = self.tcx.parent_hir_node(call_expr.hir_id);
542 if let (
543 hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Array(_), .. }),
544 hir::ExprKind::Tup(exp),
545 hir::ExprKind::Call(_, args),
546 ) = (parent_node, &callee_expr.kind, &call_expr.kind)
547 && args.len() == exp.len()
548 {
549 let start = callee_expr.span.shrink_to_hi();
550 err.span_suggestion(
551 start,
552 "consider separating array elements with a comma",
553 ",",
554 Applicability::MaybeIncorrect,
555 );
556 return true;
557 }
558 false
559 }
560
561 fn confirm_builtin_call(
562 &self,
563 call_expr: &'tcx hir::Expr<'tcx>,
564 callee_expr: &'tcx hir::Expr<'tcx>,
565 callee_ty: Ty<'tcx>,
566 arg_exprs: &'tcx [hir::Expr<'tcx>],
567 expected: Expectation<'tcx>,
568 ) -> Ty<'tcx> {
569 let (fn_sig, def_id, callee_generic_args) = match *callee_ty.kind() {
570 ty::FnDef(def_id, args) => {
571 let args = args.no_bound_vars().unwrap();
572 self.enforce_context_effects(Some(call_expr.hir_id), call_expr.span, def_id, args);
573 let fn_sig = self.tcx.fn_sig(def_id).instantiate(self.tcx, args).skip_norm_wip();
574
575 if self.has_rustc_attrs && {
{
'done:
{
for i in
::rustc_attr_ir::HasAttrs::get_attrs(def_id, &self.tcx) {
#[allow(unused_imports)]
use ::rustc_attr_ir::AttributeKind::*;
let i: &::rustc_attr_ir::Attribute = i;
match i {
::rustc_attr_ir::Attribute::Parsed(RustcEvaluateWhereClauses)
=> {
break 'done Some(());
}
::rustc_attr_ir::Attribute::Tool { .. } |
::rustc_attr_ir::Attribute::DeriveHelper(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}.is_some()find_attr!(self.tcx, def_id, RustcEvaluateWhereClauses) {
579 let clauses = self.tcx.clauses_of(def_id);
580 let clauses = clauses.instantiate(self.tcx, args);
581 for (clause, clause_span) in clauses {
582 let clause = clause.skip_norm_wip();
583 let obligation = Obligation::new(
584 self.tcx,
585 ObligationCause::dummy_with_span(callee_expr.span),
586 self.param_env,
587 clause,
588 );
589 let result = self.evaluate_obligation(&obligation);
590 self.dcx()
591 .struct_span_err(
592 callee_expr.span,
593 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("evaluate({0:?}) = {1:?}", clause,
result))
})format!("evaluate({clause:?}) = {result:?}"),
594 )
595 .with_span_label(clause_span, "predicate")
596 .emit();
597 }
598 }
599 (fn_sig, Some(def_id), Some(args))
600 }
601
602 ty::FnPtr(sig_tys, hdr) => (sig_tys.with(hdr), None, None),
604
605 _ => ::core::panicking::unreachable_default_msg()unreachable!(),
606 };
607
608 let fn_sig = self.instantiate_binder_with_fresh_vars(
614 call_expr.span,
615 BoundRegionConversionTime::FnCall,
616 fn_sig,
617 );
618 let fn_sig = self.normalize(call_expr.span, Unnormalized::new_wip(fn_sig));
619
620 let fn_id = match def_id {
622 Some(x) => SplatLoweringInfo::FnDef(x),
623 None => SplatLoweringInfo::FnPtr(callee_ty),
624 };
625
626 self.check_argument_types_maybe_method_like(
627 &fn_sig,
628 call_expr,
629 arg_exprs,
630 expected,
631 TupleArgumentsFlag::with_fn_sig_kind(fn_sig.fn_sig_kind, false),
632 fn_id,
633 callee_generic_args,
634 );
635
636 if fn_sig.abi() == rustc_abi::ExternAbi::RustCall {
638 let sp = arg_exprs.last().map_or(call_expr.span, |expr| expr.span);
639 if let Some(ty) = fn_sig.inputs().last().copied()
640 && fn_sig.splatted().is_none()
641 {
642 self.register_bound(
643 ty,
644 self.tcx.require_lang_item(LangItem::Tuple, sp),
645 self.cause(sp, ObligationCauseCode::RustCall),
646 );
647 self.require_type_is_sized(ty, sp, ObligationCauseCode::RustCall);
648 } else {
649 self.dcx().emit_err(diagnostics::RustCallIncorrectArgs { span: sp });
650 }
651 }
652
653 fn_sig.output()
654 }
655
656 fn check_argument_types_maybe_method_like(
663 &self,
664 fn_sig: &FnSig<'tcx>,
665 call_expr: &'tcx hir::Expr<'tcx>,
666 arg_exprs: &'tcx [hir::Expr<'tcx>],
667 expected: Expectation<'tcx>,
668 tuple_arguments_flag: TupleArgumentsFlag,
669 fn_id: SplatLoweringInfo<'tcx>,
670 callee_generic_args: Option<GenericArgs<'tcx>>,
671 ) {
672 let mut formal_inputs = Cow::Borrowed(fn_sig.inputs());
673 if let (SplatLoweringInfo::FnDef(def_id), Some(args)) = (fn_id, callee_generic_args) {
674 for (param, pos) in self.tcx.generics_of(def_id).own_arg_pos_consts() {
675 let ty = self.tcx.type_of(param.def_id).instantiate(self.tcx, args).skip_norm_wip();
676 let ty = self.normalize(call_expr.span, Unnormalized::new_wip(ty));
677 formal_inputs.to_mut().insert(pos as usize, ty);
678 }
679 }
680
681 let do_check = || {
682 self.check_argument_types(
683 call_expr.span,
684 call_expr,
685 &formal_inputs,
686 fn_sig.output(),
687 expected,
688 arg_exprs,
689 fn_sig.c_variadic(),
690 tuple_arguments_flag,
691 fn_id,
692 callee_generic_args,
693 );
694 };
695
696 let Some((candidate_res, args_to_map)) =
697 self.get_info_for_method_call_adjustments(call_expr, arg_exprs)
698 else {
699 return do_check();
700 };
701
702 let mut resolved_inputs = ::alloc::vec::Vec::new()vec![];
705 let mut prev_types = FxHashMap::default();
706 let formal_input_tys = fn_sig.inputs();
707
708 let args_to_map = arg_exprs
709 .iter()
710 .enumerate()
711 .filter(|(idx, _)| args_to_map.contains(idx))
712 .collect::<Vec<_>>();
713
714 for &(idx, arg) in &args_to_map {
715 let is_first_arg = idx == 0;
716 let self_ty_override = if is_first_arg { None } else { Some(resolved_inputs[idx]) };
717 let scope = ProbeScope::Single(candidate_res, self_ty_override);
718 let arg_type = self.check_expr(arg);
719
720 let pick = self.probe_for_name(
723 Mode::MethodCall,
724 Ident::dummy(),
725 None,
726 IsSuggestion(false),
727 arg_type,
728 call_expr.hir_id,
729 scope,
730 );
731
732 let Ok(ref pick) = pick else { return do_check() };
733
734 let mut ctx = ConfirmContext::new(self, arg.span, arg, arg);
735 let (adjusted_arg_type, method_adjustments) =
736 ctx.create_ty_adjustments_from_pick(arg_type, pick);
737
738 if is_first_arg && args_to_map.len() > 1 {
739 let cause = self.cause(
744 call_expr.span,
745 ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)),
746 );
747 if self
750 .sup_raw(
751 &cause,
752 self.param_env,
753 DefineOpaqueTypes::Yes,
754 formal_input_tys[0],
755 adjusted_arg_type,
756 )
757 .is_err()
758 {
759 return do_check();
760 }
761
762 resolved_inputs = self.deeply_resolve_ignoring_regions(formal_input_tys.to_vec());
763 }
764
765 prev_types.insert(
768 arg.hir_id,
769 (
770 self.typeck_results
771 .borrow_mut()
772 .node_types_mut()
773 .insert(arg.hir_id, adjusted_arg_type)
774 .expect("must be set"),
775 method_adjustments,
776 ),
777 );
778 }
779
780 do_check();
781
782 for (_, arg) in args_to_map {
783 let mut results = self.typeck_results.borrow_mut();
784 let mut adjustments = results.adjustments_mut();
785
786 let (prev_type, method_adjustments) =
787 prev_types.remove(&arg.hir_id).expect("must be in a map");
788
789 let adjustments = adjustments.entry(arg.hir_id).or_default();
799 adjustments.splice(0..0, method_adjustments);
800
801 results.node_types_mut().insert(arg.hir_id, prev_type);
803 }
804 }
805
806 fn get_info_for_method_call_adjustments(
809 &self,
810 call_expr: &'tcx hir::Expr<'tcx>,
811 arg_exprs: &'tcx [hir::Expr<'tcx>],
812 ) -> Option<(DefId, &FxIndexSet<usize>)> {
813 let parent_def = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id;
818 let Some(info) = self.tcx.hir_opt_delegation_info(parent_def) else {
819 return None;
820 };
821
822 if call_expr.hir_id != info.call_expr_id {
823 return None;
824 };
825
826 if arg_exprs.is_empty()
829 || !self.tcx.opt_associated_item(info.call_path_res).is_some_and(|i| i.is_method())
830 {
831 return None;
832 }
833
834 Some((info.call_path_res, &info.arguments_to_map))
835 }
836
837 fn suggest_call_as_method(
840 &self,
841 diag: &mut Diag<'_>,
842 segment: &'tcx hir::PathSegment<'tcx>,
843 arg_exprs: &'tcx [hir::Expr<'tcx>],
844 call_expr: &'tcx hir::Expr<'tcx>,
845 expected: Expectation<'tcx>,
846 ) {
847 if let [callee_expr, rest @ ..] = arg_exprs {
848 let Some(callee_ty) = self.typeck_results.borrow().expr_ty_adjusted_opt(callee_expr)
849 else {
850 return;
851 };
852
853 let Ok(pick) = self.lookup_probe_for_diagnostic(
857 segment.ident,
858 callee_ty,
859 call_expr,
860 ProbeScope::AllTraits,
863 expected.only_has_type(self),
864 ) else {
865 return;
866 };
867
868 let pick = self.confirm_method_for_diagnostic(
869 call_expr.span,
870 callee_expr,
871 call_expr,
872 callee_ty,
873 &pick,
874 segment,
875 );
876 if pick.illegal_sized_bound.is_some() {
877 return;
878 }
879
880 let Some(callee_expr_span) = callee_expr.span.find_ancestor_inside(call_expr.span)
881 else {
882 return;
883 };
884 let up_to_rcvr_span = segment.ident.span.until(callee_expr_span);
885 let rest_span = callee_expr_span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
886 let rest_snippet = if let Some(first) = rest.first() {
887 self.tcx
888 .sess
889 .source_map()
890 .span_to_snippet(first.span.to(call_expr.span.shrink_to_hi()))
891 } else {
892 Ok(")".to_string())
893 };
894
895 if let Ok(rest_snippet) = rest_snippet {
896 let sugg = if self.precedence(callee_expr) >= ExprPrecedence::Unambiguous {
897 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[(up_to_rcvr_span, "".to_string()),
(rest_span,
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(".{0}({1}", segment.ident,
rest_snippet))
}))]))vec![
898 (up_to_rcvr_span, "".to_string()),
899 (rest_span, format!(".{}({rest_snippet}", segment.ident)),
900 ]
901 } else {
902 ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[(up_to_rcvr_span, "(".to_string()),
(rest_span,
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(").{0}({1}",
segment.ident, rest_snippet))
}))]))vec![
903 (up_to_rcvr_span, "(".to_string()),
904 (rest_span, format!(").{}({rest_snippet}", segment.ident)),
905 ]
906 };
907 let self_ty = self.deeply_resolve_ignoring_regions(pick.callee.sig.inputs()[0]);
908 diag.multipart_suggestion(
909 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("use the `.` operator to call the method `{0}{1}` on `{2}`",
self.tcx.associated_item(pick.callee.def_id).trait_container(self.tcx).map_or_else(||
String::new(),
|trait_def_id| self.tcx.def_path_str(trait_def_id) + "::"),
segment.ident, self_ty))
})format!(
910 "use the `.` operator to call the method `{}{}` on `{self_ty}`",
911 self.tcx
912 .associated_item(pick.callee.def_id)
913 .trait_container(self.tcx)
914 .map_or_else(
915 || String::new(),
916 |trait_def_id| self.tcx.def_path_str(trait_def_id) + "::"
917 ),
918 segment.ident
919 ),
920 sugg,
921 Applicability::MaybeIncorrect,
922 );
923 }
924 }
925 }
926
927 fn report_invalid_callee(
928 &self,
929 call_expr: &'tcx hir::Expr<'tcx>,
930 callee_expr: &'tcx hir::Expr<'tcx>,
931 callee_ty: Ty<'tcx>,
932 arg_exprs: &'tcx [hir::Expr<'tcx>],
933 ) -> ErrorGuaranteed {
934 if let Some((_, _, args)) = self.extract_callable_info(callee_ty)
937 && let Err(err) = args.error_reported()
938 {
939 return err;
940 }
941
942 let mut unit_variant = None;
943 if let hir::ExprKind::Path(qpath) = &callee_expr.kind
944 && let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)
945 = self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id)
946 && arg_exprs.is_empty()
948 && call_expr.span.contains(callee_expr.span)
949 {
950 let descr = match kind {
951 def::CtorOf::Struct => "struct",
952 def::CtorOf::Variant => "enum variant",
953 };
954 let removal_span = callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
955 unit_variant =
956 Some((removal_span, descr, rustc_hir_pretty::qpath_to_string(self, qpath)));
957 }
958
959 let callee_ty = self.deeply_resolve_ignoring_regions(callee_ty);
960 let mut path = None;
961 let mut err = self.dcx().create_err(diagnostics::InvalidCallee {
962 span: callee_expr.span,
963 found: match &unit_variant {
964 Some((_, kind, path)) => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} `{1}`", kind, path))
})format!("{kind} `{path}`"),
965 None => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`",
self.tcx.short_string(callee_ty, &mut path)))
})format!("`{}`", self.tcx.short_string(callee_ty, &mut path)),
966 },
967 });
968 *err.long_ty_path() = path;
969 if callee_ty.references_error() {
970 err.downgrade_to_delayed_bug();
971 }
972
973 self.identify_bad_closure_def_and_call(
974 &mut err,
975 call_expr.hir_id,
976 &callee_expr.kind,
977 callee_expr.span,
978 );
979
980 if let Some((removal_span, kind, path)) = &unit_variant {
981 err.span_suggestion_verbose(
982 *removal_span,
983 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}` is a unit {1}, and does not take parentheses to be constructed",
path, kind))
})format!(
984 "`{path}` is a unit {kind}, and does not take parentheses to be constructed",
985 ),
986 "",
987 Applicability::MachineApplicable,
988 );
989 }
990
991 if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = callee_expr.kind
992 && let Res::Local(_) = path.res
993 && let [segment] = &path.segments
994 {
995 for id in self.tcx.hir_free_items() {
996 if let Some(node) = self.tcx.hir_get_if_local(id.owner_id.into())
997 && let hir::Node::Item(item) = node
998 && let hir::ItemKind::Fn { ident, .. } = item.kind
999 && ident.name == segment.ident.name
1000 {
1001 err.span_label(
1002 self.tcx.def_span(id.owner_id),
1003 "this function of the same name is available here, but it's shadowed by \
1004 the local binding",
1005 );
1006 }
1007 }
1008 }
1009
1010 let mut inner_callee_path = None;
1011 let def = match callee_expr.kind {
1012 hir::ExprKind::Path(ref qpath) => {
1013 self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id)
1014 }
1015 hir::ExprKind::Call(inner_callee, _) => {
1016 if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.kind {
1017 inner_callee_path = Some(inner_qpath);
1018 self.typeck_results.borrow().qpath_res(inner_qpath, inner_callee.hir_id)
1019 } else {
1020 Res::Err
1021 }
1022 }
1023 _ => Res::Err,
1024 };
1025
1026 if !self.maybe_suggest_bad_array_definition(&mut err, call_expr, callee_expr) {
1027 let call_is_multiline = self
1031 .tcx
1032 .sess
1033 .source_map()
1034 .is_multiline(call_expr.span.with_lo(callee_expr.span.hi()))
1035 && call_expr.span.ctxt() == callee_expr.span.ctxt();
1036 if call_is_multiline {
1037 err.span_suggestion(
1038 callee_expr.span.shrink_to_hi(),
1039 "consider using a semicolon here to finish the statement",
1040 ";",
1041 Applicability::MaybeIncorrect,
1042 );
1043 }
1044 if let Some((maybe_def, output_ty, _)) = self.extract_callable_info(callee_ty)
1045 && !self.type_is_sized_modulo_regions(self.param_env, output_ty)
1046 {
1047 let descr = match maybe_def {
1048 DefIdOrName::DefId(def_id) => self.tcx.def_descr(def_id),
1049 DefIdOrName::Name(name) => name,
1050 };
1051 err.span_label(
1052 callee_expr.span,
1053 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("this {0} returns an unsized value `{1}`, so it cannot be called",
descr, output_ty))
})format!("this {descr} returns an unsized value `{output_ty}`, so it cannot be called")
1054 );
1055 if let DefIdOrName::DefId(def_id) = maybe_def
1056 && let Some(def_span) = self.tcx.hir_span_if_local(def_id)
1057 {
1058 err.span_label(def_span, "the callable type is defined here");
1059 }
1060 } else {
1061 err.span_label(call_expr.span, "call expression requires function");
1062 }
1063 }
1064
1065 if let Some(span) = self.tcx.hir_res_span(def) {
1066 let label = match (unit_variant, inner_callee_path) {
1067 (Some((_, kind, path)), _) => {
1068 err.arg("kind", kind);
1069 err.arg("path", path);
1070 Some(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind} `{$path}` defined here"))msg!("{$kind} `{$path}` defined here"))
1071 }
1072 (_, Some(hir::QPath::Resolved(_, path))) => {
1073 self.tcx.sess.source_map().span_to_snippet(path.span).ok().map(|p| {
1074 err.arg("func", p);
1075 err.arg("ty", callee_ty);
1076 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$func}` defined here returns `{$ty}`"))msg!("`{$func}` defined here returns `{$ty}`")
1077 })
1078 }
1079 _ => {
1080 match def {
1081 Res::Local(hir_id) => {
1084 err.arg("local_name", self.tcx.hir_name(hir_id));
1085 err.arg("ty", callee_ty);
1086 Some(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$local_name}` has type `{$ty}`"))msg!("`{$local_name}` has type `{$ty}`"))
1087 }
1088 Res::Def(kind, def_id) if kind.ns() == Some(Namespace::ValueNS) => {
1089 err.arg("path", self.tcx.def_path_str(def_id));
1090 Some(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$path}` defined here"))msg!("`{$path}` defined here"))
1091 }
1092 _ => {
1093 err.arg("path", callee_ty.to_string());
1094 Some(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$path}` defined here"))msg!("`{$path}` defined here"))
1095 }
1096 }
1097 }
1098 };
1099 if let Some(label) = label {
1100 err.span_label(span, label);
1101 }
1102 }
1103 err.emit_err()
1104 }
1105
1106 fn confirm_deferred_closure_call(
1107 &self,
1108 call_expr: &'tcx hir::Expr<'tcx>,
1109 arg_exprs: &'tcx [hir::Expr<'tcx>],
1110 expected: Expectation<'tcx>,
1111 closure_def_id: LocalDefId,
1112 fn_sig: ty::FnSig<'tcx>,
1113 ) -> Ty<'tcx> {
1114 self.check_argument_types(
1119 call_expr.span,
1120 call_expr,
1121 fn_sig.inputs(),
1122 fn_sig.output(),
1123 expected,
1124 arg_exprs,
1125 fn_sig.fn_sig_kind.c_variadic(),
1126 TupleArgumentsFlag::rust_fn_trait_call(),
1127 SplatLoweringInfo::FnDef(closure_def_id.to_def_id()),
1128 None,
1129 );
1130
1131 fn_sig.output()
1132 }
1133
1134 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("enforce_context_effects",
"rustc_hir_typeck::callee", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs"),
::tracing_core::__macro_support::Option::Some(1134u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::callee"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("call_hir_id")
}> =
::tracing::__macro_support::FieldName::new("call_hir_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("callee_did")
}> =
::tracing::__macro_support::FieldName::new("callee_did");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("callee_args")
}> =
::tracing::__macro_support::FieldName::new("callee_args");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&call_hir_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&callee_did)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&callee_args)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
let const_context =
self.tcx.hir_body_const_context(self.body_def_id);
if let hir::Constness::Const { always: true } =
self.tcx.constness(callee_did) {
match const_context {
Some(hir::ConstContext::Const { .. } |
hir::ConstContext::Static(_)) => {}
Some(hir::ConstContext::ConstFn) | None => {
self.dcx().emit_err(diagnostics::ComptimeFnCalledOutsideConstContext {
span,
const_block: diagnostics::WrapConstBlock {
left: span.shrink_to_lo(),
right: span.shrink_to_hi(),
},
});
}
}
}
if !self.tcx.features().const_trait_impl() { return; }
if self.has_rustc_attrs &&
{
{
'done:
{
for i in
::rustc_attr_ir::HasAttrs::get_attrs(self.body_def_id,
&self.tcx) {
#[allow(unused_imports)]
use ::rustc_attr_ir::AttributeKind::*;
let i: &::rustc_attr_ir::Attribute = i;
match i {
::rustc_attr_ir::Attribute::Parsed(RustcDoNotConstCheck) =>
{
break 'done Some(());
}
::rustc_attr_ir::Attribute::Tool { .. } |
::rustc_attr_ir::Attribute::DeriveHelper(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}.is_some() {
return;
}
let host =
match const_context {
Some(hir::ConstContext::Const { .. } |
hir::ConstContext::Static(_)) => {
ty::BoundConstness::Const
}
Some(hir::ConstContext::ConstFn) =>
ty::BoundConstness::Maybe,
None => return,
};
if self.tcx.is_conditionally_const(callee_did) {
let q = self.tcx.const_conditions(callee_did);
for (idx, (cond, pred_span)) in
q.instantiate(self.tcx, callee_args).into_iter().enumerate()
{
let cause =
self.cause(span,
if let Some(hir_id) = call_hir_id {
ObligationCauseCode::HostEffectInExpr(callee_did, pred_span,
hir_id, idx)
} else {
ObligationCauseCode::WhereClause(callee_did, pred_span)
});
self.register_predicate(Obligation::new(self.tcx, cause,
self.param_env,
cond.to_host_effect_clause(self.tcx,
host).skip_norm_wip()));
}
} else {}
}
}
}#[tracing::instrument(level = "debug", skip(self, span))]
1135 pub(super) fn enforce_context_effects(
1136 &self,
1137 call_hir_id: Option<HirId>,
1138 span: Span,
1139 callee_did: DefId,
1140 callee_args: GenericArgs<'tcx>,
1141 ) {
1142 let const_context = self.tcx.hir_body_const_context(self.body_def_id);
1143
1144 if let hir::Constness::Const { always: true } = self.tcx.constness(callee_did) {
1145 match const_context {
1146 Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => {}
1147 Some(hir::ConstContext::ConstFn) | None => {
1148 self.dcx().emit_err(diagnostics::ComptimeFnCalledOutsideConstContext {
1149 span,
1150 const_block: diagnostics::WrapConstBlock {
1151 left: span.shrink_to_lo(),
1152 right: span.shrink_to_hi(),
1153 },
1154 });
1155 }
1156 }
1157 }
1158
1159 if !self.tcx.features().const_trait_impl() {
1164 return;
1165 }
1166
1167 if self.has_rustc_attrs && find_attr!(self.tcx, self.body_def_id, RustcDoNotConstCheck) {
1169 return;
1170 }
1171
1172 let host = match const_context {
1173 Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => {
1174 ty::BoundConstness::Const
1175 }
1176 Some(hir::ConstContext::ConstFn) => ty::BoundConstness::Maybe,
1177 None => return,
1178 };
1179
1180 if self.tcx.is_conditionally_const(callee_did) {
1183 let q = self.tcx.const_conditions(callee_did);
1184 for (idx, (cond, pred_span)) in
1185 q.instantiate(self.tcx, callee_args).into_iter().enumerate()
1186 {
1187 let cause = self.cause(
1188 span,
1189 if let Some(hir_id) = call_hir_id {
1190 ObligationCauseCode::HostEffectInExpr(callee_did, pred_span, hir_id, idx)
1191 } else {
1192 ObligationCauseCode::WhereClause(callee_did, pred_span)
1193 },
1194 );
1195 self.register_predicate(Obligation::new(
1196 self.tcx,
1197 cause,
1198 self.param_env,
1199 cond.to_host_effect_clause(self.tcx, host).skip_norm_wip(),
1200 ));
1201 }
1202 } else {
1203 }
1206 }
1207
1208 fn confirm_overloaded_call(
1209 &self,
1210 call_expr: &'tcx hir::Expr<'tcx>,
1211 arg_exprs: &'tcx [hir::Expr<'tcx>],
1212 expected: Expectation<'tcx>,
1213 method: MethodCallee<'tcx>,
1214 ) -> Ty<'tcx> {
1215 {
match (&method.sig.fn_sig_kind.splatted(), &None) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val,
::core::option::Option::Some(format_args!("splatting is not supported on RustCall tuples")));
}
}
}
};assert_eq!(
1218 method.sig.fn_sig_kind.splatted(),
1219 None,
1220 "splatting is not supported on RustCall tuples",
1221 );
1222 self.check_argument_types(
1223 call_expr.span,
1224 call_expr,
1225 &method.sig.inputs()[1..],
1226 method.sig.output(),
1227 expected,
1228 arg_exprs,
1229 method.sig.fn_sig_kind.c_variadic(),
1230 TupleArgumentsFlag::rust_fn_trait_call(),
1231 SplatLoweringInfo::FnDef(method.def_id),
1232 None,
1233 );
1234
1235 self.write_method_call_and_enforce_effects(call_expr.hir_id, call_expr.span, method);
1236
1237 method.sig.output()
1238 }
1239}
1240
1241#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for
DeferredCallResolution<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f,
"DeferredCallResolution call_expr callee_expr closure_ty adjustments fn_sig",
&self.call_expr, &self.callee_expr, &self.closure_ty,
&self.adjustments, &&self.fn_sig)
}
}Debug)]
1242pub(crate) struct DeferredCallResolution<'tcx> {
1243 call_expr: &'tcx hir::Expr<'tcx>,
1244 callee_expr: &'tcx hir::Expr<'tcx>,
1245 closure_ty: Ty<'tcx>,
1246 adjustments: Vec<Adjustment<'tcx>>,
1247 fn_sig: ty::FnSig<'tcx>,
1248}
1249
1250impl<'a, 'tcx> DeferredCallResolution<'tcx> {
1251 pub(crate) fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) {
1252 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs:1252",
"rustc_hir_typeck::callee", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs"),
::tracing_core::__macro_support::Option::Some(1252u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::callee"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("DeferredCallResolution::resolve() {0:?}",
self) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("DeferredCallResolution::resolve() {:?}", self);
1253
1254 if !fcx.closure_kind(self.closure_ty).is_some() {
::core::panicking::panic("assertion failed: fcx.closure_kind(self.closure_ty).is_some()")
};assert!(fcx.closure_kind(self.closure_ty).is_some());
1257
1258 match fcx.try_overloaded_call_traits(self.call_expr, self.closure_ty, None) {
1260 Some((autoref, method_callee)) => {
1261 let method_sig = method_callee.sig;
1270
1271 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs:1271",
"rustc_hir_typeck::callee", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_hir_typeck/src/callee.rs"),
::tracing_core::__macro_support::Option::Some(1271u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::callee"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("attempt_resolution: method_callee={0:?}",
method_callee) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("attempt_resolution: method_callee={:?}", method_callee);
1272
1273 for (method_arg_ty, self_arg_ty) in
1274 iter::zip(method_sig.inputs().iter().skip(1), self.fn_sig.inputs())
1275 {
1276 fcx.demand_eqtype(self.call_expr.span, *self_arg_ty, *method_arg_ty);
1277 }
1278
1279 fcx.demand_eqtype(self.call_expr.span, method_sig.output(), self.fn_sig.output());
1280
1281 let mut adjustments = self.adjustments;
1282 adjustments.extend(autoref);
1283 fcx.apply_adjustments(self.callee_expr, adjustments);
1284
1285 fcx.write_method_call_and_enforce_effects(
1286 self.call_expr.hir_id,
1287 self.call_expr.span,
1288 method_callee,
1289 );
1290 }
1291 None => {
1292 let guar = fcx.tainted_by_errors().unwrap_or_else(|| {
1293 fcx.dcx().span_delayed_bug(
1294 self.call_expr.span,
1295 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Expected to find a suitable `Fn`/`FnMut`/`FnOnce` implementation for `{0}`",
self.closure_ty))
})format!(
1296 "Expected to find a suitable `Fn`/`FnMut`/`FnOnce` implementation for `{}`",
1297 self.closure_ty
1298 ),
1299 )
1300 });
1301 fcx.write_resolution(self.call_expr.hir_id, Err(guar));
1302 }
1303 }
1304 }
1305}