1use std::mem;
12use std::ops::ControlFlow;
13
14use rustc_attr_ir::find_attr;
15use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
16use rustc_data_structures::unord::ExtendUnord;
17use rustc_errors::{E0720, ErrorGuaranteed};
18use rustc_hir::def_id::LocalDefId;
19use rustc_hir::intravisit::{self, InferKind, Visitor};
20use rustc_hir::{self as hir, AmbigArg, HirId};
21use rustc_infer::traits::solve::Goal;
22use rustc_middle::traits::ObligationCause;
23use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
24use rustc_middle::ty::{
25 self, DefiningScopeKind, DefinitionSiteHiddenType, Flags, PredicateProxy, Ty, TyCtxt,
26 TypeFoldable, TypeFolder, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable,
27 TypeVisitableExt, TypeVisitor, Unnormalized, fold_regions,
28};
29use rustc_span::Span;
30use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
31use rustc_trait_selection::opaque_types::opaque_type_has_defining_use_args;
32use rustc_trait_selection::solve;
33use tracing::{debug, instrument};
34
35use crate::FnCtxt;
36
37impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41 pub(crate) fn resolve_type_vars_in_body(
42 &self,
43 body: &'tcx hir::Body<'tcx>,
44 ) -> &'tcx ty::TypeckResults<'tcx> {
45 let item_def_id = self.tcx.hir_body_owner_def_id(body.id());
46
47 let rustc_dump_user_args =
50 self.has_rustc_attrs && {
{
'done:
{
for i in
::rustc_attr_ir::HasAttrs::get_attrs(item_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(RustcDumpUserArgs) => {
break 'done Some(());
}
::rustc_attr_ir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}.is_some()find_attr!(self.tcx, item_def_id, RustcDumpUserArgs);
51
52 let mut wbcx = WritebackCx::new(self, body, rustc_dump_user_args);
53 for param in body.params {
54 wbcx.visit_node_id(param.pat.span, param.hir_id);
55 }
56 match self.tcx.hir_body_owner_kind(item_def_id) {
57 hir::BodyOwnerKind::Const { .. }
59 | hir::BodyOwnerKind::Static(_)
60 | hir::BodyOwnerKind::GlobalAsm => {
61 let item_hir_id = self.tcx.local_def_id_to_hir_id(item_def_id);
62 wbcx.visit_node_id(body.value.span, item_hir_id);
63 }
64 hir::BodyOwnerKind::Closure | hir::BodyOwnerKind::Fn => {}
66 }
67 wbcx.visit_body(body);
68 wbcx.visit_min_capture_map();
69 wbcx.eval_closure_size();
70 wbcx.visit_fake_reads_map();
71 wbcx.visit_closures();
72 wbcx.visit_liberated_fn_sigs();
73 wbcx.visit_fru_field_types();
74 wbcx.visit_opaque_types();
75 wbcx.visit_coercion_casts();
76 wbcx.visit_user_provided_tys();
77 wbcx.visit_user_provided_sigs();
78 wbcx.visit_coroutine_interior();
79 wbcx.visit_transmutes();
80 wbcx.visit_offloads();
81 wbcx.visit_offset_of_container_types();
82 wbcx.visit_potentially_region_dependent_goals();
83
84 let used_trait_imports =
85 mem::take(&mut self.typeck_results.borrow_mut().used_trait_imports);
86 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:86",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(86u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("used_trait_imports({0:?}) = {1:?}",
item_def_id, used_trait_imports) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("used_trait_imports({:?}) = {:?}", item_def_id, used_trait_imports);
87 wbcx.typeck_results.used_trait_imports = used_trait_imports;
88
89 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:89",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(89u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("writeback: typeck results for {0:?} are {1:#?}",
item_def_id, wbcx.typeck_results) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("writeback: typeck results for {:?} are {:#?}", item_def_id, wbcx.typeck_results);
90
91 self.tcx.arena.alloc(wbcx.typeck_results)
92 }
93}
94
95struct WritebackCx<'cx, 'tcx> {
101 fcx: &'cx FnCtxt<'cx, 'tcx>,
102
103 typeck_results: ty::TypeckResults<'tcx>,
104
105 body: &'tcx hir::Body<'tcx>,
106
107 rustc_dump_user_args: bool,
108}
109
110impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
111 fn new(
112 fcx: &'cx FnCtxt<'cx, 'tcx>,
113 body: &'tcx hir::Body<'tcx>,
114 rustc_dump_user_args: bool,
115 ) -> WritebackCx<'cx, 'tcx> {
116 let owner = body.id().hir_id.owner;
117
118 let mut wbcx = WritebackCx {
119 fcx,
120 typeck_results: ty::TypeckResults::new(owner),
121 body,
122 rustc_dump_user_args,
123 };
124
125 if let Some(e) = fcx.tainted_by_errors() {
129 wbcx.typeck_results.tainted_by_errors = Some(e);
130 }
131
132 wbcx
133 }
134
135 fn tcx(&self) -> TyCtxt<'tcx> {
136 self.fcx.tcx
137 }
138
139 fn write_ty_to_typeck_results(&mut self, hir_id: HirId, ty: Ty<'tcx>) {
140 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:140",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(140u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("write_ty_to_typeck_results({0:?}, {1:?})",
hir_id, ty) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
141 if !(!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions()) {
{
::core::panicking::panic_fmt(format_args!("{0} can\'t be put into typeck results",
ty));
}
};assert!(
142 !ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions(),
143 "{ty} can't be put into typeck results"
144 );
145 self.typeck_results.node_types_mut().insert(hir_id, ty);
146 }
147
148 fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr<'_>) {
153 match e.kind {
154 hir::ExprKind::Unary(hir::UnOp::Neg | hir::UnOp::Not, inner) => {
155 let inner_ty = self.typeck_results.node_type(inner.hir_id);
156
157 if inner_ty.is_scalar() {
158 self.typeck_results.type_dependent_defs_mut().remove(e.hir_id);
159 self.typeck_results.node_args_mut().remove(e.hir_id);
160 }
161 }
162 hir::ExprKind::Binary(ref op, lhs, rhs) => {
163 let lhs_ty = self.typeck_results.node_type(lhs.hir_id);
164 let rhs_ty = self.typeck_results.node_type(rhs.hir_id);
165
166 if lhs_ty.is_scalar() && rhs_ty.is_scalar() {
167 self.typeck_results.type_dependent_defs_mut().remove(e.hir_id);
168 self.typeck_results.node_args_mut().remove(e.hir_id);
169
170 if !op.node.is_by_value() {
171 let mut adjustments = self.typeck_results.adjustments_mut();
172 if let Some(a) = adjustments.get_mut(lhs.hir_id) {
173 a.pop();
174 }
175 if let Some(a) = adjustments.get_mut(rhs.hir_id) {
176 a.pop();
177 }
178 }
179 }
180 }
181 hir::ExprKind::AssignOp(_, lhs, rhs) => {
182 let lhs_ty = self.typeck_results.node_type(lhs.hir_id);
183 let rhs_ty = self.typeck_results.node_type(rhs.hir_id);
184
185 if lhs_ty.is_scalar() && rhs_ty.is_scalar() {
186 self.typeck_results.type_dependent_defs_mut().remove(e.hir_id);
187 self.typeck_results.node_args_mut().remove(e.hir_id);
188
189 if let Some(a) = self.typeck_results.adjustments_mut().get_mut(lhs.hir_id) {
190 a.pop();
191 }
192 }
193 }
194 _ => {}
195 }
196 }
197
198 fn is_builtin_index(
203 &mut self,
204 e: &hir::Expr<'_>,
205 base_ty: Ty<'tcx>,
206 index_ty: Ty<'tcx>,
207 ) -> bool {
208 if let Some(elem_ty) = base_ty.builtin_index()
209 && let Some(exp_ty) = self.typeck_results.expr_ty_opt(e)
210 {
211 elem_ty == exp_ty && index_ty == self.fcx.tcx.types.usize
212 } else {
213 false
214 }
215 }
216
217 fn fix_index_builtin_expr(&mut self, e: &hir::Expr<'_>) {
222 if let hir::ExprKind::Index(base, index, _) = e.kind {
223 let base_ty = self.typeck_results.expr_ty_adjusted(base);
225 if let ty::Ref(_, base_ty_inner, _) = *base_ty.kind() {
226 let index_ty = self.typeck_results.expr_ty_adjusted(index);
227 if self.is_builtin_index(e, base_ty_inner, index_ty) {
228 self.typeck_results.type_dependent_defs_mut().remove(e.hir_id);
230 self.typeck_results.node_args_mut().remove(e.hir_id);
231
232 if let Some(a) = self.typeck_results.adjustments_mut().get_mut(base.hir_id)
233 && let Some(Adjustment {
239 kind: Adjust::Pointer(PointerCoercion::Unsize),
240 ..
241 }) = a.pop()
242 {
243 a.pop();
245 }
246 }
247 }
248 }
249 }
250}
251
252impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
261 fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) {
262 match e.kind {
263 hir::ExprKind::Closure(&hir::Closure { body, .. }) => {
264 let body = self.fcx.tcx.hir_body(body);
265 for param in body.params {
266 self.visit_node_id(e.span, param.hir_id);
267 }
268
269 self.visit_body(body);
270 }
271 hir::ExprKind::Struct(_, fields, _) => {
272 for field in fields {
273 self.visit_field_id(field.hir_id);
274 }
275 }
276 hir::ExprKind::Field(..) | hir::ExprKind::OffsetOf(..) => {
277 self.visit_field_id(e.hir_id);
278 }
279 _ => {}
280 }
281
282 self.visit_node_id(e.span, e.hir_id);
283 intravisit::walk_expr(self, e);
284
285 self.fix_scalar_builtin_expr(e);
286 self.fix_index_builtin_expr(e);
287 }
288
289 fn visit_inline_const(&mut self, anon_const: &hir::ConstBlock) {
290 let span = self.tcx().def_span(anon_const.def_id);
291 self.visit_node_id(span, anon_const.hir_id);
292
293 let body = self.tcx().hir_body(anon_const.body);
294 self.visit_body(body);
295 }
296
297 fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
298 match &p.kind {
299 hir::GenericParamKind::Lifetime { .. } => {
300 }
302 hir::GenericParamKind::Type { .. } | hir::GenericParamKind::Const { .. } => {
303 self.tcx()
304 .dcx()
305 .span_delayed_bug(p.span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unexpected generic param: {0:?}",
p))
})format!("unexpected generic param: {p:?}"));
306 }
307 }
308 }
309
310 fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) {
311 self.visit_node_id(b.span, b.hir_id);
312 intravisit::walk_block(self, b);
313 }
314
315 fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
316 match p.kind {
317 hir::PatKind::Binding(..) => {
318 let typeck_results = self.fcx.typeck_results.borrow();
319 let bm = typeck_results.extract_binding_mode(self.tcx().sess, p.hir_id, p.span);
320 self.typeck_results.pat_binding_modes_mut().insert(p.hir_id, bm);
321 }
322 hir::PatKind::Struct(_, fields, _) => {
323 for field in fields {
324 self.visit_field_id(field.hir_id);
325 }
326 }
327 _ => {}
328 };
329
330 self.visit_rust_2024_migration_desugared_pats(p.hir_id);
331 self.visit_skipped_ref_pats(p.hir_id);
332 self.visit_pat_adjustments(p.span, p.hir_id);
333
334 self.visit_node_id(p.span, p.hir_id);
335 intravisit::walk_pat(self, p);
336 }
337
338 fn visit_pat_expr(&mut self, expr: &'tcx hir::PatExpr<'tcx>) {
339 self.visit_node_id(expr.span, expr.hir_id);
340 intravisit::walk_pat_expr(self, expr);
341 }
342
343 fn visit_local(&mut self, l: &'tcx hir::LetStmt<'tcx>) {
344 intravisit::walk_local(self, l);
345 let var_ty = self.fcx.local_ty(l.span, l.hir_id);
346 let var_ty = self.resolve(var_ty, &l.span);
347 self.write_ty_to_typeck_results(l.hir_id, var_ty);
348 }
349
350 fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx, AmbigArg>) {
351 intravisit::walk_ty(self, hir_ty);
352 if let Some(ty) = self.fcx.node_ty_opt(hir_ty.hir_id) {
355 let ty = self.resolve(ty, &hir_ty.span);
356 self.write_ty_to_typeck_results(hir_ty.hir_id, ty);
357 }
358 }
359
360 fn visit_infer(
361 &mut self,
362 inf_id: HirId,
363 inf_span: Span,
364 _kind: InferKind<'cx>,
365 ) -> Self::Result {
366 self.visit_id(inf_id);
367
368 if let Some(ty) = self.fcx.node_ty_opt(inf_id) {
372 let ty = self.resolve(ty, &inf_span);
373 self.write_ty_to_typeck_results(inf_id, ty);
374 }
375 }
376}
377
378impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
379 fn eval_closure_size(&mut self) {
380 self.tcx().with_stable_hashing_context(|mut hcx| {
381 let fcx_typeck_results = self.fcx.typeck_results.borrow();
382
383 self.typeck_results.closure_size_eval = fcx_typeck_results
384 .closure_size_eval
385 .to_sorted(&mut hcx, false)
386 .into_iter()
387 .map(|(&closure_def_id, data)| {
388 let closure_hir_id = self.tcx().local_def_id_to_hir_id(closure_def_id);
389 let data = self.resolve(*data, &closure_hir_id);
390 (closure_def_id, data)
391 })
392 .collect();
393 })
394 }
395
396 fn visit_min_capture_map(&mut self) {
397 self.tcx().with_stable_hashing_context(|mut hcx| {
398 let fcx_typeck_results = self.fcx.typeck_results.borrow();
399
400 self.typeck_results.closure_min_captures = fcx_typeck_results
401 .closure_min_captures
402 .to_sorted(&mut hcx, false)
403 .into_iter()
404 .map(|(&closure_def_id, root_min_captures)| {
405 let root_var_map_wb = root_min_captures
406 .iter()
407 .map(|(var_hir_id, min_list)| {
408 let min_list_wb = min_list
409 .iter()
410 .map(|captured_place| {
411 let locatable =
412 captured_place.info.path_expr_id.unwrap_or_else(|| {
413 self.tcx().local_def_id_to_hir_id(closure_def_id)
414 });
415 self.resolve(captured_place.clone(), &locatable)
416 })
417 .collect();
418 (*var_hir_id, min_list_wb)
419 })
420 .collect();
421 (closure_def_id, root_var_map_wb)
422 })
423 .collect();
424 })
425 }
426
427 fn visit_fake_reads_map(&mut self) {
428 self.tcx().with_stable_hashing_context(move |mut hcx| {
429 let fcx_typeck_results = self.fcx.typeck_results.borrow();
430
431 self.typeck_results.closure_fake_reads = fcx_typeck_results
432 .closure_fake_reads
433 .to_sorted(&mut hcx, true)
434 .into_iter()
435 .map(|(&closure_def_id, fake_reads)| {
436 let resolved_fake_reads = fake_reads
437 .iter()
438 .map(|(place, cause, hir_id)| {
439 let locatable = self.tcx().local_def_id_to_hir_id(closure_def_id);
440 let resolved_fake_read = self.resolve(place.clone(), &locatable);
441 (resolved_fake_read, *cause, *hir_id)
442 })
443 .collect();
444
445 (closure_def_id, resolved_fake_reads)
446 })
447 .collect();
448 });
449 }
450
451 fn visit_closures(&mut self) {
452 let fcx_typeck_results = self.fcx.typeck_results.borrow();
453 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
454 let common_hir_owner = fcx_typeck_results.hir_owner;
455
456 let fcx_closure_kind_origins =
457 fcx_typeck_results.closure_kind_origins().items_in_stable_order();
458
459 for (local_id, origin) in fcx_closure_kind_origins {
460 let hir_id = HirId { owner: common_hir_owner, local_id };
461 let place_span = origin.0;
462 let place = self.resolve(origin.1.clone(), &place_span);
463 self.typeck_results.closure_kind_origins_mut().insert(hir_id, (place_span, place));
464 }
465 }
466
467 fn visit_coercion_casts(&mut self) {
468 let fcx_typeck_results = self.fcx.typeck_results.borrow();
469
470 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
471
472 let fcx_coercion_casts = fcx_typeck_results.coercion_casts().to_sorted_stable_ord();
473 for &local_id in fcx_coercion_casts {
474 self.typeck_results.set_coercion_cast(local_id);
475 }
476 }
477
478 fn visit_user_provided_tys(&mut self) {
479 let fcx_typeck_results = self.fcx.typeck_results.borrow();
480 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
481 let common_hir_owner = fcx_typeck_results.hir_owner;
482
483 if self.rustc_dump_user_args {
484 let sorted_user_provided_types =
485 fcx_typeck_results.user_provided_types().items_in_stable_order();
486
487 let mut errors_buffer = Vec::new();
488 for (local_id, c_ty) in sorted_user_provided_types {
489 let hir_id = HirId { owner: common_hir_owner, local_id };
490
491 if let ty::UserTypeKind::TypeOf(_, user_args) = c_ty.value.kind {
492 let span = self.tcx().hir_span(hir_id);
494 let err =
497 self.tcx().dcx().struct_span_err(span, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("user args: {0:?}", user_args))
})format!("user args: {user_args:?}"));
498 errors_buffer.push(err);
499 }
500 }
501
502 if !errors_buffer.is_empty() {
503 errors_buffer.sort_by_key(|diag| diag.span.primary_span().map(Span::lo_hi));
504 for err in errors_buffer {
505 err.emit();
506 }
507 }
508 }
509
510 self.typeck_results.user_provided_types_mut().extend(
511 fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
512 let hir_id = HirId { owner: common_hir_owner, local_id };
513 (hir_id, *c_ty)
514 }),
515 );
516 }
517
518 fn visit_user_provided_sigs(&mut self) {
519 let fcx_typeck_results = self.fcx.typeck_results.borrow();
520 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
521
522 self.typeck_results.user_provided_sigs.extend_unord(
523 fcx_typeck_results.user_provided_sigs.items().map(|(def_id, c_sig)| (*def_id, *c_sig)),
524 );
525 }
526
527 fn visit_coroutine_interior(&mut self) {
528 let fcx_typeck_results = self.fcx.typeck_results.borrow();
529 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
530 for (predicate, cause) in &fcx_typeck_results.coroutine_stalled_predicates {
531 let (predicate, cause) =
532 self.resolve_coroutine_predicate((*predicate, cause.clone()), &cause.span);
533 self.typeck_results.coroutine_stalled_predicates.insert((predicate, cause));
534 }
535 }
536
537 fn visit_transmutes(&mut self) {
538 let tcx = self.tcx();
539 let fcx_typeck_results = self.fcx.typeck_results.borrow();
540 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
541 for &(from, to, hir_id) in self.fcx.deferred_transmute_checks.borrow().iter() {
542 let span = tcx.hir_span(hir_id);
543 let from = self.resolve(from, &span);
544 let to = self.resolve(to, &span);
545 self.typeck_results.transmutes_to_check.push((from, to, hir_id));
546 }
547 }
548
549 fn visit_offloads(&mut self) {
550 let tcx = self.tcx();
551 let fcx_typeck_results = self.fcx.typeck_results.borrow();
552 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
553 for &(kernel_ty, args_ty, ret_ty, hir_id) in
554 self.fcx.deferred_offload_checks.borrow().iter()
555 {
556 let span = tcx.hir_span(hir_id);
557 let kernel_ty = self.resolve(kernel_ty, &span);
558 let args_ty = self.resolve(args_ty, &span);
559 let ret_ty = self.resolve(ret_ty, &span);
560 self.typeck_results.offloads_to_check.push((kernel_ty, args_ty, ret_ty, hir_id));
561 }
562 }
563
564 fn visit_opaque_types_next(&mut self) {
565 let mut fcx_typeck_results = self.fcx.typeck_results.borrow_mut();
566 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
567 {
match (&self.typeck_results.hidden_types.len(), &0) {
(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::None);
}
}
}
};assert_eq!(self.typeck_results.hidden_types.len(), 0);
568 self.typeck_results.hidden_types = mem::take(&mut fcx_typeck_results.hidden_types);
569 }
570
571 {}
#[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("visit_opaque_types",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(571u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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();
}
#[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;
}
{
if self.fcx.next_trait_solver() {
return self.visit_opaque_types_next();
}
let tcx = self.tcx();
let opaque_types = self.fcx.infcx.clone_opaque_types();
let num_entries =
self.fcx.inner.borrow_mut().opaque_types().num_entries();
let prev =
self.fcx.checked_opaque_types_storage_entries.replace(Some(num_entries));
if true {
{
match (&prev, &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::None);
}
}
}
};
};
for (opaque_type_key, hidden_type) in opaque_types {
let hidden_type =
self.resolve(hidden_type, &hidden_type.span);
let opaque_type_key =
self.resolve(opaque_type_key, &hidden_type.span);
if let &ty::Alias(_, ty::AliasTy {
kind: ty::Opaque { def_id }, args, .. }) =
hidden_type.ty.kind() &&
def_id == opaque_type_key.def_id.to_def_id() &&
args == opaque_type_key.args {
continue;
}
if let Err(err) =
opaque_type_has_defining_use_args(self.fcx, opaque_type_key,
hidden_type.span, DefiningScopeKind::HirTypeck) {
self.typeck_results.hidden_types.insert(opaque_type_key.def_id,
ty::DefinitionSiteHiddenType::new_error(tcx,
err.report(self.fcx)));
}
let hidden_type =
hidden_type.remap_generic_params_to_declaration_params(opaque_type_key,
tcx, DefiningScopeKind::HirTypeck);
if let Some(prev) =
self.typeck_results.hidden_types.insert(opaque_type_key.def_id,
hidden_type) {
let entry =
self.typeck_results.hidden_types.get_mut(&opaque_type_key.def_id).unwrap();
if prev.ty != hidden_type.ty {
let guar =
if let Some(guar) = self.typeck_results.tainted_by_errors {
guar
} else {
let (Ok(guar) | Err(guar)) =
prev.build_mismatch_error(&hidden_type,
tcx).map(|d| d.emit_err());
guar
};
*entry = DefinitionSiteHiddenType::new_error(tcx, guar);
}
entry.span = prev.span.substitute_dummy(hidden_type.span);
}
}
let recursive_opaques: Vec<_> =
self.typeck_results.hidden_types.iter().filter(|&(&def_id,
hidden_ty)|
{
hidden_ty.ty.instantiate_identity().skip_norm_wip().visit_with(&mut HasRecursiveOpaque {
def_id,
seen: Default::default(),
opaques: &self.typeck_results.hidden_types,
tcx,
}).is_break()
}).map(|(def_id, hidden_ty)|
(*def_id, hidden_ty.span)).collect();
for (def_id, span) in recursive_opaques {
let guar =
self.fcx.dcx().struct_span_err(span,
"cannot resolve opaque type").with_code(E0720).emit_err();
self.typeck_results.hidden_types.insert(def_id,
DefinitionSiteHiddenType::new_error(tcx, guar));
}
}
}
}#[instrument(skip(self), level = "debug")]
572 fn visit_opaque_types(&mut self) {
573 if self.fcx.next_trait_solver() {
574 return self.visit_opaque_types_next();
575 }
576
577 let tcx = self.tcx();
578 let opaque_types = self.fcx.infcx.clone_opaque_types();
581 let num_entries = self.fcx.inner.borrow_mut().opaque_types().num_entries();
582 let prev = self.fcx.checked_opaque_types_storage_entries.replace(Some(num_entries));
583 debug_assert_eq!(prev, None);
584 for (opaque_type_key, hidden_type) in opaque_types {
585 let hidden_type = self.resolve(hidden_type, &hidden_type.span);
586 let opaque_type_key = self.resolve(opaque_type_key, &hidden_type.span);
587 if let &ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) =
588 hidden_type.ty.kind()
589 && def_id == opaque_type_key.def_id.to_def_id()
590 && args == opaque_type_key.args
591 {
592 continue;
593 }
594
595 if let Err(err) = opaque_type_has_defining_use_args(
596 self.fcx,
597 opaque_type_key,
598 hidden_type.span,
599 DefiningScopeKind::HirTypeck,
600 ) {
601 self.typeck_results.hidden_types.insert(
602 opaque_type_key.def_id,
603 ty::DefinitionSiteHiddenType::new_error(tcx, err.report(self.fcx)),
604 );
605 }
606
607 let hidden_type = hidden_type.remap_generic_params_to_declaration_params(
608 opaque_type_key,
609 tcx,
610 DefiningScopeKind::HirTypeck,
611 );
612
613 if let Some(prev) =
614 self.typeck_results.hidden_types.insert(opaque_type_key.def_id, hidden_type)
615 {
616 let entry =
617 self.typeck_results.hidden_types.get_mut(&opaque_type_key.def_id).unwrap();
618 if prev.ty != hidden_type.ty {
619 let guar = if let Some(guar) = self.typeck_results.tainted_by_errors {
620 guar
621 } else {
622 let (Ok(guar) | Err(guar)) =
623 prev.build_mismatch_error(&hidden_type, tcx).map(|d| d.emit_err());
624 guar
625 };
626 *entry = DefinitionSiteHiddenType::new_error(tcx, guar);
627 }
628
629 entry.span = prev.span.substitute_dummy(hidden_type.span);
632 }
633 }
634
635 let recursive_opaques: Vec<_> = self
636 .typeck_results
637 .hidden_types
638 .iter()
639 .filter(|&(&def_id, hidden_ty)| {
640 hidden_ty
641 .ty
642 .instantiate_identity()
643 .skip_norm_wip()
644 .visit_with(&mut HasRecursiveOpaque {
645 def_id,
646 seen: Default::default(),
647 opaques: &self.typeck_results.hidden_types,
648 tcx,
649 })
650 .is_break()
651 })
652 .map(|(def_id, hidden_ty)| (*def_id, hidden_ty.span))
653 .collect();
654 for (def_id, span) in recursive_opaques {
655 let guar = self
656 .fcx
657 .dcx()
658 .struct_span_err(span, "cannot resolve opaque type")
659 .with_code(E0720)
660 .emit_err();
661 self.typeck_results
662 .hidden_types
663 .insert(def_id, DefinitionSiteHiddenType::new_error(tcx, guar));
664 }
665 }
666
667 fn visit_field_id(&mut self, hir_id: HirId) {
668 if let Some(index) = self.fcx.typeck_results.borrow_mut().field_indices_mut().remove(hir_id)
669 {
670 self.typeck_results.field_indices_mut().insert(hir_id, index);
671 }
672 }
673
674 {}
#[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("visit_node_id",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(674u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("hir_id")
}> =
::tracing::__macro_support::FieldName::new("hir_id");
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(&hir_id)
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;
}
{
if let Some(def) =
self.fcx.typeck_results.borrow_mut().type_dependent_defs_mut().remove(hir_id)
{
self.typeck_results.type_dependent_defs_mut().insert(hir_id,
def);
}
if let Some(def) =
self.fcx.typeck_results.borrow_mut().splatted_defs_mut().remove(hir_id)
{
self.typeck_results.splatted_defs_mut().insert(hir_id, def);
}
self.visit_adjustments(span, hir_id);
let n_ty = self.fcx.node_ty(hir_id);
let n_ty = self.resolve(n_ty, &span);
self.write_ty_to_typeck_results(hir_id, n_ty);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:695",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(695u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("n_ty")
}> =
::tracing::__macro_support::FieldName::new("n_ty");
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(&n_ty)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if let Some(args) =
self.fcx.typeck_results.borrow().node_args_opt(hir_id) {
let args = self.resolve(args, &span);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:700",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(700u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("write_args_to_tcx({0:?}, {1:?})",
hir_id, args) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if !(!args.has_infer() && !args.has_placeholders()) {
::core::panicking::panic("assertion failed: !args.has_infer() && !args.has_placeholders()")
};
self.typeck_results.node_args_mut().insert(hir_id, args);
}
}
}
}#[instrument(skip(self, span), level = "debug")]
675 fn visit_node_id(&mut self, span: Span, hir_id: HirId) {
676 if let Some(def) =
678 self.fcx.typeck_results.borrow_mut().type_dependent_defs_mut().remove(hir_id)
679 {
680 self.typeck_results.type_dependent_defs_mut().insert(hir_id, def);
681 }
682
683 if let Some(def) = self.fcx.typeck_results.borrow_mut().splatted_defs_mut().remove(hir_id) {
685 self.typeck_results.splatted_defs_mut().insert(hir_id, def);
686 }
687
688 self.visit_adjustments(span, hir_id);
690
691 let n_ty = self.fcx.node_ty(hir_id);
693 let n_ty = self.resolve(n_ty, &span);
694 self.write_ty_to_typeck_results(hir_id, n_ty);
695 debug!(?n_ty);
696
697 if let Some(args) = self.fcx.typeck_results.borrow().node_args_opt(hir_id) {
699 let args = self.resolve(args, &span);
700 debug!("write_args_to_tcx({:?}, {:?})", hir_id, args);
701 assert!(!args.has_infer() && !args.has_placeholders());
702 self.typeck_results.node_args_mut().insert(hir_id, args);
703 }
704 }
705
706 {}
#[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("visit_adjustments",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(706u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("hir_id")
}> =
::tracing::__macro_support::FieldName::new("hir_id");
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(&hir_id)
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 adjustment =
self.fcx.typeck_results.borrow_mut().adjustments_mut().remove(hir_id);
match adjustment {
None => {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:711",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(711u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("no adjustments for node")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
}
Some(adjustment) => {
let resolved_adjustment = self.resolve(adjustment, &span);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:716",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(716u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("resolved_adjustment")
}> =
::tracing::__macro_support::FieldName::new("resolved_adjustment");
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(&resolved_adjustment)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.typeck_results.adjustments_mut().insert(hir_id,
resolved_adjustment);
}
}
}
}
}#[instrument(skip(self, span), level = "debug")]
707 fn visit_adjustments(&mut self, span: Span, hir_id: HirId) {
708 let adjustment = self.fcx.typeck_results.borrow_mut().adjustments_mut().remove(hir_id);
709 match adjustment {
710 None => {
711 debug!("no adjustments for node");
712 }
713
714 Some(adjustment) => {
715 let resolved_adjustment = self.resolve(adjustment, &span);
716 debug!(?resolved_adjustment);
717 self.typeck_results.adjustments_mut().insert(hir_id, resolved_adjustment);
718 }
719 }
720 }
721
722 {}
#[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("visit_rust_2024_migration_desugared_pats",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(722u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("hir_id")
}> =
::tracing::__macro_support::FieldName::new("hir_id");
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(&hir_id)
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;
}
{
if let Some(is_hard_error) =
self.fcx.typeck_results.borrow_mut().rust_2024_migration_desugared_pats_mut().remove(hir_id)
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:731",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(731u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("node is a pat whose match ergonomics are desugared by the Rust 2024 migration lint")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.typeck_results.rust_2024_migration_desugared_pats_mut().insert(hir_id,
is_hard_error);
}
}
}
}#[instrument(skip(self), level = "debug")]
723 fn visit_rust_2024_migration_desugared_pats(&mut self, hir_id: hir::HirId) {
724 if let Some(is_hard_error) = self
725 .fcx
726 .typeck_results
727 .borrow_mut()
728 .rust_2024_migration_desugared_pats_mut()
729 .remove(hir_id)
730 {
731 debug!(
732 "node is a pat whose match ergonomics are desugared by the Rust 2024 migration lint"
733 );
734 self.typeck_results
735 .rust_2024_migration_desugared_pats_mut()
736 .insert(hir_id, is_hard_error);
737 }
738 }
739
740 {}
#[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("visit_pat_adjustments",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(740u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("hir_id")
}> =
::tracing::__macro_support::FieldName::new("hir_id");
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(&hir_id)
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 adjustment =
self.fcx.typeck_results.borrow_mut().pat_adjustments_mut().remove(hir_id);
match adjustment {
None => {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:745",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(745u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("no pat_adjustments for node")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
}
Some(adjustment) => {
let resolved_adjustment = self.resolve(adjustment, &span);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:750",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(750u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("resolved_adjustment")
}> =
::tracing::__macro_support::FieldName::new("resolved_adjustment");
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(&resolved_adjustment)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.typeck_results.pat_adjustments_mut().insert(hir_id,
resolved_adjustment);
}
}
}
}
}#[instrument(skip(self, span), level = "debug")]
741 fn visit_pat_adjustments(&mut self, span: Span, hir_id: HirId) {
742 let adjustment = self.fcx.typeck_results.borrow_mut().pat_adjustments_mut().remove(hir_id);
743 match adjustment {
744 None => {
745 debug!("no pat_adjustments for node");
746 }
747
748 Some(adjustment) => {
749 let resolved_adjustment = self.resolve(adjustment, &span);
750 debug!(?resolved_adjustment);
751 self.typeck_results.pat_adjustments_mut().insert(hir_id, resolved_adjustment);
752 }
753 }
754 }
755
756 {}
#[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("visit_skipped_ref_pats",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(756u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("hir_id")
}> =
::tracing::__macro_support::FieldName::new("hir_id");
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(&hir_id)
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;
}
{
if self.fcx.typeck_results.borrow_mut().skipped_ref_pats_mut().remove(hir_id)
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs:759",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(759u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::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!("node is a skipped ref pat")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.typeck_results.skipped_ref_pats_mut().insert(hir_id);
}
}
}
}#[instrument(skip(self), level = "debug")]
757 fn visit_skipped_ref_pats(&mut self, hir_id: hir::HirId) {
758 if self.fcx.typeck_results.borrow_mut().skipped_ref_pats_mut().remove(hir_id) {
759 debug!("node is a skipped ref pat");
760 self.typeck_results.skipped_ref_pats_mut().insert(hir_id);
761 }
762 }
763
764 fn visit_liberated_fn_sigs(&mut self) {
765 let fcx_typeck_results = self.fcx.typeck_results.borrow();
766 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
767 let common_hir_owner = fcx_typeck_results.hir_owner;
768
769 let fcx_liberated_fn_sigs = fcx_typeck_results.liberated_fn_sigs().items_in_stable_order();
770
771 for (local_id, &fn_sig) in fcx_liberated_fn_sigs {
772 let hir_id = HirId { owner: common_hir_owner, local_id };
773 let fn_sig = self.resolve(fn_sig, &hir_id);
774 self.typeck_results.liberated_fn_sigs_mut().insert(hir_id, fn_sig);
775 }
776 }
777
778 fn visit_fru_field_types(&mut self) {
779 let fcx_typeck_results = self.fcx.typeck_results.borrow();
780 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
781 let common_hir_owner = fcx_typeck_results.hir_owner;
782
783 let fcx_fru_field_types = fcx_typeck_results.fru_field_types().items_in_stable_order();
784
785 for (local_id, ftys) in fcx_fru_field_types {
786 let hir_id = HirId { owner: common_hir_owner, local_id };
787 let ftys = self.resolve(ftys.clone(), &hir_id);
788 self.typeck_results.fru_field_types_mut().insert(hir_id, ftys);
789 }
790 }
791
792 fn visit_offset_of_container_types(&mut self) {
793 let fcx_typeck_results = self.fcx.typeck_results.borrow();
794 {
match (&fcx_typeck_results.hir_owner, &self.typeck_results.hir_owner) {
(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::None);
}
}
}
};assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
795 let common_hir_owner = fcx_typeck_results.hir_owner;
796
797 for (local_id, indices) in fcx_typeck_results.offset_of_data().items_in_stable_order() {
798 let hir_id = HirId { owner: common_hir_owner, local_id };
799 let indices = indices
800 .iter()
801 .map(|&(ty, variant, field)| (self.resolve(ty, &hir_id), variant, field))
802 .collect();
803 self.typeck_results.offset_of_data_mut().insert(hir_id, indices);
804 }
805 }
806
807 fn visit_potentially_region_dependent_goals(&mut self) {
808 let obligations = self.fcx.take_hir_typeck_potentially_region_dependent_goals();
809 if self.fcx.tainted_by_errors().is_none() {
810 for obligation in obligations {
811 let (predicate, mut cause) = self
812 .fcx
813 .deeply_resolve_ignoring_regions((obligation.predicate, obligation.cause));
814 if predicate.has_non_region_infer() {
815 self.fcx.dcx().span_delayed_bug(
816 cause.span,
817 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unexpected inference variable after writeback: {0:?}",
predicate))
})format!("unexpected inference variable after writeback: {predicate:?}"),
818 );
819 } else {
820 let predicate = self.tcx().erase_and_anonymize_regions(predicate);
821 if cause.has_infer() || cause.has_placeholders() {
822 cause = self.fcx.misc(cause.span);
825 }
826 self.typeck_results
827 .potentially_region_dependent_goals
828 .insert((predicate, cause));
829 }
830 }
831 }
832 }
833
834 fn resolve<T>(&mut self, value: T, span: &dyn Locatable) -> T
835 where
836 T: TypeFoldable<TyCtxt<'tcx>>,
837 {
838 let value = self.fcx.deeply_resolve_ignoring_regions(value);
839
840 let mut goals = ::alloc::vec::Vec::new()vec![];
841 let value =
842 value.fold_with(&mut Resolver::new(self.fcx, span, self.body, true, &mut goals));
843
844 let mut unexpected_goals = ::alloc::vec::Vec::new()vec![];
848 self.typeck_results.coroutine_stalled_predicates.extend(
849 goals
850 .into_iter()
851 .map(|pred| {
852 self.fcx.deeply_resolve_ignoring_regions(pred).fold_with(&mut Resolver::new(
853 self.fcx,
854 span,
855 self.body,
856 false,
857 &mut unexpected_goals,
858 ))
859 })
860 .map(|goal| (goal.predicate, self.fcx.misc(span.to_span(self.fcx.tcx)))),
862 );
863 {
match (&unexpected_goals, &::alloc::vec::Vec::new()) {
(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::None);
}
}
}
};assert_eq!(unexpected_goals, vec![]);
864
865 if !!value.has_infer() {
::core::panicking::panic("assertion failed: !value.has_infer()")
};assert!(!value.has_infer());
866
867 if let Err(guar) = value.error_reported() {
871 self.typeck_results.tainted_by_errors = Some(guar);
872 }
873
874 value
875 }
876
877 fn resolve_coroutine_predicate<T>(&mut self, value: T, span: &dyn Locatable) -> T
878 where
879 T: TypeFoldable<TyCtxt<'tcx>>,
880 {
881 let value = self.fcx.deeply_resolve_ignoring_regions(value);
882
883 let mut goals = ::alloc::vec::Vec::new()vec![];
884 let value =
885 value.fold_with(&mut Resolver::new(self.fcx, span, self.body, false, &mut goals));
886 {
match (&goals, &::alloc::vec::Vec::new()) {
(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::None);
}
}
}
};assert_eq!(goals, vec![]);
887
888 if !!value.has_infer() {
::core::panicking::panic("assertion failed: !value.has_infer()")
};assert!(!value.has_infer());
889
890 if let Err(guar) = value.error_reported() {
894 self.typeck_results.tainted_by_errors = Some(guar);
895 }
896
897 value
898 }
899}
900
901pub(crate) trait Locatable {
902 fn to_span(&self, tcx: TyCtxt<'_>) -> Span;
903}
904
905impl Locatable for Span {
906 fn to_span(&self, _: TyCtxt<'_>) -> Span {
907 *self
908 }
909}
910
911impl Locatable for HirId {
912 fn to_span(&self, tcx: TyCtxt<'_>) -> Span {
913 tcx.hir_span(*self)
914 }
915}
916
917struct Resolver<'cx, 'tcx> {
918 fcx: &'cx FnCtxt<'cx, 'tcx>,
919 span: &'cx dyn Locatable,
920 body: &'tcx hir::Body<'tcx>,
921 should_normalize: bool,
924 nested_goals: &'cx mut Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
925}
926
927impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
928 fn new(
929 fcx: &'cx FnCtxt<'cx, 'tcx>,
930 span: &'cx dyn Locatable,
931 body: &'tcx hir::Body<'tcx>,
932 should_normalize: bool,
933 nested_goals: &'cx mut Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
934 ) -> Resolver<'cx, 'tcx> {
935 Resolver { fcx, span, body, nested_goals, should_normalize }
936 }
937
938 fn report_error(&self, p: impl Into<ty::Term<'tcx>>) -> ErrorGuaranteed {
939 if let Some(guar) = self.fcx.tainted_by_errors() {
940 guar
941 } else {
942 self.fcx
943 .err_ctxt()
944 .emit_inference_failure_err(
945 self.fcx.tcx.hir_body_owner_def_id(self.body.id()),
946 self.span.to_span(self.fcx.tcx),
947 p.into(),
948 TypeAnnotationNeeded::E0282,
949 false,
950 )
951 .emit_err()
952 }
953 }
954
955 {}
#[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("handle_term",
"rustc_hir_typeck::writeback", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/32dba69d69c5b10ea89a4042de8d0619f7756203/compiler/rustc_hir_typeck/src/writeback.rs"),
::tracing_core::__macro_support::Option::Some(955u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_typeck::writeback"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("value")
}> =
::tracing::__macro_support::FieldName::new("value");
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(&value)
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: T = loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.fcx.tcx;
let mut value =
if self.should_normalize && self.fcx.next_trait_solver() {
let body_def_id = tcx.hir_body_owner_def_id(self.body.id());
let cause =
ObligationCause::misc(self.span.to_span(tcx), body_def_id);
let at = self.fcx.at(&cause, self.fcx.param_env);
let universes =
::alloc::vec::from_elem(None,
outer_exclusive_binder(&value).as_usize());
match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals(at,
Unnormalized::new_wip(value), universes) {
Ok((value, goals)) => {
self.nested_goals.extend(goals);
value
}
Err(errors) => {
let guar =
self.fcx.err_ctxt().report_fulfillment_errors(errors);
new_err(tcx, guar)
}
}
} else { value };
if value.has_non_region_infer() {
let guar = self.report_error(value);
value = new_err(tcx, guar);
}
value = fold_regions(tcx, value, |_, _| tcx.lifetimes.re_erased);
if tcx.features().generic_const_exprs() {
value =
value.fold_with(&mut EagerlyNormalizeConsts::new(self.fcx));
}
value
}
}
}#[instrument(level = "debug", skip(self, outer_exclusive_binder, new_err))]
956 fn handle_term<T>(
957 &mut self,
958 value: T,
959 outer_exclusive_binder: impl FnOnce(&T) -> ty::DebruijnIndex,
960 new_err: impl Fn(TyCtxt<'tcx>, ErrorGuaranteed) -> T,
961 ) -> T
962 where
963 T: Into<ty::Term<'tcx>> + TypeSuperFoldable<TyCtxt<'tcx>> + Copy,
964 {
965 let tcx = self.fcx.tcx;
966 let mut value = if self.should_normalize && self.fcx.next_trait_solver() {
969 let body_def_id = tcx.hir_body_owner_def_id(self.body.id());
970 let cause = ObligationCause::misc(self.span.to_span(tcx), body_def_id);
971 let at = self.fcx.at(&cause, self.fcx.param_env);
972 let universes = vec![None; outer_exclusive_binder(&value).as_usize()];
973 match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals(
974 at,
975 Unnormalized::new_wip(value),
976 universes,
977 ) {
978 Ok((value, goals)) => {
979 self.nested_goals.extend(goals);
980 value
981 }
982 Err(errors) => {
983 let guar = self.fcx.err_ctxt().report_fulfillment_errors(errors);
984 new_err(tcx, guar)
985 }
986 }
987 } else {
988 value
989 };
990
991 if value.has_non_region_infer() {
993 let guar = self.report_error(value);
994 value = new_err(tcx, guar);
995 }
996
997 value = fold_regions(tcx, value, |_, _| tcx.lifetimes.re_erased);
1007
1008 if tcx.features().generic_const_exprs() {
1010 value = value.fold_with(&mut EagerlyNormalizeConsts::new(self.fcx));
1011 }
1012
1013 value
1014 }
1015}
1016
1017impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
1018 fn cx(&self) -> TyCtxt<'tcx> {
1019 self.fcx.tcx
1020 }
1021
1022 fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
1023 match r.kind() {
1024 ty::ReBound(..) => r,
1025 _ => self.fcx.tcx.lifetimes.re_erased,
1026 }
1027 }
1028
1029 fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
1030 self.handle_term(ty, Ty::outer_exclusive_binder, Ty::new_error)
1031 }
1032
1033 fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
1034 self.handle_term(ct, ty::Const::outer_exclusive_binder, ty::Const::new_error)
1035 }
1036
1037 fn fold_predicate<P: PredicateProxy<TyCtxt<'tcx>>>(&mut self, predicate: P) -> P {
1038 if !!self.should_normalize {
{
::core::panicking::panic_fmt(format_args!("normalizing predicates in writeback is not generally sound"));
}
};assert!(
1039 !self.should_normalize,
1040 "normalizing predicates in writeback is not generally sound"
1041 );
1042 predicate.super_fold_with(self)
1043 }
1044}
1045
1046struct EagerlyNormalizeConsts<'tcx> {
1047 tcx: TyCtxt<'tcx>,
1048 typing_env: ty::TypingEnv<'tcx>,
1049}
1050impl<'tcx> EagerlyNormalizeConsts<'tcx> {
1051 fn new(fcx: &FnCtxt<'_, 'tcx>) -> Self {
1052 EagerlyNormalizeConsts { tcx: fcx.tcx, typing_env: fcx.typing_env(fcx.param_env) }
1055 }
1056}
1057
1058impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EagerlyNormalizeConsts<'tcx> {
1059 fn cx(&self) -> TyCtxt<'tcx> {
1060 self.tcx
1061 }
1062
1063 fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
1064 self.tcx
1065 .try_normalize_erasing_regions(self.typing_env, Unnormalized::new_wip(ct))
1066 .unwrap_or(ct)
1067 }
1068}
1069
1070struct HasRecursiveOpaque<'a, 'tcx> {
1071 def_id: LocalDefId,
1072 seen: FxHashSet<LocalDefId>,
1073 opaques: &'a FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'tcx>>,
1074 tcx: TyCtxt<'tcx>,
1075}
1076
1077impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for HasRecursiveOpaque<'_, 'tcx> {
1078 type Result = ControlFlow<()>;
1079
1080 fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
1081 if let ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) = *t.kind()
1082 && let Some(def_id) = def_id.as_local()
1083 {
1084 if self.def_id == def_id {
1085 return ControlFlow::Break(());
1086 }
1087
1088 if self.seen.insert(def_id)
1089 && let Some(hidden_ty) = self.opaques.get(&def_id)
1090 {
1091 hidden_ty.ty.instantiate(self.tcx, args).skip_norm_wip().visit_with(self)?;
1092 }
1093 }
1094
1095 t.super_visit_with(self)
1096 }
1097}