1use rustc_data_structures::fx::FxIndexMap;
2use rustc_hir::def::DefKind;
3use rustc_hir::def_id::DefId;
4use rustc_middle::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt};
5use rustc_span::Span;
6use tracing::debug;
7
8use super::explicit::ExplicitPredicatesMap;
9use super::utils::*;
10
11pub(super) fn infer_predicates(
13 tcx: TyCtxt<'_>,
14) -> FxIndexMap<DefId, ty::EarlyBinder<'_, RequiredPredicates<'_>>> {
15 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:15",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(15u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("infer_predicates")
as &dyn Value))])
});
} else { ; }
};debug!("infer_predicates");
16
17 let mut explicit_map = ExplicitPredicatesMap::new();
18
19 let mut global_inferred_outlives = FxIndexMap::default();
20
21 for i in 0.. {
24 let mut predicates_added = ::alloc::vec::Vec::new()vec![];
25
26 for id in tcx.hir_free_items() {
28 let item_did = id.owner_id;
29
30 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:30",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(30u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("InferVisitor::visit_item(item={0:?})",
item_did) as &dyn Value))])
});
} else { ; }
};debug!("InferVisitor::visit_item(item={:?})", item_did);
31
32 let mut item_required_predicates = RequiredPredicates::default();
33 match tcx.def_kind(item_did) {
34 DefKind::Union | DefKind::Enum | DefKind::Struct => {
35 let adt_def = tcx.adt_def(item_did.to_def_id());
36
37 for field_def in adt_def.all_fields() {
39 let field_ty =
46 tcx.type_of(field_def.did).instantiate_identity().skip_norm_wip();
47 let field_span = tcx.def_span(field_def.did);
48 insert_required_predicates_to_be_wf(
49 tcx,
50 field_ty,
51 field_span,
52 &global_inferred_outlives,
53 &mut item_required_predicates,
54 &mut explicit_map,
55 );
56 }
57 }
58
59 DefKind::TyAlias if tcx.type_alias_is_lazy(item_did) => {
60 insert_required_predicates_to_be_wf(
61 tcx,
62 tcx.type_of(item_did).instantiate_identity().skip_norm_wip(),
63 tcx.def_span(item_did),
64 &global_inferred_outlives,
65 &mut item_required_predicates,
66 &mut explicit_map,
67 );
68 }
69
70 _ => {}
71 };
72
73 let item_predicates_len: usize = global_inferred_outlives
80 .get(&item_did.to_def_id())
81 .map_or(0, |p| p.as_ref().skip_binder().len());
82 if item_required_predicates.len() > item_predicates_len {
83 predicates_added.push(item_did);
84 global_inferred_outlives.insert(
85 item_did.to_def_id(),
86 ty::EarlyBinder::bind_iter(item_required_predicates),
87 );
88 }
89 }
90
91 if predicates_added.is_empty() {
92 break;
94 } else if !tcx.recursion_limit().value_within_limit(i) {
95 let msg = if let &[id] = &predicates_added[..] {
96 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("overflow computing implied lifetime bounds for `{0}`",
tcx.def_path_str(id)))
})format!("overflow computing implied lifetime bounds for `{}`", tcx.def_path_str(id),)
97 } else {
98 "overflow computing implied lifetime bounds".to_string()
99 };
100 tcx.dcx()
101 .struct_span_fatal(
102 predicates_added.iter().map(|id| tcx.def_span(*id)).collect::<Vec<_>>(),
103 msg,
104 )
105 .emit();
106 }
107 }
108
109 global_inferred_outlives
110}
111
112fn insert_required_predicates_to_be_wf<'tcx>(
113 tcx: TyCtxt<'tcx>,
114 ty: Ty<'tcx>,
115 span: Span,
116 global_inferred_outlives: &FxIndexMap<DefId, ty::EarlyBinder<'tcx, RequiredPredicates<'tcx>>>,
117 required_predicates: &mut RequiredPredicates<'tcx>,
118 explicit_map: &mut ExplicitPredicatesMap<'tcx>,
119) {
120 for arg in ty.walk() {
121 let leaf_ty = match arg.kind() {
122 GenericArgKind::Type(ty) => ty,
123
124 GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue,
127 };
128
129 match *leaf_ty.kind() {
130 ty::Ref(region, rty, _) => {
131 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:135",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(135u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("Ref")
as &dyn Value))])
});
} else { ; }
};debug!("Ref");
136 insert_outlives_predicate(tcx, rty.into(), region, span, required_predicates);
137 }
138
139 ty::Adt(def, args) => {
140 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:141",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(141u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("Adt")
as &dyn Value))])
});
} else { ; }
};debug!("Adt");
142 check_inferred_predicates(
143 tcx,
144 def.did(),
145 args,
146 global_inferred_outlives,
147 required_predicates,
148 );
149 check_explicit_predicates(
150 tcx,
151 def.did(),
152 args,
153 required_predicates,
154 explicit_map,
155 IgnorePredicatesReferencingSelf::No,
156 );
157 }
158
159 ty::Alias(_, ty::AliasTy { kind: ty::Free { def_id }, args, .. }) => {
160 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:162",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(162u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("Free")
as &dyn Value))])
});
} else { ; }
};debug!("Free");
163 check_inferred_predicates(
164 tcx,
165 def_id,
166 args,
167 global_inferred_outlives,
168 required_predicates,
169 );
170 check_explicit_predicates(
171 tcx,
172 def_id,
173 args,
174 required_predicates,
175 explicit_map,
176 IgnorePredicatesReferencingSelf::No,
177 );
178 }
179
180 ty::Dynamic(obj, ..) => {
181 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:183",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(183u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("Dynamic")
as &dyn Value))])
});
} else { ; }
};debug!("Dynamic");
184 if let Some(trait_ref) = obj.principal() {
185 let args = trait_ref
186 .with_self_ty(tcx, tcx.types.trait_object_dummy_self)
187 .skip_binder()
188 .args;
189 check_explicit_predicates(
199 tcx,
200 trait_ref.def_id(),
201 args,
202 required_predicates,
203 explicit_map,
204 IgnorePredicatesReferencingSelf::Yes,
205 );
206 }
207 }
208
209 ty::Alias(_, ty::AliasTy { kind: ty::Projection { def_id }, args, .. }) => {
210 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:213",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(213u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("Projection")
as &dyn Value))])
});
} else { ; }
};debug!("Projection");
214 check_explicit_predicates(
215 tcx,
216 tcx.parent(def_id),
217 args,
218 required_predicates,
219 explicit_map,
220 IgnorePredicatesReferencingSelf::No,
221 );
222 }
223
224 ty::Alias(_, ty::AliasTy { kind: ty::Inherent { .. }, .. }) => {}
226
227 _ => {}
228 }
229 }
230}
231
232#[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("check_explicit_predicates",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(249u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::tracing_core::field::FieldSet::new(&["def_id", "args",
"required_predicates", "explicit_map",
"ignore_preds_refing_self"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&required_predicates)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&explicit_map)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ignore_preds_refing_self)
as &dyn 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 explicit_predicates =
explicit_map.explicit_predicates_of(tcx, def_id);
for (&predicate @ ty::OutlivesPredicate(arg, _), &span) in
explicit_predicates.as_ref().skip_binder() {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:263",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(263u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::tracing_core::field::FieldSet::new(&["predicate"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&predicate)
as &dyn Value))])
});
} else { ; }
};
if let IgnorePredicatesReferencingSelf::Yes =
ignore_preds_refing_self &&
arg.walk().any(|arg| arg == tcx.types.self_param.into()) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:268",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(268u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("ignoring predicate since it references `Self`")
as &dyn Value))])
});
} else { ; }
};
continue;
}
let predicate @ ty::OutlivesPredicate(arg, region) =
explicit_predicates.rebind(predicate).instantiate(tcx,
args).skip_norm_wip();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs:274",
"rustc_hir_analysis::outlives::implicit_infer",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs"),
::tracing_core::__macro_support::Option::Some(274u32),
::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::outlives::implicit_infer"),
::tracing_core::field::FieldSet::new(&["predicate"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&predicate)
as &dyn Value))])
});
} else { ; }
};
insert_outlives_predicate(tcx, arg, region, span,
required_predicates);
}
}
}
}#[tracing::instrument(level = "debug", skip(tcx))]
250fn check_explicit_predicates<'tcx>(
251 tcx: TyCtxt<'tcx>,
252 def_id: DefId,
253 args: &[GenericArg<'tcx>],
254 required_predicates: &mut RequiredPredicates<'tcx>,
255 explicit_map: &mut ExplicitPredicatesMap<'tcx>,
256 ignore_preds_refing_self: IgnorePredicatesReferencingSelf,
257) {
258 let explicit_predicates = explicit_map.explicit_predicates_of(tcx, def_id);
259
260 for (&predicate @ ty::OutlivesPredicate(arg, _), &span) in
261 explicit_predicates.as_ref().skip_binder()
262 {
263 debug!(?predicate);
264
265 if let IgnorePredicatesReferencingSelf::Yes = ignore_preds_refing_self
266 && arg.walk().any(|arg| arg == tcx.types.self_param.into())
267 {
268 debug!("ignoring predicate since it references `Self`");
269 continue;
270 }
271
272 let predicate @ ty::OutlivesPredicate(arg, region) =
273 explicit_predicates.rebind(predicate).instantiate(tcx, args).skip_norm_wip();
274 debug!(?predicate);
275
276 insert_outlives_predicate(tcx, arg, region, span, required_predicates);
277 }
278}
279
280#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IgnorePredicatesReferencingSelf {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
IgnorePredicatesReferencingSelf::Yes => "Yes",
IgnorePredicatesReferencingSelf::No => "No",
})
}
}Debug)]
281enum IgnorePredicatesReferencingSelf {
282 Yes,
283 No,
284}
285
286fn check_inferred_predicates<'tcx>(
306 tcx: TyCtxt<'tcx>,
307 def_id: DefId,
308 args: ty::GenericArgsRef<'tcx>,
309 global_inferred_outlives: &FxIndexMap<DefId, ty::EarlyBinder<'tcx, RequiredPredicates<'tcx>>>,
310 required_predicates: &mut RequiredPredicates<'tcx>,
311) {
312 let Some(predicates) = global_inferred_outlives.get(&def_id) else {
316 return;
317 };
318
319 for (&predicate, &span) in predicates.as_ref().skip_binder() {
320 let ty::OutlivesPredicate(arg, region) =
323 predicates.rebind(predicate).instantiate(tcx, args).skip_norm_wip();
324 insert_outlives_predicate(tcx, arg, region, span, required_predicates);
325 }
326}