1#![allow(rustc::usage_of_ty_tykind)]
13
14use std::fmt::Debug;
15use std::hash::{Hash, Hasher};
16use std::marker::PhantomData;
17use std::num::NonZero;
18use std::ptr::NonNull;
19use std::{fmt, iter, str};
20
21pub use adt::*;
22pub use assoc::*;
23pub use generic_args::{GenericArgKind, TermKind, *};
24pub use generics::*;
25pub use intrinsic::IntrinsicDef;
26use rustc_abi::{
27 Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, ScalableElt, VariantIdx,
28};
29use rustc_ast::AttrVec;
30use rustc_ast::expand::typetree::{FncTree, Kind, Type, TypeTree};
31use rustc_ast::node_id::NodeMap;
32pub use rustc_ast_ir::{Movability, Mutability, try_visit};
33use rustc_data_structures::assert_matches;
34use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
35use rustc_data_structures::intern::Interned;
36use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
37use rustc_data_structures::steal::Steal;
38use rustc_data_structures::unord::{UnordMap, UnordSet};
39use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
40use rustc_hir::attrs::StrippedCfgItem;
41use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
42use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
43use rustc_hir::{LangItem, attrs as attr, find_attr};
44use rustc_index::IndexVec;
45use rustc_index::bit_set::BitMatrix;
46use rustc_macros::{
47 BlobDecodable, Decodable, Encodable, HashStable, TyDecodable, TyEncodable, TypeFoldable,
48 TypeVisitable, extension,
49};
50use rustc_serialize::{Decodable, Encodable};
51pub use rustc_session::lint::RegisteredTools;
52use rustc_span::hygiene::MacroKind;
53use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol};
54pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet};
55pub use rustc_type_ir::fast_reject::DeepRejectCtxt;
56#[allow(
57 hidden_glob_reexports,
58 rustc::usage_of_type_ir_inherent,
59 rustc::non_glob_import_of_type_ir_inherent
60)]
61use rustc_type_ir::inherent;
62pub use rustc_type_ir::relate::VarianceDiagInfo;
63pub use rustc_type_ir::solve::{CandidatePreferenceMode, SizedTraitKind};
64pub use rustc_type_ir::*;
65#[allow(hidden_glob_reexports, unused_imports)]
66use rustc_type_ir::{InferCtxtLike, Interner};
67use tracing::{debug, instrument, trace};
68pub use vtable::*;
69use {rustc_ast as ast, rustc_hir as hir};
70
71pub use self::closure::{
72 BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo,
73 MinCaptureInformationMap, MinCaptureList, RootVariableMinCaptureList, UpvarCapture, UpvarId,
74 UpvarPath, analyze_coroutine_closure_captures, is_ancestor_or_same_capture,
75 place_to_string_for_capture,
76};
77pub use self::consts::{
78 AtomicOrdering, Const, ConstInt, ConstKind, ConstToValTreeResult, Expr, ExprKind,
79 LitToConstInput, ScalarInt, SimdAlign, UnevaluatedConst, ValTree, ValTreeKindExt, Value,
80 const_lit_matches_ty,
81};
82pub use self::context::{
83 CtxtInterners, CurrentGcx, Feed, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls,
84};
85pub use self::fold::*;
86pub use self::instance::{Instance, InstanceKind, ReifyReason, UnusedGenericParams};
87pub use self::list::{List, ListWithCachedTypeInfo};
88pub use self::opaque_types::OpaqueTypeKey;
89pub use self::pattern::{Pattern, PatternKind};
90pub use self::predicate::{
91 AliasTerm, ArgOutlivesPredicate, Clause, ClauseKind, CoercePredicate, ExistentialPredicate,
92 ExistentialPredicateStableCmpExt, ExistentialProjection, ExistentialTraitRef,
93 HostEffectPredicate, NormalizesTo, OutlivesPredicate, PolyCoercePredicate,
94 PolyExistentialPredicate, PolyExistentialProjection, PolyExistentialTraitRef,
95 PolyProjectionPredicate, PolyRegionOutlivesPredicate, PolySubtypePredicate, PolyTraitPredicate,
96 PolyTraitRef, PolyTypeOutlivesPredicate, Predicate, PredicateKind, ProjectionPredicate,
97 RegionOutlivesPredicate, SubtypePredicate, TraitPredicate, TraitRef, TypeOutlivesPredicate,
98};
99pub use self::region::{
100 EarlyParamRegion, LateParamRegion, LateParamRegionKind, Region, RegionKind, RegionVid,
101};
102pub use self::sty::{
103 AliasTy, Article, Binder, BoundConst, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind,
104 BoundVariableKind, CanonicalPolyFnSig, CoroutineArgsExt, EarlyBinder, FnSig, InlineConstArgs,
105 InlineConstArgsParts, ParamConst, ParamTy, PlaceholderConst, PlaceholderRegion,
106 PlaceholderType, PolyFnSig, TyKind, TypeAndMut, TypingMode, UpvarArgs,
107};
108pub use self::trait_def::TraitDef;
109pub use self::typeck_results::{
110 CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity,
111 Rust2024IncompatiblePatInfo, TypeckResults, UserType, UserTypeAnnotationIndex, UserTypeKind,
112};
113use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
114use crate::ich::StableHashingContext;
115use crate::metadata::{AmbigModChild, ModChild};
116use crate::middle::privacy::EffectiveVisibilities;
117use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, SourceInfo};
118use crate::query::{IntoQueryParam, Providers};
119use crate::ty;
120use crate::ty::codec::{TyDecoder, TyEncoder};
121pub use crate::ty::diagnostics::*;
122use crate::ty::fast_reject::SimplifiedType;
123use crate::ty::layout::LayoutError;
124use crate::ty::util::Discr;
125use crate::ty::walk::TypeWalker;
126
127pub mod abstract_const;
128pub mod adjustment;
129pub mod cast;
130pub mod codec;
131pub mod error;
132pub mod fast_reject;
133pub mod inhabitedness;
134pub mod layout;
135pub mod normalize_erasing_regions;
136pub mod offload_meta;
137pub mod pattern;
138pub mod print;
139pub mod relate;
140pub mod significant_drop_order;
141pub mod trait_def;
142pub mod util;
143pub mod vtable;
144
145mod adt;
146mod assoc;
147mod closure;
148mod consts;
149mod context;
150mod diagnostics;
151mod elaborate_impl;
152mod erase_regions;
153mod fold;
154mod generic_args;
155mod generics;
156mod impls_ty;
157mod instance;
158mod intrinsic;
159mod list;
160mod opaque_types;
161mod predicate;
162mod region;
163mod structural_impls;
164#[allow(hidden_glob_reexports)]
165mod sty;
166mod typeck_results;
167mod visit;
168
169#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ResolverGlobalCtxt {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["visibilities_for_hashing", "expn_that_defined",
"effective_visibilities", "extern_crate_map",
"maybe_unused_trait_imports", "module_children",
"ambig_module_children", "glob_map", "main_def",
"trait_impls", "proc_macros",
"confused_type_with_std_module", "doc_link_resolutions",
"doc_link_traits_in_scope", "all_macro_rules",
"stripped_cfg_items"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.visibilities_for_hashing, &self.expn_that_defined,
&self.effective_visibilities, &self.extern_crate_map,
&self.maybe_unused_trait_imports, &self.module_children,
&self.ambig_module_children, &self.glob_map, &self.main_def,
&self.trait_impls, &self.proc_macros,
&self.confused_type_with_std_module,
&self.doc_link_resolutions, &self.doc_link_traits_in_scope,
&self.all_macro_rules, &&self.stripped_cfg_items];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"ResolverGlobalCtxt", names, values)
}
}Debug, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for ResolverGlobalCtxt {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ResolverGlobalCtxt {
visibilities_for_hashing: ref __binding_0,
expn_that_defined: ref __binding_1,
effective_visibilities: ref __binding_2,
extern_crate_map: ref __binding_3,
maybe_unused_trait_imports: ref __binding_4,
module_children: ref __binding_5,
ambig_module_children: ref __binding_6,
glob_map: ref __binding_7,
main_def: ref __binding_8,
trait_impls: ref __binding_9,
proc_macros: ref __binding_10,
confused_type_with_std_module: ref __binding_11,
doc_link_resolutions: ref __binding_12,
doc_link_traits_in_scope: ref __binding_13,
all_macro_rules: ref __binding_14,
stripped_cfg_items: ref __binding_15 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
{ __binding_7.hash_stable(__hcx, __hasher); }
{ __binding_8.hash_stable(__hcx, __hasher); }
{ __binding_9.hash_stable(__hcx, __hasher); }
{ __binding_10.hash_stable(__hcx, __hasher); }
{ __binding_11.hash_stable(__hcx, __hasher); }
{ __binding_12.hash_stable(__hcx, __hasher); }
{ __binding_13.hash_stable(__hcx, __hasher); }
{ __binding_14.hash_stable(__hcx, __hasher); }
{ __binding_15.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
172pub struct ResolverGlobalCtxt {
173 pub visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
174 pub expn_that_defined: UnordMap<LocalDefId, ExpnId>,
176 pub effective_visibilities: EffectiveVisibilities,
177 pub extern_crate_map: UnordMap<LocalDefId, CrateNum>,
178 pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
179 pub module_children: LocalDefIdMap<Vec<ModChild>>,
180 pub ambig_module_children: LocalDefIdMap<Vec<AmbigModChild>>,
181 pub glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
182 pub main_def: Option<MainDefinition>,
183 pub trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
184 pub proc_macros: Vec<LocalDefId>,
187 pub confused_type_with_std_module: FxIndexMap<Span, Span>,
190 pub doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
191 pub doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>,
192 pub all_macro_rules: UnordSet<Symbol>,
193 pub stripped_cfg_items: Vec<StrippedCfgItem>,
194}
195
196#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ResolverAstLowering {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["partial_res_map", "import_res_map", "label_res_map",
"lifetimes_res_map", "extra_lifetime_params_map",
"next_node_id", "node_id_to_def_id", "trait_map",
"lifetime_elision_allowed", "lint_buffer",
"delegation_fn_sigs", "delegation_infos"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.partial_res_map, &self.import_res_map,
&self.label_res_map, &self.lifetimes_res_map,
&self.extra_lifetime_params_map, &self.next_node_id,
&self.node_id_to_def_id, &self.trait_map,
&self.lifetime_elision_allowed, &self.lint_buffer,
&self.delegation_fn_sigs, &&self.delegation_infos];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"ResolverAstLowering", names, values)
}
}Debug)]
199pub struct ResolverAstLowering {
200 pub partial_res_map: NodeMap<hir::def::PartialRes>,
202 pub import_res_map: NodeMap<hir::def::PerNS<Option<Res<ast::NodeId>>>>,
204 pub label_res_map: NodeMap<ast::NodeId>,
206 pub lifetimes_res_map: NodeMap<LifetimeRes>,
208 pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, LifetimeRes)>>,
210
211 pub next_node_id: ast::NodeId,
212
213 pub node_id_to_def_id: NodeMap<LocalDefId>,
214
215 pub trait_map: NodeMap<Vec<hir::TraitCandidate>>,
216 pub lifetime_elision_allowed: FxHashSet<ast::NodeId>,
218
219 pub lint_buffer: Steal<LintBuffer>,
221
222 pub delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>,
224 pub delegation_infos: LocalDefIdMap<DelegationInfo>,
226}
227
228bitflags::bitflags! {
229 #[derive(#[automatically_derived]
impl ::core::clone::Clone for DelegationFnSigAttrs {
#[inline]
fn clone(&self) -> DelegationFnSigAttrs {
let _:
::core::clone::AssertParamIsClone<<DelegationFnSigAttrs as
::bitflags::__private::PublicFlags>::Internal>;
*self
}
}
impl DelegationFnSigAttrs {
#[allow(deprecated, non_upper_case_globals,)]
pub const TARGET_FEATURE: Self = Self::from_bits_retain(1 << 0);
#[allow(deprecated, non_upper_case_globals,)]
pub const MUST_USE: Self = Self::from_bits_retain(1 << 1);
}
impl ::bitflags::Flags for DelegationFnSigAttrs {
const FLAGS: &'static [::bitflags::Flag<DelegationFnSigAttrs>] =
&[{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("TARGET_FEATURE",
DelegationFnSigAttrs::TARGET_FEATURE)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("MUST_USE",
DelegationFnSigAttrs::MUST_USE)
}];
type Bits = u8;
fn bits(&self) -> u8 { DelegationFnSigAttrs::bits(self) }
fn from_bits_retain(bits: u8) -> DelegationFnSigAttrs {
DelegationFnSigAttrs::from_bits_retain(bits)
}
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: indexing_slicing, clippy :: same_name_method,
clippy :: iter_without_into_iter,)]
const _: () =
{
#[repr(transparent)]
pub struct InternalBitFlags(u8);
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
#[automatically_derived]
impl ::core::clone::Clone for InternalBitFlags {
#[inline]
fn clone(&self) -> InternalBitFlags {
let _: ::core::clone::AssertParamIsClone<u8>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for InternalBitFlags { }
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
#[automatically_derived]
impl ::core::cmp::PartialEq for InternalBitFlags {
#[inline]
fn eq(&self, other: &InternalBitFlags) -> bool {
self.0 == other.0
}
}
#[automatically_derived]
impl ::core::cmp::Eq for InternalBitFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u8>;
}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for InternalBitFlags {
#[inline]
fn partial_cmp(&self, other: &InternalBitFlags)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
}
}
#[automatically_derived]
impl ::core::cmp::Ord for InternalBitFlags {
#[inline]
fn cmp(&self, other: &InternalBitFlags) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}
#[automatically_derived]
impl ::core::hash::Hash for InternalBitFlags {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
impl ::bitflags::__private::PublicFlags for DelegationFnSigAttrs {
type Primitive = u8;
type Internal = InternalBitFlags;
}
impl ::bitflags::__private::core::default::Default for
InternalBitFlags {
#[inline]
fn default() -> Self { InternalBitFlags::empty() }
}
impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
if self.is_empty() {
f.write_fmt(format_args!("{0:#x}",
<u8 as ::bitflags::Bits>::EMPTY))
} else {
::bitflags::__private::core::fmt::Display::fmt(self, f)
}
}
}
impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
::bitflags::parser::to_writer(&DelegationFnSigAttrs(*self), f)
}
}
impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
type Err = ::bitflags::parser::ParseError;
fn from_str(s: &str)
->
::bitflags::__private::core::result::Result<Self,
Self::Err> {
::bitflags::parser::from_str::<DelegationFnSigAttrs>(s).map(|flags|
flags.0)
}
}
impl ::bitflags::__private::core::convert::AsRef<u8> for
InternalBitFlags {
fn as_ref(&self) -> &u8 { &self.0 }
}
impl ::bitflags::__private::core::convert::From<u8> for
InternalBitFlags {
fn from(bits: u8) -> Self { Self::from_bits_retain(bits) }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl InternalBitFlags {
#[inline]
pub const fn empty() -> Self {
Self(<u8 as ::bitflags::Bits>::EMPTY)
}
#[inline]
pub const fn all() -> Self {
let mut truncated = <u8 as ::bitflags::Bits>::EMPTY;
let mut i = 0;
{
{
let flag =
<DelegationFnSigAttrs as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DelegationFnSigAttrs as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
let _ = i;
Self(truncated)
}
#[inline]
pub const fn bits(&self) -> u8 { self.0 }
#[inline]
pub const fn from_bits(bits: u8)
-> ::bitflags::__private::core::option::Option<Self> {
let truncated = Self::from_bits_truncate(bits).0;
if truncated == bits {
::bitflags::__private::core::option::Option::Some(Self(bits))
} else { ::bitflags::__private::core::option::Option::None }
}
#[inline]
pub const fn from_bits_truncate(bits: u8) -> Self {
Self(bits & Self::all().0)
}
#[inline]
pub const fn from_bits_retain(bits: u8) -> Self { Self(bits) }
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
{
if name == "TARGET_FEATURE" {
return ::bitflags::__private::core::option::Option::Some(Self(DelegationFnSigAttrs::TARGET_FEATURE.bits()));
}
};
;
{
if name == "MUST_USE" {
return ::bitflags::__private::core::option::Option::Some(Self(DelegationFnSigAttrs::MUST_USE.bits()));
}
};
;
let _ = name;
::bitflags::__private::core::option::Option::None
}
#[inline]
pub const fn is_empty(&self) -> bool {
self.0 == <u8 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn is_all(&self) -> bool {
Self::all().0 | self.0 == self.0
}
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0 & other.0 != <u8 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0 & other.0 == other.0
}
#[inline]
pub fn insert(&mut self, other: Self) {
*self = Self(self.0).union(other);
}
#[inline]
pub fn remove(&mut self, other: Self) {
*self = Self(self.0).difference(other);
}
#[inline]
pub fn toggle(&mut self, other: Self) {
*self = Self(self.0).symmetric_difference(other);
}
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
if value { self.insert(other); } else { self.remove(other); }
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0 & other.0)
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0 & !other.0)
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0 ^ other.0)
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self::from_bits_truncate(!self.0)
}
}
impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for InternalBitFlags {
type Output = Self;
#[inline]
fn bitor(self, other: InternalBitFlags) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
InternalBitFlags {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
InternalBitFlags {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
InternalBitFlags {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
{
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
InternalBitFlags {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<InternalBitFlags>
for InternalBitFlags {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl InternalBitFlags {
#[inline]
pub const fn iter(&self)
-> ::bitflags::iter::Iter<DelegationFnSigAttrs> {
::bitflags::iter::Iter::__private_const_new(<DelegationFnSigAttrs
as ::bitflags::Flags>::FLAGS,
DelegationFnSigAttrs::from_bits_retain(self.bits()),
DelegationFnSigAttrs::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<DelegationFnSigAttrs> {
::bitflags::iter::IterNames::__private_const_new(<DelegationFnSigAttrs
as ::bitflags::Flags>::FLAGS,
DelegationFnSigAttrs::from_bits_retain(self.bits()),
DelegationFnSigAttrs::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
InternalBitFlags {
type Item = DelegationFnSigAttrs;
type IntoIter = ::bitflags::iter::Iter<DelegationFnSigAttrs>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
impl InternalBitFlags {
#[inline]
pub fn bits_mut(&mut self) -> &mut u8 { &mut self.0 }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl DelegationFnSigAttrs {
#[inline]
pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
#[inline]
pub const fn all() -> Self { Self(InternalBitFlags::all()) }
#[inline]
pub const fn bits(&self) -> u8 { self.0.bits() }
#[inline]
pub const fn from_bits(bits: u8)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_bits(bits) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
#[inline]
pub const fn from_bits_truncate(bits: u8) -> Self {
Self(InternalBitFlags::from_bits_truncate(bits))
}
#[inline]
pub const fn from_bits_retain(bits: u8) -> Self {
Self(InternalBitFlags::from_bits_retain(bits))
}
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_name(name) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
#[inline]
pub const fn is_empty(&self) -> bool { self.0.is_empty() }
#[inline]
pub const fn is_all(&self) -> bool { self.0.is_all() }
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0.intersects(other.0)
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0.contains(other.0)
}
#[inline]
pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
#[inline]
pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
#[inline]
pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
self.0.set(other.0, value)
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0.intersection(other.0))
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0.union(other.0))
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0.difference(other.0))
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0.symmetric_difference(other.0))
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self(self.0.complement())
}
}
impl ::bitflags::__private::core::fmt::Binary for DelegationFnSigAttrs
{
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for DelegationFnSigAttrs
{
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for
DelegationFnSigAttrs {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for
DelegationFnSigAttrs {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for DelegationFnSigAttrs
{
type Output = Self;
#[inline]
fn bitor(self, other: DelegationFnSigAttrs) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
DelegationFnSigAttrs {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for DelegationFnSigAttrs
{
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
DelegationFnSigAttrs {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for DelegationFnSigAttrs
{
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
DelegationFnSigAttrs {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for DelegationFnSigAttrs {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for
DelegationFnSigAttrs {
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for DelegationFnSigAttrs {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<DelegationFnSigAttrs>
for DelegationFnSigAttrs {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<DelegationFnSigAttrs>
for DelegationFnSigAttrs {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl DelegationFnSigAttrs {
#[inline]
pub const fn iter(&self)
-> ::bitflags::iter::Iter<DelegationFnSigAttrs> {
::bitflags::iter::Iter::__private_const_new(<DelegationFnSigAttrs
as ::bitflags::Flags>::FLAGS,
DelegationFnSigAttrs::from_bits_retain(self.bits()),
DelegationFnSigAttrs::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<DelegationFnSigAttrs> {
::bitflags::iter::IterNames::__private_const_new(<DelegationFnSigAttrs
as ::bitflags::Flags>::FLAGS,
DelegationFnSigAttrs::from_bits_retain(self.bits()),
DelegationFnSigAttrs::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
DelegationFnSigAttrs {
type Item = DelegationFnSigAttrs;
type IntoIter = ::bitflags::iter::Iter<DelegationFnSigAttrs>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
};Clone, #[automatically_derived]
impl ::core::marker::Copy for DelegationFnSigAttrs { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for DelegationFnSigAttrs {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DelegationFnSigAttrs", &&self.0)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for DelegationFnSigAttrs {
#[inline]
fn eq(&self, other: &DelegationFnSigAttrs) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DelegationFnSigAttrs {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _:
::core::cmp::AssertParamIsEq<<DelegationFnSigAttrs as
::bitflags::__private::PublicFlags>::Internal>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DelegationFnSigAttrs {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}Hash)]
230 pub struct DelegationFnSigAttrs: u8 {
231 const TARGET_FEATURE = 1 << 0;
232 const MUST_USE = 1 << 1;
233 }
234}
235
236pub const DELEGATION_INHERIT_ATTRS_START: DelegationFnSigAttrs = DelegationFnSigAttrs::MUST_USE;
237
238#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationInfo {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DelegationInfo", "resolution_node", &self.resolution_node,
"attrs", &&self.attrs)
}
}Debug)]
239pub struct DelegationInfo {
240 pub resolution_node: ast::NodeId,
243 pub attrs: DelegationAttrs,
244}
245
246#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationAttrs {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DelegationAttrs", "flags", &self.flags, "to_inherit",
&&self.to_inherit)
}
}Debug)]
247pub struct DelegationAttrs {
248 pub flags: DelegationFnSigAttrs,
249 pub to_inherit: AttrVec,
250}
251
252#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationFnSig {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f,
"DelegationFnSig", "header", &self.header, "param_count",
&self.param_count, "has_self", &self.has_self, "c_variadic",
&self.c_variadic, "attrs", &&self.attrs)
}
}Debug)]
253pub struct DelegationFnSig {
254 pub header: ast::FnHeader,
255 pub param_count: usize,
256 pub has_self: bool,
257 pub c_variadic: bool,
258 pub attrs: DelegationAttrs,
259}
260
261#[derive(#[automatically_derived]
impl ::core::clone::Clone for MainDefinition {
#[inline]
fn clone(&self) -> MainDefinition {
let _: ::core::clone::AssertParamIsClone<Res<ast::NodeId>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Span>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MainDefinition { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for MainDefinition {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"MainDefinition", "res", &self.res, "is_import", &self.is_import,
"span", &&self.span)
}
}Debug, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for MainDefinition {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
MainDefinition {
res: ref __binding_0,
is_import: ref __binding_1,
span: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
262pub struct MainDefinition {
263 pub res: Res<ast::NodeId>,
264 pub is_import: bool,
265 pub span: Span,
266}
267
268impl MainDefinition {
269 pub fn opt_fn_def_id(self) -> Option<DefId> {
270 if let Res::Def(DefKind::Fn, def_id) = self.res { Some(def_id) } else { None }
271 }
272}
273
274#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for ImplTraitHeader<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for ImplTraitHeader<'tcx> {
#[inline]
fn clone(&self) -> ImplTraitHeader<'tcx> {
let _:
::core::clone::AssertParamIsClone<ty::EarlyBinder<'tcx,
ty::TraitRef<'tcx>>>;
let _: ::core::clone::AssertParamIsClone<ImplPolarity>;
let _: ::core::clone::AssertParamIsClone<hir::Safety>;
let _: ::core::clone::AssertParamIsClone<hir::Constness>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ImplTraitHeader<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"ImplTraitHeader", "trait_ref", &self.trait_ref, "polarity",
&self.polarity, "safety", &self.safety, "constness",
&&self.constness)
}
}Debug, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for ImplTraitHeader<'tcx> {
fn encode(&self, __encoder: &mut __E) {
match *self {
ImplTraitHeader {
trait_ref: ref __binding_0,
polarity: ref __binding_1,
safety: ref __binding_2,
constness: ref __binding_3 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for ImplTraitHeader<'tcx> {
fn decode(__decoder: &mut __D) -> Self {
ImplTraitHeader {
trait_ref: ::rustc_serialize::Decodable::decode(__decoder),
polarity: ::rustc_serialize::Decodable::decode(__decoder),
safety: ::rustc_serialize::Decodable::decode(__decoder),
constness: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for ImplTraitHeader<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ImplTraitHeader {
trait_ref: ref __binding_0,
polarity: ref __binding_1,
safety: ref __binding_2,
constness: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
275pub struct ImplTraitHeader<'tcx> {
276 pub trait_ref: ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>,
277 pub polarity: ImplPolarity,
278 pub safety: hir::Safety,
279 pub constness: hir::Constness,
280}
281
282#[derive(#[automatically_derived]
impl ::core::marker::Copy for Asyncness { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Asyncness {
#[inline]
fn clone(&self) -> Asyncness { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Asyncness {
#[inline]
fn eq(&self, other: &Asyncness) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Asyncness {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for Asyncness {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for Asyncness {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Asyncness::Yes => { 0usize }
Asyncness::No => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self { Asyncness::Yes => {} Asyncness::No => {} }
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for Asyncness {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Asyncness::Yes }
1usize => { Asyncness::No }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Asyncness`, expected 0..2, actual {0}",
n));
}
}
}
}
};TyDecodable, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for Asyncness {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self { Asyncness::Yes => {} Asyncness::No => {} }
}
}
};HashStable, #[automatically_derived]
impl ::core::fmt::Debug for Asyncness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self { Asyncness::Yes => "Yes", Asyncness::No => "No", })
}
}Debug)]
283#[derive(const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for Asyncness {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
Asyncness::Yes => { Asyncness::Yes }
Asyncness::No => { Asyncness::No }
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
Asyncness::Yes => { Asyncness::Yes }
Asyncness::No => { Asyncness::No }
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for Asyncness {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self { Asyncness::Yes => {} Asyncness::No => {} }
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable, #[automatically_derived]
impl ::core::default::Default for Asyncness {
#[inline]
fn default() -> Asyncness { Self::No }
}Default)]
284pub enum Asyncness {
285 Yes,
286 #[default]
287 No,
288}
289
290impl Asyncness {
291 pub fn is_async(self) -> bool {
292 #[allow(non_exhaustive_omitted_patterns)] match self {
Asyncness::Yes => true,
_ => false,
}matches!(self, Asyncness::Yes)
293 }
294}
295
296#[derive(#[automatically_derived]
impl<Id: ::core::clone::Clone> ::core::clone::Clone for Visibility<Id> {
#[inline]
fn clone(&self) -> Visibility<Id> {
match self {
Visibility::Public => Visibility::Public,
Visibility::Restricted(__self_0) =>
Visibility::Restricted(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl<Id: ::core::fmt::Debug> ::core::fmt::Debug for Visibility<Id> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Visibility::Public =>
::core::fmt::Formatter::write_str(f, "Public"),
Visibility::Restricted(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Restricted", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<Id: ::core::cmp::PartialEq> ::core::cmp::PartialEq for Visibility<Id> {
#[inline]
fn eq(&self, other: &Visibility<Id>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Visibility::Restricted(__self_0),
Visibility::Restricted(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl<Id: ::core::cmp::Eq> ::core::cmp::Eq for Visibility<Id> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Id>;
}
}Eq, #[automatically_derived]
impl<Id: ::core::marker::Copy> ::core::marker::Copy for Visibility<Id> { }Copy, #[automatically_derived]
impl<Id: ::core::hash::Hash> ::core::hash::Hash for Visibility<Id> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
Visibility::Restricted(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, const _: () =
{
impl<Id, __E: ::rustc_span::SpanEncoder>
::rustc_serialize::Encodable<__E> for Visibility<Id> where
Id: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Visibility::Public => { 0usize }
Visibility::Restricted(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Visibility::Public => {}
Visibility::Restricted(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<Id, __D: ::rustc_span::BlobDecoder>
::rustc_serialize::Decodable<__D> for Visibility<Id> where
Id: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Visibility::Public }
1usize => {
Visibility::Restricted(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Visibility`, expected 0..2, actual {0}",
n));
}
}
}
}
};BlobDecodable, const _: () =
{
impl<'__ctx, Id>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for Visibility<Id> where
Id: ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
{
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
Visibility::Public => {}
Visibility::Restricted(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
297pub enum Visibility<Id = LocalDefId> {
298 Public,
300 Restricted(Id),
302}
303
304impl Visibility {
305 pub fn to_string(self, def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
306 match self {
307 ty::Visibility::Restricted(restricted_id) => {
308 if restricted_id.is_top_level_module() {
309 "pub(crate)".to_string()
310 } else if restricted_id == tcx.parent_module_from_def_id(def_id).to_local_def_id() {
311 "pub(self)".to_string()
312 } else {
313 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("pub(in crate{0})",
tcx.def_path(restricted_id.to_def_id()).to_string_no_crate_verbose()))
})format!(
314 "pub(in crate{})",
315 tcx.def_path(restricted_id.to_def_id()).to_string_no_crate_verbose()
316 )
317 }
318 }
319 ty::Visibility::Public => "pub".to_string(),
320 }
321 }
322}
323
324#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for ClosureSizeProfileData<'tcx> {
#[inline]
fn clone(&self) -> ClosureSizeProfileData<'tcx> {
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ClosureSizeProfileData<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"ClosureSizeProfileData", "before_feature_tys",
&self.before_feature_tys, "after_feature_tys",
&&self.after_feature_tys)
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for ClosureSizeProfileData<'tcx> {
#[inline]
fn eq(&self, other: &ClosureSizeProfileData<'tcx>) -> bool {
self.before_feature_tys == other.before_feature_tys &&
self.after_feature_tys == other.after_feature_tys
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for ClosureSizeProfileData<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for ClosureSizeProfileData<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for ClosureSizeProfileData<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.before_feature_tys, state);
::core::hash::Hash::hash(&self.after_feature_tys, state)
}
}Hash, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for ClosureSizeProfileData<'tcx>
{
fn encode(&self, __encoder: &mut __E) {
match *self {
ClosureSizeProfileData {
before_feature_tys: ref __binding_0,
after_feature_tys: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for ClosureSizeProfileData<'tcx>
{
fn decode(__decoder: &mut __D) -> Self {
ClosureSizeProfileData {
before_feature_tys: ::rustc_serialize::Decodable::decode(__decoder),
after_feature_tys: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for ClosureSizeProfileData<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ClosureSizeProfileData {
before_feature_tys: ref __binding_0,
after_feature_tys: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
325#[derive(const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for ClosureSizeProfileData<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
ClosureSizeProfileData {
before_feature_tys: __binding_0,
after_feature_tys: __binding_1 } => {
ClosureSizeProfileData {
before_feature_tys: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
after_feature_tys: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
ClosureSizeProfileData {
before_feature_tys: __binding_0,
after_feature_tys: __binding_1 } => {
ClosureSizeProfileData {
before_feature_tys: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
after_feature_tys: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for ClosureSizeProfileData<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ClosureSizeProfileData {
before_feature_tys: ref __binding_0,
after_feature_tys: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
326pub struct ClosureSizeProfileData<'tcx> {
327 pub before_feature_tys: Ty<'tcx>,
329 pub after_feature_tys: Ty<'tcx>,
331}
332
333impl TyCtxt<'_> {
334 #[inline]
335 pub fn opt_parent(self, id: DefId) -> Option<DefId> {
336 self.def_key(id).parent.map(|index| DefId { index, ..id })
337 }
338
339 #[inline]
340 #[track_caller]
341 pub fn parent(self, id: DefId) -> DefId {
342 match self.opt_parent(id) {
343 Some(id) => id,
344 None => crate::util::bug::bug_fmt(format_args!("{0:?} doesn\'t have a parent", id))bug!("{id:?} doesn't have a parent"),
346 }
347 }
348
349 #[inline]
350 #[track_caller]
351 pub fn opt_local_parent(self, id: LocalDefId) -> Option<LocalDefId> {
352 self.opt_parent(id.to_def_id()).map(DefId::expect_local)
353 }
354
355 #[inline]
356 #[track_caller]
357 pub fn local_parent(self, id: impl Into<LocalDefId>) -> LocalDefId {
358 self.parent(id.into().to_def_id()).expect_local()
359 }
360
361 pub fn is_descendant_of(self, mut descendant: DefId, ancestor: DefId) -> bool {
362 if descendant.krate != ancestor.krate {
363 return false;
364 }
365
366 while descendant != ancestor {
367 match self.opt_parent(descendant) {
368 Some(parent) => descendant = parent,
369 None => return false,
370 }
371 }
372 true
373 }
374}
375
376impl<Id> Visibility<Id> {
377 pub fn is_public(self) -> bool {
378 #[allow(non_exhaustive_omitted_patterns)] match self {
Visibility::Public => true,
_ => false,
}matches!(self, Visibility::Public)
379 }
380
381 pub fn map_id<OutId>(self, f: impl FnOnce(Id) -> OutId) -> Visibility<OutId> {
382 match self {
383 Visibility::Public => Visibility::Public,
384 Visibility::Restricted(id) => Visibility::Restricted(f(id)),
385 }
386 }
387}
388
389impl<Id: Into<DefId>> Visibility<Id> {
390 pub fn to_def_id(self) -> Visibility<DefId> {
391 self.map_id(Into::into)
392 }
393
394 pub fn is_accessible_from(self, module: impl Into<DefId>, tcx: TyCtxt<'_>) -> bool {
396 match self {
397 Visibility::Public => true,
399 Visibility::Restricted(id) => tcx.is_descendant_of(module.into(), id.into()),
400 }
401 }
402
403 pub fn is_at_least(self, vis: Visibility<impl Into<DefId>>, tcx: TyCtxt<'_>) -> bool {
405 match vis {
406 Visibility::Public => self.is_public(),
407 Visibility::Restricted(id) => self.is_accessible_from(id, tcx),
408 }
409 }
410}
411
412impl<Id: Into<DefId> + Copy> Visibility<Id> {
413 pub fn min(self, vis: Visibility<Id>, tcx: TyCtxt<'_>) -> Visibility<Id> {
414 if self.is_at_least(vis, tcx) { vis } else { self }
415 }
416}
417
418impl Visibility<DefId> {
419 pub fn expect_local(self) -> Visibility {
420 self.map_id(|id| id.expect_local())
421 }
422
423 pub fn is_visible_locally(self) -> bool {
425 match self {
426 Visibility::Public => true,
427 Visibility::Restricted(def_id) => def_id.is_local(),
428 }
429 }
430}
431
432#[derive(const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for CrateVariancesMap<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
CrateVariancesMap { variances: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for CrateVariancesMap<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"CrateVariancesMap", "variances", &&self.variances)
}
}Debug)]
439pub struct CrateVariancesMap<'tcx> {
440 pub variances: DefIdMap<&'tcx [ty::Variance]>,
444}
445
446#[derive(#[automatically_derived]
impl ::core::marker::Copy for CReaderCacheKey { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CReaderCacheKey {
#[inline]
fn clone(&self) -> CReaderCacheKey {
let _: ::core::clone::AssertParamIsClone<Option<CrateNum>>;
let _: ::core::clone::AssertParamIsClone<usize>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CReaderCacheKey {
#[inline]
fn eq(&self, other: &CReaderCacheKey) -> bool {
self.cnum == other.cnum && self.pos == other.pos
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CReaderCacheKey {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Option<CrateNum>>;
let _: ::core::cmp::AssertParamIsEq<usize>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for CReaderCacheKey {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.cnum, state);
::core::hash::Hash::hash(&self.pos, state)
}
}Hash)]
449pub struct CReaderCacheKey {
450 pub cnum: Option<CrateNum>,
451 pub pos: usize,
452}
453
454#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for Ty<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for Ty<'tcx> {
#[inline]
fn clone(&self) -> Ty<'tcx> {
let _:
::core::clone::AssertParamIsClone<Interned<'tcx,
WithCachedTypeInfo<TyKind<'tcx>>>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for Ty<'tcx> {
#[inline]
fn eq(&self, other: &Ty<'tcx>) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for Ty<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _:
::core::cmp::AssertParamIsEq<Interned<'tcx,
WithCachedTypeInfo<TyKind<'tcx>>>>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for Ty<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}Hash, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for Ty<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Ty(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
456#[rustc_diagnostic_item = "Ty"]
457#[rustc_pass_by_value]
458pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
459
460impl<'tcx> rustc_type_ir::inherent::IntoKind for Ty<'tcx> {
461 type Kind = TyKind<'tcx>;
462
463 fn kind(self) -> TyKind<'tcx> {
464 *self.kind()
465 }
466}
467
468impl<'tcx> rustc_type_ir::Flags for Ty<'tcx> {
469 fn flags(&self) -> TypeFlags {
470 self.0.flags
471 }
472
473 fn outer_exclusive_binder(&self) -> DebruijnIndex {
474 self.0.outer_exclusive_binder
475 }
476}
477
478#[derive(const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for CratePredicatesMap<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
CratePredicatesMap { predicates: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for CratePredicatesMap<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"CratePredicatesMap", "predicates", &&self.predicates)
}
}Debug)]
485pub struct CratePredicatesMap<'tcx> {
486 pub predicates: DefIdMap<&'tcx [(Clause<'tcx>, Span)]>,
490}
491
492#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for Term<'tcx> {
#[inline]
fn clone(&self) -> Term<'tcx> {
let _: ::core::clone::AssertParamIsClone<NonNull<()>>;
let _:
::core::clone::AssertParamIsClone<PhantomData<(Ty<'tcx>,
Const<'tcx>)>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for Term<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for Term<'tcx> {
#[inline]
fn eq(&self, other: &Term<'tcx>) -> bool {
self.ptr == other.ptr && self.marker == other.marker
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for Term<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<NonNull<()>>;
let _:
::core::cmp::AssertParamIsEq<PhantomData<(Ty<'tcx>,
Const<'tcx>)>>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialOrd for Term<'tcx> {
#[inline]
fn partial_cmp(&self, other: &Term<'tcx>)
-> ::core::option::Option<::core::cmp::Ordering> {
match ::core::cmp::PartialOrd::partial_cmp(&self.ptr, &other.ptr) {
::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
::core::cmp::PartialOrd::partial_cmp(&self.marker,
&other.marker),
cmp => cmp,
}
}
}PartialOrd, #[automatically_derived]
impl<'tcx> ::core::cmp::Ord for Term<'tcx> {
#[inline]
fn cmp(&self, other: &Term<'tcx>) -> ::core::cmp::Ordering {
match ::core::cmp::Ord::cmp(&self.ptr, &other.ptr) {
::core::cmp::Ordering::Equal =>
::core::cmp::Ord::cmp(&self.marker, &other.marker),
cmp => cmp,
}
}
}Ord, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for Term<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.ptr, state);
::core::hash::Hash::hash(&self.marker, state)
}
}Hash)]
493pub struct Term<'tcx> {
494 ptr: NonNull<()>,
495 marker: PhantomData<(Ty<'tcx>, Const<'tcx>)>,
496}
497
498impl<'tcx> rustc_type_ir::inherent::Term<TyCtxt<'tcx>> for Term<'tcx> {}
499
500impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> {
501 type Kind = TermKind<'tcx>;
502
503 fn kind(self) -> Self::Kind {
504 self.kind()
505 }
506}
507
508unsafe impl<'tcx> rustc_data_structures::sync::DynSend for Term<'tcx> where
509 &'tcx (Ty<'tcx>, Const<'tcx>): rustc_data_structures::sync::DynSend
510{
511}
512unsafe impl<'tcx> rustc_data_structures::sync::DynSync for Term<'tcx> where
513 &'tcx (Ty<'tcx>, Const<'tcx>): rustc_data_structures::sync::DynSync
514{
515}
516unsafe impl<'tcx> Send for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Send {}
517unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync {}
518
519impl Debug for Term<'_> {
520 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
521 match self.kind() {
522 TermKind::Ty(ty) => f.write_fmt(format_args!("Term::Ty({0:?})", ty))write!(f, "Term::Ty({ty:?})"),
523 TermKind::Const(ct) => f.write_fmt(format_args!("Term::Const({0:?})", ct))write!(f, "Term::Const({ct:?})"),
524 }
525 }
526}
527
528impl<'tcx> From<Ty<'tcx>> for Term<'tcx> {
529 fn from(ty: Ty<'tcx>) -> Self {
530 TermKind::Ty(ty).pack()
531 }
532}
533
534impl<'tcx> From<Const<'tcx>> for Term<'tcx> {
535 fn from(c: Const<'tcx>) -> Self {
536 TermKind::Const(c).pack()
537 }
538}
539
540impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Term<'tcx> {
541 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
542 self.kind().hash_stable(hcx, hasher);
543 }
544}
545
546impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
547 fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
548 self,
549 folder: &mut F,
550 ) -> Result<Self, F::Error> {
551 match self.kind() {
552 ty::TermKind::Ty(ty) => ty.try_fold_with(folder).map(Into::into),
553 ty::TermKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
554 }
555 }
556
557 fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
558 match self.kind() {
559 ty::TermKind::Ty(ty) => ty.fold_with(folder).into(),
560 ty::TermKind::Const(ct) => ct.fold_with(folder).into(),
561 }
562 }
563}
564
565impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
566 fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
567 match self.kind() {
568 ty::TermKind::Ty(ty) => ty.visit_with(visitor),
569 ty::TermKind::Const(ct) => ct.visit_with(visitor),
570 }
571 }
572}
573
574impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Term<'tcx> {
575 fn encode(&self, e: &mut E) {
576 self.kind().encode(e)
577 }
578}
579
580impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Term<'tcx> {
581 fn decode(d: &mut D) -> Self {
582 let res: TermKind<'tcx> = Decodable::decode(d);
583 res.pack()
584 }
585}
586
587impl<'tcx> Term<'tcx> {
588 #[inline]
589 pub fn kind(self) -> TermKind<'tcx> {
590 let ptr =
591 unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
592 unsafe {
596 match self.ptr.addr().get() & TAG_MASK {
597 TYPE_TAG => TermKind::Ty(Ty(Interned::new_unchecked(
598 ptr.cast::<WithCachedTypeInfo<ty::TyKind<'tcx>>>().as_ref(),
599 ))),
600 CONST_TAG => TermKind::Const(ty::Const(Interned::new_unchecked(
601 ptr.cast::<WithCachedTypeInfo<ty::ConstKind<'tcx>>>().as_ref(),
602 ))),
603 _ => core::intrinsics::unreachable(),
604 }
605 }
606 }
607
608 pub fn as_type(&self) -> Option<Ty<'tcx>> {
609 if let TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
610 }
611
612 pub fn expect_type(&self) -> Ty<'tcx> {
613 self.as_type().expect("expected a type, but found a const")
614 }
615
616 pub fn as_const(&self) -> Option<Const<'tcx>> {
617 if let TermKind::Const(c) = self.kind() { Some(c) } else { None }
618 }
619
620 pub fn expect_const(&self) -> Const<'tcx> {
621 self.as_const().expect("expected a const, but found a type")
622 }
623
624 pub fn into_arg(self) -> GenericArg<'tcx> {
625 match self.kind() {
626 TermKind::Ty(ty) => ty.into(),
627 TermKind::Const(c) => c.into(),
628 }
629 }
630
631 pub fn to_alias_term(self) -> Option<AliasTerm<'tcx>> {
632 match self.kind() {
633 TermKind::Ty(ty) => match *ty.kind() {
634 ty::Alias(_kind, alias_ty) => Some(alias_ty.into()),
635 _ => None,
636 },
637 TermKind::Const(ct) => match ct.kind() {
638 ConstKind::Unevaluated(uv) => Some(uv.into()),
639 _ => None,
640 },
641 }
642 }
643
644 pub fn is_infer(&self) -> bool {
645 match self.kind() {
646 TermKind::Ty(ty) => ty.is_ty_var(),
647 TermKind::Const(ct) => ct.is_ct_infer(),
648 }
649 }
650
651 pub fn is_trivially_wf(&self, tcx: TyCtxt<'tcx>) -> bool {
652 match self.kind() {
653 TermKind::Ty(ty) => ty.is_trivially_wf(tcx),
654 TermKind::Const(ct) => ct.is_trivially_wf(),
655 }
656 }
657
658 pub fn walk(self) -> TypeWalker<TyCtxt<'tcx>> {
669 TypeWalker::new(self.into())
670 }
671}
672
673const TAG_MASK: usize = 0b11;
674const TYPE_TAG: usize = 0b00;
675const CONST_TAG: usize = 0b01;
676
677impl<'tcx> TermKindPackExt<'tcx> for TermKind<'tcx> {
#[inline]
fn pack(self) -> Term<'tcx> {
let (tag, ptr) =
match self {
TermKind::Ty(ty) => {
match (&(align_of_val(&*ty.0.0) & TAG_MASK), &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);
}
}
};
(TYPE_TAG, NonNull::from(ty.0.0).cast())
}
TermKind::Const(ct) => {
match (&(align_of_val(&*ct.0.0) & TAG_MASK), &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);
}
}
};
(CONST_TAG, NonNull::from(ct.0.0).cast())
}
};
Term { ptr: ptr.map_addr(|addr| addr | tag), marker: PhantomData }
}
}#[extension(pub trait TermKindPackExt<'tcx>)]
678impl<'tcx> TermKind<'tcx> {
679 #[inline]
680 fn pack(self) -> Term<'tcx> {
681 let (tag, ptr) = match self {
682 TermKind::Ty(ty) => {
683 assert_eq!(align_of_val(&*ty.0.0) & TAG_MASK, 0);
685 (TYPE_TAG, NonNull::from(ty.0.0).cast())
686 }
687 TermKind::Const(ct) => {
688 assert_eq!(align_of_val(&*ct.0.0) & TAG_MASK, 0);
690 (CONST_TAG, NonNull::from(ct.0.0).cast())
691 }
692 };
693
694 Term { ptr: ptr.map_addr(|addr| addr | tag), marker: PhantomData }
695 }
696}
697
698#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for InstantiatedPredicates<'tcx> {
#[inline]
fn clone(&self) -> InstantiatedPredicates<'tcx> {
InstantiatedPredicates {
predicates: ::core::clone::Clone::clone(&self.predicates),
spans: ::core::clone::Clone::clone(&self.spans),
}
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for InstantiatedPredicates<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"InstantiatedPredicates", "predicates", &self.predicates, "spans",
&&self.spans)
}
}Debug, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for InstantiatedPredicates<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
InstantiatedPredicates {
predicates: __binding_0, spans: __binding_1 } => {
InstantiatedPredicates {
predicates: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
spans: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
InstantiatedPredicates {
predicates: __binding_0, spans: __binding_1 } => {
InstantiatedPredicates {
predicates: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
spans: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for InstantiatedPredicates<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
InstantiatedPredicates {
predicates: ref __binding_0, spans: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
718pub struct InstantiatedPredicates<'tcx> {
719 pub predicates: Vec<Clause<'tcx>>,
720 pub spans: Vec<Span>,
721}
722
723impl<'tcx> InstantiatedPredicates<'tcx> {
724 pub fn empty() -> InstantiatedPredicates<'tcx> {
725 InstantiatedPredicates { predicates: ::alloc::vec::Vec::new()vec![], spans: ::alloc::vec::Vec::new()vec![] }
726 }
727
728 pub fn is_empty(&self) -> bool {
729 self.predicates.is_empty()
730 }
731
732 pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter {
733 self.into_iter()
734 }
735}
736
737impl<'tcx> IntoIterator for InstantiatedPredicates<'tcx> {
738 type Item = (Clause<'tcx>, Span);
739
740 type IntoIter = std::iter::Zip<std::vec::IntoIter<Clause<'tcx>>, std::vec::IntoIter<Span>>;
741
742 fn into_iter(self) -> Self::IntoIter {
743 if true {
match (&self.predicates.len(), &self.spans.len()) {
(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);
}
}
};
};debug_assert_eq!(self.predicates.len(), self.spans.len());
744 std::iter::zip(self.predicates, self.spans)
745 }
746}
747
748impl<'a, 'tcx> IntoIterator for &'a InstantiatedPredicates<'tcx> {
749 type Item = (Clause<'tcx>, Span);
750
751 type IntoIter = std::iter::Zip<
752 std::iter::Copied<std::slice::Iter<'a, Clause<'tcx>>>,
753 std::iter::Copied<std::slice::Iter<'a, Span>>,
754 >;
755
756 fn into_iter(self) -> Self::IntoIter {
757 if true {
match (&self.predicates.len(), &self.spans.len()) {
(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);
}
}
};
};debug_assert_eq!(self.predicates.len(), self.spans.len());
758 std::iter::zip(self.predicates.iter().copied(), self.spans.iter().copied())
759 }
760}
761
762#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for ProvisionalHiddenType<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for ProvisionalHiddenType<'tcx> {
#[inline]
fn clone(&self) -> ProvisionalHiddenType<'tcx> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ProvisionalHiddenType<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"ProvisionalHiddenType", "span", &self.span, "ty", &&self.ty)
}
}Debug, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for ProvisionalHiddenType<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
ProvisionalHiddenType { span: __binding_0, ty: __binding_1 }
=> {
ProvisionalHiddenType {
span: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
ty: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
ProvisionalHiddenType { span: __binding_0, ty: __binding_1 }
=> {
ProvisionalHiddenType {
span: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
ty: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for ProvisionalHiddenType<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ProvisionalHiddenType {
span: ref __binding_0, ty: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for ProvisionalHiddenType<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ProvisionalHiddenType {
span: ref __binding_0, ty: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for ProvisionalHiddenType<'tcx>
{
fn encode(&self, __encoder: &mut __E) {
match *self {
ProvisionalHiddenType {
span: ref __binding_0, ty: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for ProvisionalHiddenType<'tcx>
{
fn decode(__decoder: &mut __D) -> Self {
ProvisionalHiddenType {
span: ::rustc_serialize::Decodable::decode(__decoder),
ty: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable)]
763pub struct ProvisionalHiddenType<'tcx> {
764 pub span: Span,
778
779 pub ty: Ty<'tcx>,
792}
793
794#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DefiningScopeKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DefiningScopeKind::HirTypeck => "HirTypeck",
DefiningScopeKind::MirBorrowck => "MirBorrowck",
})
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for DefiningScopeKind {
#[inline]
fn clone(&self) -> DefiningScopeKind { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DefiningScopeKind { }Copy)]
796pub enum DefiningScopeKind {
797 HirTypeck,
802 MirBorrowck,
803}
804
805impl<'tcx> ProvisionalHiddenType<'tcx> {
806 pub fn new_error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> ProvisionalHiddenType<'tcx> {
807 ProvisionalHiddenType { span: DUMMY_SP, ty: Ty::new_error(tcx, guar) }
808 }
809
810 pub fn build_mismatch_error(
811 &self,
812 other: &Self,
813 tcx: TyCtxt<'tcx>,
814 ) -> Result<Diag<'tcx>, ErrorGuaranteed> {
815 (self.ty, other.ty).error_reported()?;
816 let sub_diag = if self.span == other.span {
818 TypeMismatchReason::ConflictType { span: self.span }
819 } else {
820 TypeMismatchReason::PreviousUse { span: self.span }
821 };
822 Ok(tcx.dcx().create_err(OpaqueHiddenTypeMismatch {
823 self_ty: self.ty,
824 other_ty: other.ty,
825 other_span: other.span,
826 sub: sub_diag,
827 }))
828 }
829
830 x;#[instrument(level = "debug", skip(tcx), ret)]
831 pub fn remap_generic_params_to_declaration_params(
832 self,
833 opaque_type_key: OpaqueTypeKey<'tcx>,
834 tcx: TyCtxt<'tcx>,
835 defining_scope_kind: DefiningScopeKind,
836 ) -> DefinitionSiteHiddenType<'tcx> {
837 let OpaqueTypeKey { def_id, args } = opaque_type_key;
838
839 let id_args = GenericArgs::identity_for_item(tcx, def_id);
846 debug!(?id_args);
847
848 let map = args.iter().zip(id_args).collect();
852 debug!("map = {:#?}", map);
853
854 let ty = match defining_scope_kind {
860 DefiningScopeKind::HirTypeck => {
861 fold_regions(tcx, self.ty, |_, _| tcx.lifetimes.re_erased)
862 }
863 DefiningScopeKind::MirBorrowck => self.ty,
864 };
865 let result_ty = ty.fold_with(&mut opaque_types::ReverseMapper::new(tcx, map, self.span));
866 if cfg!(debug_assertions) && matches!(defining_scope_kind, DefiningScopeKind::HirTypeck) {
867 assert_eq!(result_ty, fold_regions(tcx, result_ty, |_, _| tcx.lifetimes.re_erased));
868 }
869 DefinitionSiteHiddenType { span: self.span, ty: ty::EarlyBinder::bind(result_ty) }
870 }
871}
872
873#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for DefinitionSiteHiddenType<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for DefinitionSiteHiddenType<'tcx> {
#[inline]
fn clone(&self) -> DefinitionSiteHiddenType<'tcx> {
let _: ::core::clone::AssertParamIsClone<Span>;
let _:
::core::clone::AssertParamIsClone<ty::EarlyBinder<'tcx,
Ty<'tcx>>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for DefinitionSiteHiddenType<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DefinitionSiteHiddenType", "span", &self.span, "ty", &&self.ty)
}
}Debug, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for DefinitionSiteHiddenType<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
DefinitionSiteHiddenType {
span: ref __binding_0, ty: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for
DefinitionSiteHiddenType<'tcx> {
fn encode(&self, __encoder: &mut __E) {
match *self {
DefinitionSiteHiddenType {
span: ref __binding_0, ty: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for
DefinitionSiteHiddenType<'tcx> {
fn decode(__decoder: &mut __D) -> Self {
DefinitionSiteHiddenType {
span: ::rustc_serialize::Decodable::decode(__decoder),
ty: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable)]
874pub struct DefinitionSiteHiddenType<'tcx> {
875 pub span: Span,
888
889 pub ty: ty::EarlyBinder<'tcx, Ty<'tcx>>,
891}
892
893impl<'tcx> DefinitionSiteHiddenType<'tcx> {
894 pub fn new_error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> DefinitionSiteHiddenType<'tcx> {
895 DefinitionSiteHiddenType {
896 span: DUMMY_SP,
897 ty: ty::EarlyBinder::bind(Ty::new_error(tcx, guar)),
898 }
899 }
900
901 pub fn build_mismatch_error(
902 &self,
903 other: &Self,
904 tcx: TyCtxt<'tcx>,
905 ) -> Result<Diag<'tcx>, ErrorGuaranteed> {
906 let self_ty = self.ty.instantiate_identity();
907 let other_ty = other.ty.instantiate_identity();
908 (self_ty, other_ty).error_reported()?;
909 let sub_diag = if self.span == other.span {
911 TypeMismatchReason::ConflictType { span: self.span }
912 } else {
913 TypeMismatchReason::PreviousUse { span: self.span }
914 };
915 Ok(tcx.dcx().create_err(OpaqueHiddenTypeMismatch {
916 self_ty,
917 other_ty,
918 other_span: other.span,
919 sub: sub_diag,
920 }))
921 }
922}
923
924pub type Clauses<'tcx> = &'tcx ListWithCachedTypeInfo<Clause<'tcx>>;
925
926impl<'tcx> rustc_type_ir::Flags for Clauses<'tcx> {
927 fn flags(&self) -> TypeFlags {
928 (**self).flags()
929 }
930
931 fn outer_exclusive_binder(&self) -> DebruijnIndex {
932 (**self).outer_exclusive_binder()
933 }
934}
935
936#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ParamEnv<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "ParamEnv",
"caller_bounds", &&self.caller_bounds)
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for ParamEnv<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for ParamEnv<'tcx> {
#[inline]
fn clone(&self) -> ParamEnv<'tcx> {
let _: ::core::clone::AssertParamIsClone<Clauses<'tcx>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for ParamEnv<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.caller_bounds, state)
}
}Hash, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for ParamEnv<'tcx> {
#[inline]
fn eq(&self, other: &ParamEnv<'tcx>) -> bool {
self.caller_bounds == other.caller_bounds
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for ParamEnv<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Clauses<'tcx>>;
}
}Eq)]
942#[derive(const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for ParamEnv<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ParamEnv { caller_bounds: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for ParamEnv<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ParamEnv { caller_bounds: ref __binding_0 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for ParamEnv<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
ParamEnv { caller_bounds: __binding_0 } => {
ParamEnv {
caller_bounds: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
ParamEnv { caller_bounds: __binding_0 } => {
ParamEnv {
caller_bounds: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
}
}
}
};TypeFoldable)]
943pub struct ParamEnv<'tcx> {
944 caller_bounds: Clauses<'tcx>,
950}
951
952impl<'tcx> rustc_type_ir::inherent::ParamEnv<TyCtxt<'tcx>> for ParamEnv<'tcx> {
953 fn caller_bounds(self) -> impl inherent::SliceLike<Item = ty::Clause<'tcx>> {
954 self.caller_bounds()
955 }
956}
957
958impl<'tcx> ParamEnv<'tcx> {
959 #[inline]
966 pub fn empty() -> Self {
967 Self::new(ListWithCachedTypeInfo::empty())
968 }
969
970 #[inline]
971 pub fn caller_bounds(self) -> Clauses<'tcx> {
972 self.caller_bounds
973 }
974
975 #[inline]
977 pub fn new(caller_bounds: Clauses<'tcx>) -> Self {
978 ParamEnv { caller_bounds }
979 }
980
981 pub fn and<T: TypeVisitable<TyCtxt<'tcx>>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
983 ParamEnvAnd { param_env: self, value }
984 }
985}
986
987#[derive(#[automatically_derived]
impl<'tcx, T: ::core::marker::Copy> ::core::marker::Copy for
ParamEnvAnd<'tcx, T> {
}Copy, #[automatically_derived]
impl<'tcx, T: ::core::clone::Clone> ::core::clone::Clone for
ParamEnvAnd<'tcx, T> {
#[inline]
fn clone(&self) -> ParamEnvAnd<'tcx, T> {
ParamEnvAnd {
param_env: ::core::clone::Clone::clone(&self.param_env),
value: ::core::clone::Clone::clone(&self.value),
}
}
}Clone, #[automatically_derived]
impl<'tcx, T: ::core::fmt::Debug> ::core::fmt::Debug for ParamEnvAnd<'tcx, T>
{
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "ParamEnvAnd",
"param_env", &self.param_env, "value", &&self.value)
}
}Debug, #[automatically_derived]
impl<'tcx, T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for
ParamEnvAnd<'tcx, T> {
#[inline]
fn eq(&self, other: &ParamEnvAnd<'tcx, T>) -> bool {
self.param_env == other.param_env && self.value == other.value
}
}PartialEq, #[automatically_derived]
impl<'tcx, T: ::core::cmp::Eq> ::core::cmp::Eq for ParamEnvAnd<'tcx, T> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<ParamEnv<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<T>;
}
}Eq, #[automatically_derived]
impl<'tcx, T: ::core::hash::Hash> ::core::hash::Hash for ParamEnvAnd<'tcx, T>
{
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.param_env, state);
::core::hash::Hash::hash(&self.value, state)
}
}Hash, const _: () =
{
impl<'tcx, T>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for ParamEnvAnd<'tcx, T> where
T: ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
{
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
ParamEnvAnd { param_env: __binding_0, value: __binding_1 }
=> {
ParamEnvAnd {
param_env: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
value: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
ParamEnvAnd { param_env: __binding_0, value: __binding_1 }
=> {
ParamEnvAnd {
param_env: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
value: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx, T>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for ParamEnvAnd<'tcx, T> where
T: ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
{
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ParamEnvAnd {
param_env: ref __binding_0, value: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
988#[derive(const _: () =
{
impl<'tcx, '__ctx, T>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for ParamEnvAnd<'tcx, T> where
T: ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
{
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ParamEnvAnd {
param_env: ref __binding_0, value: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
989pub struct ParamEnvAnd<'tcx, T> {
990 pub param_env: ParamEnv<'tcx>,
991 pub value: T,
992}
993
994#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for TypingEnv<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for TypingEnv<'tcx> {
#[inline]
fn clone(&self) -> TypingEnv<'tcx> {
let _: ::core::clone::AssertParamIsClone<TypingMode<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ParamEnv<'tcx>>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for TypingEnv<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "TypingEnv",
"typing_mode", &self.typing_mode, "param_env", &&self.param_env)
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for TypingEnv<'tcx> {
#[inline]
fn eq(&self, other: &TypingEnv<'tcx>) -> bool {
self.typing_mode == other.typing_mode &&
self.param_env == other.param_env
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for TypingEnv<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<TypingMode<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<ParamEnv<'tcx>>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for TypingEnv<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.typing_mode, state);
::core::hash::Hash::hash(&self.param_env, state)
}
}Hash, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for TypingEnv<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TypingEnv {
typing_mode: ref __binding_0, param_env: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
1005#[derive(const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for TypingEnv<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
TypingEnv { param_env: ref __binding_1, .. } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for TypingEnv<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
TypingEnv { typing_mode: __binding_0, param_env: __binding_1
} => {
TypingEnv {
typing_mode: __binding_0,
param_env: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
TypingEnv { typing_mode: __binding_0, param_env: __binding_1
} => {
TypingEnv {
typing_mode: __binding_0,
param_env: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable)]
1006pub struct TypingEnv<'tcx> {
1007 #[type_foldable(identity)]
1008 #[type_visitable(ignore)]
1009 pub typing_mode: TypingMode<'tcx>,
1010 pub param_env: ParamEnv<'tcx>,
1011}
1012
1013impl<'tcx> TypingEnv<'tcx> {
1014 pub fn fully_monomorphized() -> TypingEnv<'tcx> {
1022 TypingEnv { typing_mode: TypingMode::PostAnalysis, param_env: ParamEnv::empty() }
1023 }
1024
1025 pub fn non_body_analysis(
1031 tcx: TyCtxt<'tcx>,
1032 def_id: impl IntoQueryParam<DefId>,
1033 ) -> TypingEnv<'tcx> {
1034 TypingEnv { typing_mode: TypingMode::non_body_analysis(), param_env: tcx.param_env(def_id) }
1035 }
1036
1037 pub fn post_analysis(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryParam<DefId>) -> TypingEnv<'tcx> {
1038 tcx.typing_env_normalized_for_post_analysis(def_id)
1039 }
1040
1041 pub fn with_post_analysis_normalized(self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> {
1044 let TypingEnv { typing_mode, param_env } = self;
1045 if let TypingMode::PostAnalysis = typing_mode {
1046 return self;
1047 }
1048
1049 let param_env = if tcx.next_trait_solver_globally() {
1052 param_env
1053 } else {
1054 ParamEnv::new(tcx.reveal_opaque_types_in_bounds(param_env.caller_bounds()))
1055 };
1056 TypingEnv { typing_mode: TypingMode::PostAnalysis, param_env }
1057 }
1058
1059 pub fn as_query_input<T>(self, value: T) -> PseudoCanonicalInput<'tcx, T>
1064 where
1065 T: TypeVisitable<TyCtxt<'tcx>>,
1066 {
1067 PseudoCanonicalInput { typing_env: self, value }
1080 }
1081}
1082
1083#[derive(#[automatically_derived]
impl<'tcx, T: ::core::marker::Copy> ::core::marker::Copy for
PseudoCanonicalInput<'tcx, T> {
}Copy, #[automatically_derived]
impl<'tcx, T: ::core::clone::Clone> ::core::clone::Clone for
PseudoCanonicalInput<'tcx, T> {
#[inline]
fn clone(&self) -> PseudoCanonicalInput<'tcx, T> {
PseudoCanonicalInput {
typing_env: ::core::clone::Clone::clone(&self.typing_env),
value: ::core::clone::Clone::clone(&self.value),
}
}
}Clone, #[automatically_derived]
impl<'tcx, T: ::core::fmt::Debug> ::core::fmt::Debug for
PseudoCanonicalInput<'tcx, T> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"PseudoCanonicalInput", "typing_env", &self.typing_env, "value",
&&self.value)
}
}Debug, #[automatically_derived]
impl<'tcx, T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for
PseudoCanonicalInput<'tcx, T> {
#[inline]
fn eq(&self, other: &PseudoCanonicalInput<'tcx, T>) -> bool {
self.typing_env == other.typing_env && self.value == other.value
}
}PartialEq, #[automatically_derived]
impl<'tcx, T: ::core::cmp::Eq> ::core::cmp::Eq for
PseudoCanonicalInput<'tcx, T> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<TypingEnv<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<T>;
}
}Eq, #[automatically_derived]
impl<'tcx, T: ::core::hash::Hash> ::core::hash::Hash for
PseudoCanonicalInput<'tcx, T> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.typing_env, state);
::core::hash::Hash::hash(&self.value, state)
}
}Hash)]
1093#[derive(const _: () =
{
impl<'tcx, '__ctx, T>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for PseudoCanonicalInput<'tcx, T> where
T: ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
{
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PseudoCanonicalInput {
typing_env: ref __binding_0, value: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx, T>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for PseudoCanonicalInput<'tcx, T> where
T: ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
{
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
PseudoCanonicalInput {
typing_env: ref __binding_0, value: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable, const _: () =
{
impl<'tcx, T>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for PseudoCanonicalInput<'tcx, T> where
T: ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
{
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
PseudoCanonicalInput {
typing_env: __binding_0, value: __binding_1 } => {
PseudoCanonicalInput {
typing_env: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
value: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
PseudoCanonicalInput {
typing_env: __binding_0, value: __binding_1 } => {
PseudoCanonicalInput {
typing_env: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
value: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable)]
1094pub struct PseudoCanonicalInput<'tcx, T> {
1095 pub typing_env: TypingEnv<'tcx>,
1096 pub value: T,
1097}
1098
1099#[derive(#[automatically_derived]
impl ::core::marker::Copy for Destructor { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Destructor {
#[inline]
fn clone(&self) -> Destructor {
let _: ::core::clone::AssertParamIsClone<DefId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Destructor {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "Destructor",
"did", &&self.did)
}
}Debug, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for Destructor {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Destructor { did: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Destructor {
fn encode(&self, __encoder: &mut __E) {
match *self {
Destructor { did: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Destructor {
fn decode(__decoder: &mut __D) -> Self {
Destructor {
did: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1100pub struct Destructor {
1101 pub did: DefId,
1103}
1104
1105#[derive(#[automatically_derived]
impl ::core::marker::Copy for AsyncDestructor { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AsyncDestructor {
#[inline]
fn clone(&self) -> AsyncDestructor {
let _: ::core::clone::AssertParamIsClone<DefId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AsyncDestructor {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"AsyncDestructor", "impl_did", &&self.impl_did)
}
}Debug, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for AsyncDestructor {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AsyncDestructor { impl_did: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AsyncDestructor {
fn encode(&self, __encoder: &mut __E) {
match *self {
AsyncDestructor { impl_did: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AsyncDestructor {
fn decode(__decoder: &mut __D) -> Self {
AsyncDestructor {
impl_did: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1107pub struct AsyncDestructor {
1108 pub impl_did: DefId,
1110}
1111
1112#[derive(#[automatically_derived]
impl ::core::clone::Clone for VariantFlags {
#[inline]
fn clone(&self) -> VariantFlags {
let _: ::core::clone::AssertParamIsClone<u8>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for VariantFlags { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for VariantFlags {
#[inline]
fn eq(&self, other: &VariantFlags) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for VariantFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u8>;
}
}Eq, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for VariantFlags {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
VariantFlags(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for VariantFlags {
fn encode(&self, __encoder: &mut __E) {
match *self {
VariantFlags(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for VariantFlags {
fn decode(__decoder: &mut __D) -> Self {
VariantFlags(::rustc_serialize::Decodable::decode(__decoder))
}
}
};TyDecodable)]
1113pub struct VariantFlags(u8);
1114impl VariantFlags {
#[allow(deprecated, non_upper_case_globals,)]
pub const NO_VARIANT_FLAGS: Self = Self::from_bits_retain(0);
#[doc =
r" Indicates whether the field list of this variant is `#[non_exhaustive]`."]
#[allow(deprecated, non_upper_case_globals,)]
pub const IS_FIELD_LIST_NON_EXHAUSTIVE: Self =
Self::from_bits_retain(1 << 0);
}
impl ::bitflags::Flags for VariantFlags {
const FLAGS: &'static [::bitflags::Flag<VariantFlags>] =
&[{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("NO_VARIANT_FLAGS",
VariantFlags::NO_VARIANT_FLAGS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("IS_FIELD_LIST_NON_EXHAUSTIVE",
VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE)
}];
type Bits = u8;
fn bits(&self) -> u8 { VariantFlags::bits(self) }
fn from_bits_retain(bits: u8) -> VariantFlags {
VariantFlags::from_bits_retain(bits)
}
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: iter_without_into_iter,)]
const _: () =
{
#[allow(dead_code, deprecated, unused_attributes)]
impl VariantFlags {
#[inline]
pub const fn empty() -> Self {
Self(<u8 as ::bitflags::Bits>::EMPTY)
}
#[inline]
pub const fn all() -> Self {
let mut truncated = <u8 as ::bitflags::Bits>::EMPTY;
let mut i = 0;
{
{
let flag =
<VariantFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<VariantFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
let _ = i;
Self(truncated)
}
#[inline]
pub const fn bits(&self) -> u8 { self.0 }
#[inline]
pub const fn from_bits(bits: u8)
-> ::bitflags::__private::core::option::Option<Self> {
let truncated = Self::from_bits_truncate(bits).0;
if truncated == bits {
::bitflags::__private::core::option::Option::Some(Self(bits))
} else { ::bitflags::__private::core::option::Option::None }
}
#[inline]
pub const fn from_bits_truncate(bits: u8) -> Self {
Self(bits & Self::all().0)
}
#[inline]
pub const fn from_bits_retain(bits: u8) -> Self { Self(bits) }
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
{
if name == "NO_VARIANT_FLAGS" {
return ::bitflags::__private::core::option::Option::Some(Self(VariantFlags::NO_VARIANT_FLAGS.bits()));
}
};
;
{
if name == "IS_FIELD_LIST_NON_EXHAUSTIVE" {
return ::bitflags::__private::core::option::Option::Some(Self(VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE.bits()));
}
};
;
let _ = name;
::bitflags::__private::core::option::Option::None
}
#[inline]
pub const fn is_empty(&self) -> bool {
self.0 == <u8 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn is_all(&self) -> bool {
Self::all().0 | self.0 == self.0
}
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0 & other.0 != <u8 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0 & other.0 == other.0
}
#[inline]
pub fn insert(&mut self, other: Self) {
*self = Self(self.0).union(other);
}
#[inline]
pub fn remove(&mut self, other: Self) {
*self = Self(self.0).difference(other);
}
#[inline]
pub fn toggle(&mut self, other: Self) {
*self = Self(self.0).symmetric_difference(other);
}
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
if value { self.insert(other); } else { self.remove(other); }
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0 & other.0)
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0 & !other.0)
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0 ^ other.0)
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self::from_bits_truncate(!self.0)
}
}
impl ::bitflags::__private::core::fmt::Binary for VariantFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for VariantFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for VariantFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for VariantFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for VariantFlags {
type Output = Self;
#[inline]
fn bitor(self, other: VariantFlags) -> Self { self.union(other) }
}
impl ::bitflags::__private::core::ops::BitOrAssign for VariantFlags {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for VariantFlags {
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for VariantFlags {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for VariantFlags {
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for VariantFlags {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for VariantFlags {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for VariantFlags {
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for VariantFlags {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<VariantFlags> for
VariantFlags {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<VariantFlags> for
VariantFlags {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl VariantFlags {
#[inline]
pub const fn iter(&self) -> ::bitflags::iter::Iter<VariantFlags> {
::bitflags::iter::Iter::__private_const_new(<VariantFlags as
::bitflags::Flags>::FLAGS,
VariantFlags::from_bits_retain(self.bits()),
VariantFlags::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<VariantFlags> {
::bitflags::iter::IterNames::__private_const_new(<VariantFlags
as ::bitflags::Flags>::FLAGS,
VariantFlags::from_bits_retain(self.bits()),
VariantFlags::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for VariantFlags
{
type Item = VariantFlags;
type IntoIter = ::bitflags::iter::Iter<VariantFlags>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
};bitflags::bitflags! {
1115 impl VariantFlags: u8 {
1116 const NO_VARIANT_FLAGS = 0;
1117 const IS_FIELD_LIST_NON_EXHAUSTIVE = 1 << 0;
1119 }
1120}
1121impl ::std::fmt::Debug for VariantFlags {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::bitflags::parser::to_writer(self, f)
}
}rustc_data_structures::external_bitflags_debug! { VariantFlags }
1122
1123#[derive(#[automatically_derived]
impl ::core::fmt::Debug for VariantDef {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["def_id", "ctor", "name", "discr", "fields", "tainted",
"flags"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.def_id, &self.ctor, &self.name, &self.discr, &self.fields,
&self.tainted, &&self.flags];
::core::fmt::Formatter::debug_struct_fields_finish(f, "VariantDef",
names, values)
}
}Debug, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for VariantDef {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
VariantDef {
def_id: ref __binding_0,
ctor: ref __binding_1,
name: ref __binding_2,
discr: ref __binding_3,
fields: ref __binding_4,
tainted: ref __binding_5,
flags: ref __binding_6 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
{ __binding_5.hash_stable(__hcx, __hasher); }
{ __binding_6.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for VariantDef {
fn encode(&self, __encoder: &mut __E) {
match *self {
VariantDef {
def_id: ref __binding_0,
ctor: ref __binding_1,
name: ref __binding_2,
discr: ref __binding_3,
fields: ref __binding_4,
tainted: ref __binding_5,
flags: ref __binding_6 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_4,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_5,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_6,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for VariantDef {
fn decode(__decoder: &mut __D) -> Self {
VariantDef {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
ctor: ::rustc_serialize::Decodable::decode(__decoder),
name: ::rustc_serialize::Decodable::decode(__decoder),
discr: ::rustc_serialize::Decodable::decode(__decoder),
fields: ::rustc_serialize::Decodable::decode(__decoder),
tainted: ::rustc_serialize::Decodable::decode(__decoder),
flags: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable)]
1125pub struct VariantDef {
1126 pub def_id: DefId,
1129 pub ctor: Option<(CtorKind, DefId)>,
1132 pub name: Symbol,
1134 pub discr: VariantDiscr,
1136 pub fields: IndexVec<FieldIdx, FieldDef>,
1138 tainted: Option<ErrorGuaranteed>,
1140 flags: VariantFlags,
1142}
1143
1144impl VariantDef {
1145 #[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("new",
"rustc_middle::ty", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
::tracing_core::__macro_support::Option::Some(1161u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
::tracing_core::field::FieldSet::new(&["name",
"variant_did", "ctor", "discr", "fields", "parent_did",
"recover_tainted", "is_field_list_non_exhaustive"],
::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(&name)
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(&variant_did)
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(&ctor)
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(&discr)
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(&fields)
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(&parent_did)
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(&recover_tainted)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&is_field_list_non_exhaustive
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: Self = loop {};
return __tracing_attr_fake_return;
}
{
let mut flags = VariantFlags::NO_VARIANT_FLAGS;
if is_field_list_non_exhaustive {
flags |= VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE;
}
VariantDef {
def_id: variant_did.unwrap_or(parent_did),
ctor,
name,
discr,
fields,
flags,
tainted: recover_tainted,
}
}
}
}#[instrument(level = "debug")]
1162 pub fn new(
1163 name: Symbol,
1164 variant_did: Option<DefId>,
1165 ctor: Option<(CtorKind, DefId)>,
1166 discr: VariantDiscr,
1167 fields: IndexVec<FieldIdx, FieldDef>,
1168 parent_did: DefId,
1169 recover_tainted: Option<ErrorGuaranteed>,
1170 is_field_list_non_exhaustive: bool,
1171 ) -> Self {
1172 let mut flags = VariantFlags::NO_VARIANT_FLAGS;
1173 if is_field_list_non_exhaustive {
1174 flags |= VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE;
1175 }
1176
1177 VariantDef {
1178 def_id: variant_did.unwrap_or(parent_did),
1179 ctor,
1180 name,
1181 discr,
1182 fields,
1183 flags,
1184 tainted: recover_tainted,
1185 }
1186 }
1187
1188 #[inline]
1194 pub fn is_field_list_non_exhaustive(&self) -> bool {
1195 self.flags.intersects(VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE)
1196 }
1197
1198 #[inline]
1201 pub fn field_list_has_applicable_non_exhaustive(&self) -> bool {
1202 self.is_field_list_non_exhaustive() && !self.def_id.is_local()
1203 }
1204
1205 pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
1207 Ident::new(self.name, tcx.def_ident_span(self.def_id).unwrap())
1208 }
1209
1210 #[inline]
1212 pub fn has_errors(&self) -> Result<(), ErrorGuaranteed> {
1213 self.tainted.map_or(Ok(()), Err)
1214 }
1215
1216 #[inline]
1217 pub fn ctor_kind(&self) -> Option<CtorKind> {
1218 self.ctor.map(|(kind, _)| kind)
1219 }
1220
1221 #[inline]
1222 pub fn ctor_def_id(&self) -> Option<DefId> {
1223 self.ctor.map(|(_, def_id)| def_id)
1224 }
1225
1226 #[inline]
1230 pub fn single_field(&self) -> &FieldDef {
1231 if !(self.fields.len() == 1) {
::core::panicking::panic("assertion failed: self.fields.len() == 1")
};assert!(self.fields.len() == 1);
1232
1233 &self.fields[FieldIdx::ZERO]
1234 }
1235
1236 #[inline]
1238 pub fn tail_opt(&self) -> Option<&FieldDef> {
1239 self.fields.raw.last()
1240 }
1241
1242 #[inline]
1248 pub fn tail(&self) -> &FieldDef {
1249 self.tail_opt().expect("expected unsized ADT to have a tail field")
1250 }
1251
1252 pub fn has_unsafe_fields(&self) -> bool {
1254 self.fields.iter().any(|x| x.safety.is_unsafe())
1255 }
1256}
1257
1258impl PartialEq for VariantDef {
1259 #[inline]
1260 fn eq(&self, other: &Self) -> bool {
1261 let Self {
1269 def_id: lhs_def_id,
1270 ctor: _,
1271 name: _,
1272 discr: _,
1273 fields: _,
1274 flags: _,
1275 tainted: _,
1276 } = &self;
1277 let Self {
1278 def_id: rhs_def_id,
1279 ctor: _,
1280 name: _,
1281 discr: _,
1282 fields: _,
1283 flags: _,
1284 tainted: _,
1285 } = other;
1286
1287 let res = lhs_def_id == rhs_def_id;
1288
1289 if truecfg!(debug_assertions) && res {
1291 let deep = self.ctor == other.ctor
1292 && self.name == other.name
1293 && self.discr == other.discr
1294 && self.fields == other.fields
1295 && self.flags == other.flags;
1296 if !deep {
{
::core::panicking::panic_fmt(format_args!("VariantDef for the same def-id has differing data"));
}
};assert!(deep, "VariantDef for the same def-id has differing data");
1297 }
1298
1299 res
1300 }
1301}
1302
1303impl Eq for VariantDef {}
1304
1305impl Hash for VariantDef {
1306 #[inline]
1307 fn hash<H: Hasher>(&self, s: &mut H) {
1308 let Self { def_id, ctor: _, name: _, discr: _, fields: _, flags: _, tainted: _ } = &self;
1316 def_id.hash(s)
1317 }
1318}
1319
1320#[derive(#[automatically_derived]
impl ::core::marker::Copy for VariantDiscr { }Copy, #[automatically_derived]
impl ::core::clone::Clone for VariantDiscr {
#[inline]
fn clone(&self) -> VariantDiscr {
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for VariantDiscr {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
VariantDiscr::Explicit(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Explicit", &__self_0),
VariantDiscr::Relative(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Relative", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for VariantDiscr {
#[inline]
fn eq(&self, other: &VariantDiscr) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(VariantDiscr::Explicit(__self_0),
VariantDiscr::Explicit(__arg1_0)) => __self_0 == __arg1_0,
(VariantDiscr::Relative(__self_0),
VariantDiscr::Relative(__arg1_0)) => __self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for VariantDiscr {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<DefId>;
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}Eq, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for VariantDiscr {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
VariantDiscr::Explicit(ref __binding_0) => { 0usize }
VariantDiscr::Relative(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
VariantDiscr::Explicit(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
VariantDiscr::Relative(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for VariantDiscr {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
VariantDiscr::Explicit(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
VariantDiscr::Relative(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `VariantDiscr`, expected 0..2, actual {0}",
n));
}
}
}
}
};TyDecodable, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for VariantDiscr {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
VariantDiscr::Explicit(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
VariantDiscr::Relative(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
1321pub enum VariantDiscr {
1322 Explicit(DefId),
1325
1326 Relative(u32),
1331}
1332
1333#[derive(#[automatically_derived]
impl ::core::fmt::Debug for FieldDef {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "FieldDef",
"did", &self.did, "name", &self.name, "vis", &self.vis, "safety",
&self.safety, "value", &&self.value)
}
}Debug, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for FieldDef {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FieldDef {
did: ref __binding_0,
name: ref __binding_1,
vis: ref __binding_2,
safety: ref __binding_3,
value: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for FieldDef {
fn encode(&self, __encoder: &mut __E) {
match *self {
FieldDef {
did: ref __binding_0,
name: ref __binding_1,
vis: ref __binding_2,
safety: ref __binding_3,
value: ref __binding_4 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_4,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for FieldDef {
fn decode(__decoder: &mut __D) -> Self {
FieldDef {
did: ::rustc_serialize::Decodable::decode(__decoder),
name: ::rustc_serialize::Decodable::decode(__decoder),
vis: ::rustc_serialize::Decodable::decode(__decoder),
safety: ::rustc_serialize::Decodable::decode(__decoder),
value: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable)]
1334pub struct FieldDef {
1335 pub did: DefId,
1336 pub name: Symbol,
1337 pub vis: Visibility<DefId>,
1338 pub safety: hir::Safety,
1339 pub value: Option<DefId>,
1340}
1341
1342impl PartialEq for FieldDef {
1343 #[inline]
1344 fn eq(&self, other: &Self) -> bool {
1345 let Self { did: lhs_did, name: _, vis: _, safety: _, value: _ } = &self;
1353
1354 let Self { did: rhs_did, name: _, vis: _, safety: _, value: _ } = other;
1355
1356 let res = lhs_did == rhs_did;
1357
1358 if truecfg!(debug_assertions) && res {
1360 let deep =
1361 self.name == other.name && self.vis == other.vis && self.safety == other.safety;
1362 if !deep {
{
::core::panicking::panic_fmt(format_args!("FieldDef for the same def-id has differing data"));
}
};assert!(deep, "FieldDef for the same def-id has differing data");
1363 }
1364
1365 res
1366 }
1367}
1368
1369impl Eq for FieldDef {}
1370
1371impl Hash for FieldDef {
1372 #[inline]
1373 fn hash<H: Hasher>(&self, s: &mut H) {
1374 let Self { did, name: _, vis: _, safety: _, value: _ } = &self;
1382
1383 did.hash(s)
1384 }
1385}
1386
1387impl<'tcx> FieldDef {
1388 pub fn ty(&self, tcx: TyCtxt<'tcx>, args: GenericArgsRef<'tcx>) -> Ty<'tcx> {
1391 tcx.type_of(self.did).instantiate(tcx, args)
1392 }
1393
1394 pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
1396 Ident::new(self.name, tcx.def_ident_span(self.did).unwrap())
1397 }
1398}
1399
1400#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplOverlapKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ImplOverlapKind::Permitted { marker: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Permitted", "marker", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplOverlapKind {
#[inline]
fn eq(&self, other: &ImplOverlapKind) -> bool {
match (self, other) {
(ImplOverlapKind::Permitted { marker: __self_0 },
ImplOverlapKind::Permitted { marker: __arg1_0 }) =>
__self_0 == __arg1_0,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplOverlapKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq)]
1401pub enum ImplOverlapKind {
1402 Permitted {
1404 marker: bool,
1406 },
1407}
1408
1409#[derive(#[automatically_derived]
impl ::core::clone::Clone for ImplTraitInTraitData {
#[inline]
fn clone(&self) -> ImplTraitInTraitData {
let _: ::core::clone::AssertParamIsClone<DefId>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ImplTraitInTraitData { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for ImplTraitInTraitData {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ImplTraitInTraitData::Trait {
fn_def_id: __self_0, opaque_def_id: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "Trait",
"fn_def_id", __self_0, "opaque_def_id", &__self_1),
ImplTraitInTraitData::Impl { fn_def_id: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Impl",
"fn_def_id", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplTraitInTraitData {
#[inline]
fn eq(&self, other: &ImplTraitInTraitData) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(ImplTraitInTraitData::Trait {
fn_def_id: __self_0, opaque_def_id: __self_1 },
ImplTraitInTraitData::Trait {
fn_def_id: __arg1_0, opaque_def_id: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(ImplTraitInTraitData::Impl { fn_def_id: __self_0 },
ImplTraitInTraitData::Impl { fn_def_id: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplTraitInTraitData {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<DefId>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for ImplTraitInTraitData {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
ImplTraitInTraitData::Trait {
fn_def_id: __self_0, opaque_def_id: __self_1 } => {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
ImplTraitInTraitData::Impl { fn_def_id: __self_0 } =>
::core::hash::Hash::hash(__self_0, state),
}
}
}Hash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ImplTraitInTraitData {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ImplTraitInTraitData::Trait {
fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
=> {
0usize
}
ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
{
1usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ImplTraitInTraitData::Trait {
fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
{
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ImplTraitInTraitData {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
ImplTraitInTraitData::Trait {
fn_def_id: ::rustc_serialize::Decodable::decode(__decoder),
opaque_def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => {
ImplTraitInTraitData::Impl {
fn_def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplTraitInTraitData`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for ImplTraitInTraitData {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ImplTraitInTraitData::Trait {
fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
1412pub enum ImplTraitInTraitData {
1413 Trait { fn_def_id: DefId, opaque_def_id: DefId },
1414 Impl { fn_def_id: DefId },
1415}
1416
1417impl<'tcx> TyCtxt<'tcx> {
1418 pub fn typeck_body(self, body: hir::BodyId) -> &'tcx TypeckResults<'tcx> {
1419 self.typeck(self.hir_body_owner_def_id(body))
1420 }
1421
1422 pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> {
1423 self.associated_items(id)
1424 .in_definition_order()
1425 .filter(move |item| item.is_fn() && item.defaultness(self).has_value())
1426 }
1427
1428 pub fn repr_options_of_def(self, did: LocalDefId) -> ReprOptions {
1429 let mut flags = ReprFlags::empty();
1430 let mut size = None;
1431 let mut max_align: Option<Align> = None;
1432 let mut min_pack: Option<Align> = None;
1433
1434 let mut field_shuffle_seed = self.def_path_hash(did.to_def_id()).0.to_smaller_hash();
1437
1438 if let Some(user_seed) = self.sess.opts.unstable_opts.layout_seed {
1442 field_shuffle_seed ^= user_seed;
1443 }
1444
1445 let elt = {
#[allow(deprecated)]
{
{
'done:
{
for i in self.get_all_attrs(did) {
#[allow(unused_imports)]
use rustc_hir::attrs::AttributeKind::*;
let i: &rustc_hir::Attribute = i;
match i {
rustc_hir::Attribute::Parsed(RustcScalableVector {
element_count, .. }) => {
break 'done Some(element_count);
}
rustc_hir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}
}find_attr!(self, did, RustcScalableVector { element_count, .. } => element_count
1446 )
1447 .map(|elt| match elt {
1448 Some(n) => ScalableElt::ElementCount(*n),
1449 None => ScalableElt::Container,
1450 });
1451 if elt.is_some() {
1452 flags.insert(ReprFlags::IS_SCALABLE);
1453 }
1454 if let Some(reprs) = {
#[allow(deprecated)]
{
{
'done:
{
for i in self.get_all_attrs(did) {
#[allow(unused_imports)]
use rustc_hir::attrs::AttributeKind::*;
let i: &rustc_hir::Attribute = i;
match i {
rustc_hir::Attribute::Parsed(Repr { reprs, .. }) => {
break 'done Some(reprs);
}
rustc_hir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}
}find_attr!(self, did, Repr { reprs, .. } => reprs) {
1455 for (r, _) in reprs {
1456 flags.insert(match *r {
1457 attr::ReprRust => ReprFlags::empty(),
1458 attr::ReprC => ReprFlags::IS_C,
1459 attr::ReprPacked(pack) => {
1460 min_pack = Some(if let Some(min_pack) = min_pack {
1461 min_pack.min(pack)
1462 } else {
1463 pack
1464 });
1465 ReprFlags::empty()
1466 }
1467 attr::ReprTransparent => ReprFlags::IS_TRANSPARENT,
1468 attr::ReprSimd => ReprFlags::IS_SIMD,
1469 attr::ReprInt(i) => {
1470 size = Some(match i {
1471 attr::IntType::SignedInt(x) => match x {
1472 ast::IntTy::Isize => IntegerType::Pointer(true),
1473 ast::IntTy::I8 => IntegerType::Fixed(Integer::I8, true),
1474 ast::IntTy::I16 => IntegerType::Fixed(Integer::I16, true),
1475 ast::IntTy::I32 => IntegerType::Fixed(Integer::I32, true),
1476 ast::IntTy::I64 => IntegerType::Fixed(Integer::I64, true),
1477 ast::IntTy::I128 => IntegerType::Fixed(Integer::I128, true),
1478 },
1479 attr::IntType::UnsignedInt(x) => match x {
1480 ast::UintTy::Usize => IntegerType::Pointer(false),
1481 ast::UintTy::U8 => IntegerType::Fixed(Integer::I8, false),
1482 ast::UintTy::U16 => IntegerType::Fixed(Integer::I16, false),
1483 ast::UintTy::U32 => IntegerType::Fixed(Integer::I32, false),
1484 ast::UintTy::U64 => IntegerType::Fixed(Integer::I64, false),
1485 ast::UintTy::U128 => IntegerType::Fixed(Integer::I128, false),
1486 },
1487 });
1488 ReprFlags::empty()
1489 }
1490 attr::ReprAlign(align) => {
1491 max_align = max_align.max(Some(align));
1492 ReprFlags::empty()
1493 }
1494 });
1495 }
1496 }
1497
1498 if self.sess.opts.unstable_opts.randomize_layout {
1501 flags.insert(ReprFlags::RANDOMIZE_LAYOUT);
1502 }
1503
1504 let is_box = self.is_lang_item(did.to_def_id(), LangItem::OwnedBox);
1507
1508 if is_box {
1510 flags.insert(ReprFlags::IS_LINEAR);
1511 }
1512
1513 if {
#[allow(deprecated)]
{
{
'done:
{
for i in self.get_all_attrs(did) {
#[allow(unused_imports)]
use rustc_hir::attrs::AttributeKind::*;
let i: &rustc_hir::Attribute = i;
match i {
rustc_hir::Attribute::Parsed(RustcPassIndirectlyInNonRusticAbis(..))
=> {
break 'done Some(());
}
rustc_hir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}
}.is_some()find_attr!(self, did, RustcPassIndirectlyInNonRusticAbis(..)) {
1515 flags.insert(ReprFlags::PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS);
1516 }
1517
1518 ReprOptions {
1519 int: size,
1520 align: max_align,
1521 pack: min_pack,
1522 flags,
1523 field_shuffle_seed,
1524 scalable: elt,
1525 }
1526 }
1527
1528 pub fn opt_item_name(self, def_id: impl IntoQueryParam<DefId>) -> Option<Symbol> {
1530 let def_id = def_id.into_query_param();
1531 if let Some(cnum) = def_id.as_crate_root() {
1532 Some(self.crate_name(cnum))
1533 } else {
1534 let def_key = self.def_key(def_id);
1535 match def_key.disambiguated_data.data {
1536 rustc_hir::definitions::DefPathData::Ctor => self
1538 .opt_item_name(DefId { krate: def_id.krate, index: def_key.parent.unwrap() }),
1539 _ => def_key.get_opt_name(),
1540 }
1541 }
1542 }
1543
1544 pub fn item_name(self, id: impl IntoQueryParam<DefId>) -> Symbol {
1551 let id = id.into_query_param();
1552 self.opt_item_name(id).unwrap_or_else(|| {
1553 crate::util::bug::bug_fmt(format_args!("item_name: no name for {0:?}",
self.def_path(id)));bug!("item_name: no name for {:?}", self.def_path(id));
1554 })
1555 }
1556
1557 pub fn opt_item_ident(self, def_id: impl IntoQueryParam<DefId>) -> Option<Ident> {
1561 let def_id = def_id.into_query_param();
1562 let def = self.opt_item_name(def_id)?;
1563 let span = self
1564 .def_ident_span(def_id)
1565 .unwrap_or_else(|| crate::util::bug::bug_fmt(format_args!("missing ident span for {0:?}",
def_id))bug!("missing ident span for {def_id:?}"));
1566 Some(Ident::new(def, span))
1567 }
1568
1569 pub fn item_ident(self, def_id: impl IntoQueryParam<DefId>) -> Ident {
1573 let def_id = def_id.into_query_param();
1574 self.opt_item_ident(def_id).unwrap_or_else(|| {
1575 crate::util::bug::bug_fmt(format_args!("item_ident: no name for {0:?}",
self.def_path(def_id)));bug!("item_ident: no name for {:?}", self.def_path(def_id));
1576 })
1577 }
1578
1579 pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
1580 if let DefKind::AssocConst { .. } | DefKind::AssocFn | DefKind::AssocTy =
1581 self.def_kind(def_id)
1582 {
1583 Some(self.associated_item(def_id))
1584 } else {
1585 None
1586 }
1587 }
1588
1589 pub fn opt_rpitit_info(self, def_id: DefId) -> Option<ImplTraitInTraitData> {
1593 if let DefKind::AssocTy = self.def_kind(def_id)
1594 && let AssocKind::Type { data: AssocTypeData::Rpitit(rpitit_info) } =
1595 self.associated_item(def_id).kind
1596 {
1597 Some(rpitit_info)
1598 } else {
1599 None
1600 }
1601 }
1602
1603 pub fn find_field_index(self, ident: Ident, variant: &VariantDef) -> Option<FieldIdx> {
1604 variant.fields.iter_enumerated().find_map(|(i, field)| {
1605 self.hygienic_eq(ident, field.ident(self), variant.def_id).then_some(i)
1606 })
1607 }
1608
1609 x;#[instrument(level = "debug", skip(self), ret)]
1612 pub fn impls_are_allowed_to_overlap(
1613 self,
1614 def_id1: DefId,
1615 def_id2: DefId,
1616 ) -> Option<ImplOverlapKind> {
1617 let impl1 = self.impl_trait_header(def_id1);
1618 let impl2 = self.impl_trait_header(def_id2);
1619
1620 let trait_ref1 = impl1.trait_ref.skip_binder();
1621 let trait_ref2 = impl2.trait_ref.skip_binder();
1622
1623 if trait_ref1.references_error() || trait_ref2.references_error() {
1626 return Some(ImplOverlapKind::Permitted { marker: false });
1627 }
1628
1629 match (impl1.polarity, impl2.polarity) {
1630 (ImplPolarity::Reservation, _) | (_, ImplPolarity::Reservation) => {
1631 return Some(ImplOverlapKind::Permitted { marker: false });
1633 }
1634 (ImplPolarity::Positive, ImplPolarity::Negative)
1635 | (ImplPolarity::Negative, ImplPolarity::Positive) => {
1636 return None;
1638 }
1639 (ImplPolarity::Positive, ImplPolarity::Positive)
1640 | (ImplPolarity::Negative, ImplPolarity::Negative) => {}
1641 };
1642
1643 let is_marker_impl = |trait_ref: TraitRef<'_>| self.trait_def(trait_ref.def_id).is_marker;
1644 let is_marker_overlap = is_marker_impl(trait_ref1) && is_marker_impl(trait_ref2);
1645
1646 if is_marker_overlap {
1647 return Some(ImplOverlapKind::Permitted { marker: true });
1648 }
1649
1650 None
1651 }
1652
1653 pub fn expect_variant_res(self, res: Res) -> &'tcx VariantDef {
1656 match res {
1657 Res::Def(DefKind::Variant, did) => {
1658 let enum_did = self.parent(did);
1659 self.adt_def(enum_did).variant_with_id(did)
1660 }
1661 Res::Def(DefKind::Struct | DefKind::Union, did) => self.adt_def(did).non_enum_variant(),
1662 Res::Def(DefKind::Ctor(CtorOf::Variant, ..), variant_ctor_did) => {
1663 let variant_did = self.parent(variant_ctor_did);
1664 let enum_did = self.parent(variant_did);
1665 self.adt_def(enum_did).variant_with_ctor_id(variant_ctor_did)
1666 }
1667 Res::Def(DefKind::Ctor(CtorOf::Struct, ..), ctor_did) => {
1668 let struct_did = self.parent(ctor_did);
1669 self.adt_def(struct_did).non_enum_variant()
1670 }
1671 _ => crate::util::bug::bug_fmt(format_args!("expect_variant_res used with unexpected res {0:?}",
res))bug!("expect_variant_res used with unexpected res {:?}", res),
1672 }
1673 }
1674
1675 #[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("instance_mir",
"rustc_middle::ty", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
::tracing_core::__macro_support::Option::Some(1676u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
::tracing_core::field::FieldSet::new(&["instance"],
::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(&instance)
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: &'tcx Body<'tcx> = loop {};
return __tracing_attr_fake_return;
}
{
match instance {
ty::InstanceKind::Item(def) => {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_middle/src/ty/mod.rs:1680",
"rustc_middle::ty", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
::tracing_core::__macro_support::Option::Some(1680u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
::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!("calling def_kind on def: {0:?}",
def) as &dyn Value))])
});
} else { ; }
};
let def_kind = self.def_kind(def);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_middle/src/ty/mod.rs:1682",
"rustc_middle::ty", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
::tracing_core::__macro_support::Option::Some(1682u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
::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!("returned from def_kind: {0:?}",
def_kind) as &dyn Value))])
});
} else { ; }
};
match def_kind {
DefKind::Const { .. } | DefKind::Static { .. } |
DefKind::AssocConst { .. } | DefKind::Ctor(..) |
DefKind::AnonConst | DefKind::InlineConst =>
self.mir_for_ctfe(def),
_ => self.optimized_mir(def),
}
}
ty::InstanceKind::VTableShim(..) |
ty::InstanceKind::ReifyShim(..) |
ty::InstanceKind::Intrinsic(..) |
ty::InstanceKind::FnPtrShim(..) |
ty::InstanceKind::Virtual(..) |
ty::InstanceKind::ClosureOnceShim { .. } |
ty::InstanceKind::ConstructCoroutineInClosureShim { .. } |
ty::InstanceKind::FutureDropPollShim(..) |
ty::InstanceKind::DropGlue(..) |
ty::InstanceKind::CloneShim(..) |
ty::InstanceKind::ThreadLocalShim(..) |
ty::InstanceKind::FnPtrAddrShim(..) |
ty::InstanceKind::AsyncDropGlueCtorShim(..) |
ty::InstanceKind::AsyncDropGlue(..) =>
self.mir_shims(instance),
}
}
}
}#[instrument(skip(self), level = "debug")]
1677 pub fn instance_mir(self, instance: ty::InstanceKind<'tcx>) -> &'tcx Body<'tcx> {
1678 match instance {
1679 ty::InstanceKind::Item(def) => {
1680 debug!("calling def_kind on def: {:?}", def);
1681 let def_kind = self.def_kind(def);
1682 debug!("returned from def_kind: {:?}", def_kind);
1683 match def_kind {
1684 DefKind::Const { .. }
1685 | DefKind::Static { .. }
1686 | DefKind::AssocConst { .. }
1687 | DefKind::Ctor(..)
1688 | DefKind::AnonConst
1689 | DefKind::InlineConst => self.mir_for_ctfe(def),
1690 _ => self.optimized_mir(def),
1693 }
1694 }
1695 ty::InstanceKind::VTableShim(..)
1696 | ty::InstanceKind::ReifyShim(..)
1697 | ty::InstanceKind::Intrinsic(..)
1698 | ty::InstanceKind::FnPtrShim(..)
1699 | ty::InstanceKind::Virtual(..)
1700 | ty::InstanceKind::ClosureOnceShim { .. }
1701 | ty::InstanceKind::ConstructCoroutineInClosureShim { .. }
1702 | ty::InstanceKind::FutureDropPollShim(..)
1703 | ty::InstanceKind::DropGlue(..)
1704 | ty::InstanceKind::CloneShim(..)
1705 | ty::InstanceKind::ThreadLocalShim(..)
1706 | ty::InstanceKind::FnPtrAddrShim(..)
1707 | ty::InstanceKind::AsyncDropGlueCtorShim(..)
1708 | ty::InstanceKind::AsyncDropGlue(..) => self.mir_shims(instance),
1709 }
1710 }
1711
1712 #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1714 pub fn get_attrs(
1715 self,
1716 did: impl Into<DefId>,
1717 attr: Symbol,
1718 ) -> impl Iterator<Item = &'tcx hir::Attribute> {
1719 #[allow(deprecated)]
1720 self.get_all_attrs(did).iter().filter(move |a: &&hir::Attribute| a.has_name(attr))
1721 }
1722
1723 #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1728 pub fn get_all_attrs(self, did: impl Into<DefId>) -> &'tcx [hir::Attribute] {
1729 let did: DefId = did.into();
1730 if let Some(did) = did.as_local() {
1731 self.hir_attrs(self.local_def_id_to_hir_id(did))
1732 } else {
1733 self.attrs_for_def(did)
1734 }
1735 }
1736
1737 pub fn get_attrs_by_path(
1738 self,
1739 did: DefId,
1740 attr: &[Symbol],
1741 ) -> impl Iterator<Item = &'tcx hir::Attribute> {
1742 let filter_fn = move |a: &&hir::Attribute| a.path_matches(attr);
1743 if let Some(did) = did.as_local() {
1744 self.hir_attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
1745 } else {
1746 self.attrs_for_def(did).iter().filter(filter_fn)
1747 }
1748 }
1749
1750 #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1751 pub fn get_attr(self, did: impl Into<DefId>, attr: Symbol) -> Option<&'tcx hir::Attribute> {
1752 if truecfg!(debug_assertions) && !rustc_feature::is_valid_for_get_attr(attr) {
1753 let did: DefId = did.into();
1754 crate::util::bug::bug_fmt(format_args!("get_attr: unexpected called with DefId `{0:?}`, attr `{1:?}`",
did, attr));bug!("get_attr: unexpected called with DefId `{:?}`, attr `{:?}`", did, attr);
1755 } else {
1756 #[allow(deprecated)]
1757 self.get_attrs(did, attr).next()
1758 }
1759 }
1760
1761 #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1763 pub fn has_attr(self, did: impl Into<DefId>, attr: Symbol) -> bool {
1764 #[allow(deprecated)]
1765 self.get_attrs(did, attr).next().is_some()
1766 }
1767
1768 pub fn has_attrs_with_path(self, did: impl Into<DefId>, attrs: &[Symbol]) -> bool {
1770 self.get_attrs_by_path(did.into(), attrs).next().is_some()
1771 }
1772
1773 pub fn trait_is_auto(self, trait_def_id: DefId) -> bool {
1775 self.trait_def(trait_def_id).has_auto_impl
1776 }
1777
1778 pub fn trait_is_coinductive(self, trait_def_id: DefId) -> bool {
1781 self.trait_def(trait_def_id).is_coinductive
1782 }
1783
1784 pub fn trait_is_alias(self, trait_def_id: DefId) -> bool {
1786 self.def_kind(trait_def_id) == DefKind::TraitAlias
1787 }
1788
1789 fn layout_error(self, err: LayoutError<'tcx>) -> &'tcx LayoutError<'tcx> {
1791 self.arena.alloc(err)
1792 }
1793
1794 fn ordinary_coroutine_layout(
1800 self,
1801 def_id: DefId,
1802 args: GenericArgsRef<'tcx>,
1803 ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
1804 let coroutine_kind_ty = args.as_coroutine().kind_ty();
1805 let mir = self.optimized_mir(def_id);
1806 let ty = || Ty::new_coroutine(self, def_id, args);
1807 if coroutine_kind_ty.is_unit() {
1809 mir.coroutine_layout_raw().ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1810 } else {
1811 let ty::Coroutine(_, identity_args) =
1814 *self.type_of(def_id).instantiate_identity().kind()
1815 else {
1816 ::core::panicking::panic("internal error: entered unreachable code");unreachable!();
1817 };
1818 let identity_kind_ty = identity_args.as_coroutine().kind_ty();
1819 if identity_kind_ty == coroutine_kind_ty {
1822 mir.coroutine_layout_raw()
1823 .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1824 } else {
1825 match coroutine_kind_ty.to_opt_closure_kind() {
Some(ClosureKind::FnOnce) => {}
ref left_val => {
::core::panicking::assert_matches_failed(left_val,
"Some(ClosureKind::FnOnce)", ::core::option::Option::None);
}
};assert_matches!(coroutine_kind_ty.to_opt_closure_kind(), Some(ClosureKind::FnOnce));
1826 match identity_kind_ty.to_opt_closure_kind() {
Some(ClosureKind::Fn | ClosureKind::FnMut) => {}
ref left_val => {
::core::panicking::assert_matches_failed(left_val,
"Some(ClosureKind::Fn | ClosureKind::FnMut)",
::core::option::Option::None);
}
};assert_matches!(
1827 identity_kind_ty.to_opt_closure_kind(),
1828 Some(ClosureKind::Fn | ClosureKind::FnMut)
1829 );
1830 self.optimized_mir(self.coroutine_by_move_body_def_id(def_id))
1831 .coroutine_layout_raw()
1832 .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1833 }
1834 }
1835 }
1836
1837 fn async_drop_coroutine_layout(
1841 self,
1842 def_id: DefId,
1843 args: GenericArgsRef<'tcx>,
1844 ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
1845 let ty = || Ty::new_coroutine(self, def_id, args);
1846 if args[0].has_placeholders() || args[0].has_non_region_param() {
1847 return Err(self.layout_error(LayoutError::TooGeneric(ty())));
1848 }
1849 let instance = InstanceKind::AsyncDropGlue(def_id, Ty::new_coroutine(self, def_id, args));
1850 self.mir_shims(instance)
1851 .coroutine_layout_raw()
1852 .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1853 }
1854
1855 pub fn coroutine_layout(
1858 self,
1859 def_id: DefId,
1860 args: GenericArgsRef<'tcx>,
1861 ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
1862 if self.is_async_drop_in_place_coroutine(def_id) {
1863 let arg_cor_ty = args.first().unwrap().expect_ty();
1867 if arg_cor_ty.is_coroutine() {
1868 let span = self.def_span(def_id);
1869 let source_info = SourceInfo::outermost(span);
1870 let variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>> =
1873 iter::repeat(IndexVec::new()).take(CoroutineArgs::RESERVED_VARIANTS).collect();
1874 let variant_source_info: IndexVec<VariantIdx, SourceInfo> =
1875 iter::repeat(source_info).take(CoroutineArgs::RESERVED_VARIANTS).collect();
1876 let proxy_layout = CoroutineLayout {
1877 field_tys: [].into(),
1878 field_names: [].into(),
1879 variant_fields,
1880 variant_source_info,
1881 storage_conflicts: BitMatrix::new(0, 0),
1882 };
1883 return Ok(self.arena.alloc(proxy_layout));
1884 } else {
1885 self.async_drop_coroutine_layout(def_id, args)
1886 }
1887 } else {
1888 self.ordinary_coroutine_layout(def_id, args)
1889 }
1890 }
1891
1892 pub fn assoc_parent(self, def_id: DefId) -> Option<(DefId, DefKind)> {
1894 if !self.def_kind(def_id).is_assoc() {
1895 return None;
1896 }
1897 let parent = self.parent(def_id);
1898 let def_kind = self.def_kind(parent);
1899 Some((parent, def_kind))
1900 }
1901
1902 pub fn trait_item_of(self, def_id: impl IntoQueryParam<DefId>) -> Option<DefId> {
1904 self.opt_associated_item(def_id.into_query_param())?.trait_item_def_id()
1905 }
1906
1907 pub fn trait_of_assoc(self, def_id: DefId) -> Option<DefId> {
1910 match self.assoc_parent(def_id) {
1911 Some((id, DefKind::Trait)) => Some(id),
1912 _ => None,
1913 }
1914 }
1915
1916 pub fn impl_is_of_trait(self, def_id: impl IntoQueryParam<DefId>) -> bool {
1917 let def_id = def_id.into_query_param();
1918 let DefKind::Impl { of_trait } = self.def_kind(def_id) else {
1919 {
::core::panicking::panic_fmt(format_args!("expected Impl for {0:?}",
def_id));
};panic!("expected Impl for {def_id:?}");
1920 };
1921 of_trait
1922 }
1923
1924 pub fn impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
1927 match self.assoc_parent(def_id) {
1928 Some((id, DefKind::Impl { .. })) => Some(id),
1929 _ => None,
1930 }
1931 }
1932
1933 pub fn inherent_impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
1936 match self.assoc_parent(def_id) {
1937 Some((id, DefKind::Impl { of_trait: false })) => Some(id),
1938 _ => None,
1939 }
1940 }
1941
1942 pub fn trait_impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
1945 match self.assoc_parent(def_id) {
1946 Some((id, DefKind::Impl { of_trait: true })) => Some(id),
1947 _ => None,
1948 }
1949 }
1950
1951 pub fn impl_polarity(self, def_id: impl IntoQueryParam<DefId>) -> ty::ImplPolarity {
1952 self.impl_trait_header(def_id).polarity
1953 }
1954
1955 pub fn impl_trait_ref(
1957 self,
1958 def_id: impl IntoQueryParam<DefId>,
1959 ) -> ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>> {
1960 self.impl_trait_header(def_id).trait_ref
1961 }
1962
1963 pub fn impl_opt_trait_ref(
1966 self,
1967 def_id: impl IntoQueryParam<DefId>,
1968 ) -> Option<ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>> {
1969 let def_id = def_id.into_query_param();
1970 self.impl_is_of_trait(def_id).then(|| self.impl_trait_ref(def_id))
1971 }
1972
1973 pub fn impl_trait_id(self, def_id: impl IntoQueryParam<DefId>) -> DefId {
1975 self.impl_trait_ref(def_id).skip_binder().def_id
1976 }
1977
1978 pub fn impl_opt_trait_id(self, def_id: impl IntoQueryParam<DefId>) -> Option<DefId> {
1981 let def_id = def_id.into_query_param();
1982 self.impl_is_of_trait(def_id).then(|| self.impl_trait_id(def_id))
1983 }
1984
1985 pub fn is_exportable(self, def_id: DefId) -> bool {
1986 self.exportable_items(def_id.krate).contains(&def_id)
1987 }
1988
1989 pub fn is_builtin_derived(self, def_id: DefId) -> bool {
1992 if self.is_automatically_derived(def_id)
1993 && let Some(def_id) = def_id.as_local()
1994 && let outer = self.def_span(def_id).ctxt().outer_expn_data()
1995 && #[allow(non_exhaustive_omitted_patterns)] match outer.kind {
ExpnKind::Macro(MacroKind::Derive, _) => true,
_ => false,
}matches!(outer.kind, ExpnKind::Macro(MacroKind::Derive, _))
1996 && {
#[allow(deprecated)]
{
{
'done:
{
for i in self.get_all_attrs(outer.macro_def_id.unwrap()) {
#[allow(unused_imports)]
use rustc_hir::attrs::AttributeKind::*;
let i: &rustc_hir::Attribute = i;
match i {
rustc_hir::Attribute::Parsed(RustcBuiltinMacro { .. }) => {
break 'done Some(());
}
rustc_hir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}
}.is_some()find_attr!(self, outer.macro_def_id.unwrap(), RustcBuiltinMacro { .. })
1997 {
1998 true
1999 } else {
2000 false
2001 }
2002 }
2003
2004 pub fn is_automatically_derived(self, def_id: DefId) -> bool {
2006 {
#[allow(deprecated)]
{
{
'done:
{
for i in self.get_all_attrs(def_id) {
#[allow(unused_imports)]
use rustc_hir::attrs::AttributeKind::*;
let i: &rustc_hir::Attribute = i;
match i {
rustc_hir::Attribute::Parsed(AutomaticallyDerived(..)) => {
break 'done Some(());
}
rustc_hir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}
}.is_some()find_attr!(self, def_id, AutomaticallyDerived(..))
2007 }
2008
2009 pub fn span_of_impl(self, impl_def_id: DefId) -> Result<Span, Symbol> {
2012 if let Some(impl_def_id) = impl_def_id.as_local() {
2013 Ok(self.def_span(impl_def_id))
2014 } else {
2015 Err(self.crate_name(impl_def_id.krate))
2016 }
2017 }
2018
2019 pub fn hygienic_eq(self, use_ident: Ident, def_ident: Ident, def_parent_def_id: DefId) -> bool {
2023 use_ident.name == def_ident.name
2027 && use_ident
2028 .span
2029 .ctxt()
2030 .hygienic_eq(def_ident.span.ctxt(), self.expn_that_defined(def_parent_def_id))
2031 }
2032
2033 pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident {
2034 ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope));
2035 ident
2036 }
2037
2038 pub fn adjust_ident_and_get_scope(
2040 self,
2041 mut ident: Ident,
2042 scope: DefId,
2043 block: hir::HirId,
2044 ) -> (Ident, DefId) {
2045 let scope = ident
2046 .span
2047 .normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope))
2048 .and_then(|actual_expansion| actual_expansion.expn_data().parent_module)
2049 .unwrap_or_else(|| self.parent_module(block).to_def_id());
2050 (ident, scope)
2051 }
2052
2053 #[inline]
2057 pub fn is_const_fn(self, def_id: DefId) -> bool {
2058 #[allow(non_exhaustive_omitted_patterns)] match self.def_kind(def_id) {
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn) |
DefKind::Closure => true,
_ => false,
}matches!(
2059 self.def_kind(def_id),
2060 DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn) | DefKind::Closure
2061 ) && self.constness(def_id) == hir::Constness::Const
2062 }
2063
2064 pub fn is_conditionally_const(self, def_id: impl Into<DefId>) -> bool {
2071 let def_id: DefId = def_id.into();
2072 match self.def_kind(def_id) {
2073 DefKind::Impl { of_trait: true } => {
2074 let header = self.impl_trait_header(def_id);
2075 header.constness == hir::Constness::Const
2076 && self.is_const_trait(header.trait_ref.skip_binder().def_id)
2077 }
2078 DefKind::Impl { of_trait: false } => self.constness(def_id) == hir::Constness::Const,
2079 DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) => {
2080 self.constness(def_id) == hir::Constness::Const
2081 }
2082 DefKind::TraitAlias | DefKind::Trait => self.is_const_trait(def_id),
2083 DefKind::AssocTy => {
2084 let parent_def_id = self.parent(def_id);
2085 match self.def_kind(parent_def_id) {
2086 DefKind::Impl { of_trait: false } => false,
2087 DefKind::Impl { of_trait: true } | DefKind::Trait => {
2088 self.is_conditionally_const(parent_def_id)
2089 }
2090 _ => crate::util::bug::bug_fmt(format_args!("unexpected parent item of associated type: {0:?}",
parent_def_id))bug!("unexpected parent item of associated type: {parent_def_id:?}"),
2091 }
2092 }
2093 DefKind::AssocFn => {
2094 let parent_def_id = self.parent(def_id);
2095 match self.def_kind(parent_def_id) {
2096 DefKind::Impl { of_trait: false } => {
2097 self.constness(def_id) == hir::Constness::Const
2098 }
2099 DefKind::Impl { of_trait: true } => {
2100 let Some(trait_method_did) = self.trait_item_of(def_id) else {
2101 return false;
2102 };
2103 self.constness(trait_method_did) == hir::Constness::Const
2104 && self.is_conditionally_const(parent_def_id)
2105 }
2106 DefKind::Trait => {
2107 self.constness(def_id) == hir::Constness::Const
2108 && self.is_conditionally_const(parent_def_id)
2109 }
2110 _ => crate::util::bug::bug_fmt(format_args!("unexpected parent item of associated fn: {0:?}",
parent_def_id))bug!("unexpected parent item of associated fn: {parent_def_id:?}"),
2111 }
2112 }
2113 DefKind::OpaqueTy => match self.opaque_ty_origin(def_id) {
2114 hir::OpaqueTyOrigin::FnReturn { parent, .. } => self.is_conditionally_const(parent),
2115 hir::OpaqueTyOrigin::AsyncFn { .. } => false,
2116 hir::OpaqueTyOrigin::TyAlias { .. } => false,
2118 },
2119 DefKind::Closure => {
2120 false
2123 }
2124 DefKind::Ctor(_, CtorKind::Const)
2125 | DefKind::Mod
2126 | DefKind::Struct
2127 | DefKind::Union
2128 | DefKind::Enum
2129 | DefKind::Variant
2130 | DefKind::TyAlias
2131 | DefKind::ForeignTy
2132 | DefKind::TyParam
2133 | DefKind::Const { .. }
2134 | DefKind::ConstParam
2135 | DefKind::Static { .. }
2136 | DefKind::AssocConst { .. }
2137 | DefKind::Macro(_)
2138 | DefKind::ExternCrate
2139 | DefKind::Use
2140 | DefKind::ForeignMod
2141 | DefKind::AnonConst
2142 | DefKind::InlineConst
2143 | DefKind::Field
2144 | DefKind::LifetimeParam
2145 | DefKind::GlobalAsm
2146 | DefKind::SyntheticCoroutineBody => false,
2147 }
2148 }
2149
2150 #[inline]
2151 pub fn is_const_trait(self, def_id: DefId) -> bool {
2152 self.trait_def(def_id).constness == hir::Constness::Const
2153 }
2154
2155 pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool {
2156 if self.def_kind(def_id) != DefKind::AssocFn {
2157 return false;
2158 }
2159
2160 let Some(item) = self.opt_associated_item(def_id) else {
2161 return false;
2162 };
2163
2164 let AssocContainer::TraitImpl(Ok(trait_item_def_id)) = item.container else {
2165 return false;
2166 };
2167
2168 !self.associated_types_for_impl_traits_in_associated_fn(trait_item_def_id).is_empty()
2169 }
2170}
2171
2172pub fn provide(providers: &mut Providers) {
2173 closure::provide(providers);
2174 context::provide(providers);
2175 erase_regions::provide(providers);
2176 inhabitedness::provide(providers);
2177 util::provide(providers);
2178 print::provide(providers);
2179 super::util::bug::provide(providers);
2180 *providers = Providers {
2181 trait_impls_of: trait_def::trait_impls_of_provider,
2182 incoherent_impls: trait_def::incoherent_impls_provider,
2183 trait_impls_in_crate: trait_def::trait_impls_in_crate_provider,
2184 traits: trait_def::traits_provider,
2185 vtable_allocation: vtable::vtable_allocation_provider,
2186 ..*providers
2187 };
2188}
2189
2190#[derive(#[automatically_derived]
impl ::core::clone::Clone for CrateInherentImpls {
#[inline]
fn clone(&self) -> CrateInherentImpls {
CrateInherentImpls {
inherent_impls: ::core::clone::Clone::clone(&self.inherent_impls),
incoherent_impls: ::core::clone::Clone::clone(&self.incoherent_impls),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CrateInherentImpls {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"CrateInherentImpls", "inherent_impls", &self.inherent_impls,
"incoherent_impls", &&self.incoherent_impls)
}
}Debug, #[automatically_derived]
impl ::core::default::Default for CrateInherentImpls {
#[inline]
fn default() -> CrateInherentImpls {
CrateInherentImpls {
inherent_impls: ::core::default::Default::default(),
incoherent_impls: ::core::default::Default::default(),
}
}
}Default, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for CrateInherentImpls {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
CrateInherentImpls {
inherent_impls: ref __binding_0,
incoherent_impls: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
2196pub struct CrateInherentImpls {
2197 pub inherent_impls: FxIndexMap<LocalDefId, Vec<DefId>>,
2198 pub incoherent_impls: FxIndexMap<SimplifiedType, Vec<LocalDefId>>,
2199}
2200
2201#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for SymbolName<'tcx> {
#[inline]
fn clone(&self) -> SymbolName<'tcx> {
let _: ::core::clone::AssertParamIsClone<&'tcx str>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for SymbolName<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for SymbolName<'tcx> {
#[inline]
fn eq(&self, other: &SymbolName<'tcx>) -> bool { self.name == other.name }
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for SymbolName<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<&'tcx str>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialOrd for SymbolName<'tcx> {
#[inline]
fn partial_cmp(&self, other: &SymbolName<'tcx>)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::cmp::PartialOrd::partial_cmp(&self.name, &other.name)
}
}PartialOrd, #[automatically_derived]
impl<'tcx> ::core::cmp::Ord for SymbolName<'tcx> {
#[inline]
fn cmp(&self, other: &SymbolName<'tcx>) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.name, &other.name)
}
}Ord, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for SymbolName<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.name, state)
}
}Hash, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for SymbolName<'tcx> {
fn encode(&self, __encoder: &mut __E) {
match *self {
SymbolName { name: __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for SymbolName<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
SymbolName { name: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
2202pub struct SymbolName<'tcx> {
2203 pub name: &'tcx str,
2205}
2206
2207impl<'tcx> SymbolName<'tcx> {
2208 pub fn new(tcx: TyCtxt<'tcx>, name: &str) -> SymbolName<'tcx> {
2209 SymbolName { name: tcx.arena.alloc_str(name) }
2210 }
2211}
2212
2213impl<'tcx> fmt::Display for SymbolName<'tcx> {
2214 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2215 fmt::Display::fmt(&self.name, fmt)
2216 }
2217}
2218
2219impl<'tcx> fmt::Debug for SymbolName<'tcx> {
2220 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2221 fmt::Display::fmt(&self.name, fmt)
2222 }
2223}
2224
2225#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for DestructuredAdtConst<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for DestructuredAdtConst<'tcx> {
#[inline]
fn clone(&self) -> DestructuredAdtConst<'tcx> {
let _: ::core::clone::AssertParamIsClone<VariantIdx>;
let _: ::core::clone::AssertParamIsClone<&'tcx [ty::Const<'tcx>]>;
*self
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for DestructuredAdtConst<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DestructuredAdtConst", "variant", &self.variant, "fields",
&&self.fields)
}
}Debug, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
for DestructuredAdtConst<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
DestructuredAdtConst {
variant: ref __binding_0, fields: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
2227pub struct DestructuredAdtConst<'tcx> {
2228 pub variant: VariantIdx,
2229 pub fields: &'tcx [ty::Const<'tcx>],
2230}
2231
2232pub fn fnc_typetrees<'tcx>(tcx: TyCtxt<'tcx>, fn_ty: Ty<'tcx>) -> FncTree {
2236 if tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::NoTT) {
2238 return FncTree { args: ::alloc::vec::Vec::new()vec![], ret: TypeTree::new() };
2239 }
2240
2241 if !fn_ty.is_fn() {
2243 return FncTree { args: ::alloc::vec::Vec::new()vec![], ret: TypeTree::new() };
2244 }
2245
2246 let fn_sig = fn_ty.fn_sig(tcx);
2248 let sig = tcx.instantiate_bound_regions_with_erased(fn_sig);
2249
2250 let mut args = ::alloc::vec::Vec::new()vec![];
2252 for ty in sig.inputs().iter() {
2253 let type_tree = typetree_from_ty(tcx, *ty);
2254 args.push(type_tree);
2255 }
2256
2257 let ret = typetree_from_ty(tcx, sig.output());
2259
2260 FncTree { args, ret }
2261}
2262
2263pub fn typetree_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> TypeTree {
2266 let mut visited = Vec::new();
2267 typetree_from_ty_inner(tcx, ty, 0, &mut visited)
2268}
2269
2270const MAX_TYPETREE_DEPTH: usize = 6;
2273
2274fn typetree_from_ty_inner<'tcx>(
2276 tcx: TyCtxt<'tcx>,
2277 ty: Ty<'tcx>,
2278 depth: usize,
2279 visited: &mut Vec<Ty<'tcx>>,
2280) -> TypeTree {
2281 if depth >= MAX_TYPETREE_DEPTH {
2282 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_middle/src/ty/mod.rs:2282",
"rustc_middle::ty", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
::tracing_core::__macro_support::Option::Some(2282u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::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!("typetree depth limit {0} reached for type: {1}",
MAX_TYPETREE_DEPTH, ty) as &dyn Value))])
});
} else { ; }
};trace!("typetree depth limit {} reached for type: {}", MAX_TYPETREE_DEPTH, ty);
2283 return TypeTree::new();
2284 }
2285
2286 if visited.contains(&ty) {
2287 return TypeTree::new();
2288 }
2289
2290 visited.push(ty);
2291 let result = typetree_from_ty_impl(tcx, ty, depth, visited);
2292 visited.pop();
2293 result
2294}
2295
2296fn typetree_from_ty_impl<'tcx>(
2298 tcx: TyCtxt<'tcx>,
2299 ty: Ty<'tcx>,
2300 depth: usize,
2301 visited: &mut Vec<Ty<'tcx>>,
2302) -> TypeTree {
2303 typetree_from_ty_impl_inner(tcx, ty, depth, visited, false)
2304}
2305
2306fn typetree_from_ty_impl_inner<'tcx>(
2308 tcx: TyCtxt<'tcx>,
2309 ty: Ty<'tcx>,
2310 depth: usize,
2311 visited: &mut Vec<Ty<'tcx>>,
2312 is_reference_target: bool,
2313) -> TypeTree {
2314 if ty.is_scalar() {
2315 let (kind, size) = if ty.is_integral() || ty.is_char() || ty.is_bool() {
2316 (Kind::Integer, ty.primitive_size(tcx).bytes_usize())
2317 } else if ty.is_floating_point() {
2318 match ty {
2319 x if x == tcx.types.f16 => (Kind::Half, 2),
2320 x if x == tcx.types.f32 => (Kind::Float, 4),
2321 x if x == tcx.types.f64 => (Kind::Double, 8),
2322 x if x == tcx.types.f128 => (Kind::F128, 16),
2323 _ => (Kind::Integer, 0),
2324 }
2325 } else {
2326 (Kind::Integer, 0)
2327 };
2328
2329 let offset = if is_reference_target && !ty.is_array() { 0 } else { -1 };
2332 return TypeTree(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[Type { offset, size, kind, child: TypeTree::new() }]))vec![Type { offset, size, kind, child: TypeTree::new() }]);
2333 }
2334
2335 if ty.is_ref() || ty.is_raw_ptr() || ty.is_box() {
2336 let Some(inner_ty) = ty.builtin_deref(true) else {
2337 return TypeTree::new();
2338 };
2339
2340 let child = typetree_from_ty_impl_inner(tcx, inner_ty, depth + 1, visited, true);
2341 return TypeTree(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[Type {
offset: -1,
size: tcx.data_layout.pointer_size().bytes_usize(),
kind: Kind::Pointer,
child,
}]))vec![Type {
2342 offset: -1,
2343 size: tcx.data_layout.pointer_size().bytes_usize(),
2344 kind: Kind::Pointer,
2345 child,
2346 }]);
2347 }
2348
2349 if ty.is_array() {
2350 if let ty::Array(element_ty, len_const) = ty.kind() {
2351 let len = len_const.try_to_target_usize(tcx).unwrap_or(0);
2352 if len == 0 {
2353 return TypeTree::new();
2354 }
2355 let element_tree =
2356 typetree_from_ty_impl_inner(tcx, *element_ty, depth + 1, visited, false);
2357 let mut types = Vec::new();
2358 for elem_type in &element_tree.0 {
2359 types.push(Type {
2360 offset: -1,
2361 size: elem_type.size,
2362 kind: elem_type.kind,
2363 child: elem_type.child.clone(),
2364 });
2365 }
2366
2367 return TypeTree(types);
2368 }
2369 }
2370
2371 if ty.is_slice() {
2372 if let ty::Slice(element_ty) = ty.kind() {
2373 let element_tree =
2374 typetree_from_ty_impl_inner(tcx, *element_ty, depth + 1, visited, false);
2375 return element_tree;
2376 }
2377 }
2378
2379 if let ty::Tuple(tuple_types) = ty.kind() {
2380 if tuple_types.is_empty() {
2381 return TypeTree::new();
2382 }
2383
2384 let mut types = Vec::new();
2385 let mut current_offset = 0;
2386
2387 for tuple_ty in tuple_types.iter() {
2388 let element_tree =
2389 typetree_from_ty_impl_inner(tcx, tuple_ty, depth + 1, visited, false);
2390
2391 let element_layout = tcx
2392 .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(tuple_ty))
2393 .ok()
2394 .map(|layout| layout.size.bytes_usize())
2395 .unwrap_or(0);
2396
2397 for elem_type in &element_tree.0 {
2398 types.push(Type {
2399 offset: if elem_type.offset == -1 {
2400 current_offset as isize
2401 } else {
2402 current_offset as isize + elem_type.offset
2403 },
2404 size: elem_type.size,
2405 kind: elem_type.kind,
2406 child: elem_type.child.clone(),
2407 });
2408 }
2409
2410 current_offset += element_layout;
2411 }
2412
2413 return TypeTree(types);
2414 }
2415
2416 if let ty::Adt(adt_def, args) = ty.kind() {
2417 if adt_def.is_struct() {
2418 let struct_layout =
2419 tcx.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(ty));
2420 if let Ok(layout) = struct_layout {
2421 let mut types = Vec::new();
2422
2423 for (field_idx, field_def) in adt_def.all_fields().enumerate() {
2424 let field_ty = field_def.ty(tcx, args);
2425 let field_tree =
2426 typetree_from_ty_impl_inner(tcx, field_ty, depth + 1, visited, false);
2427
2428 let field_offset = layout.fields.offset(field_idx).bytes_usize();
2429
2430 for elem_type in &field_tree.0 {
2431 types.push(Type {
2432 offset: if elem_type.offset == -1 {
2433 field_offset as isize
2434 } else {
2435 field_offset as isize + elem_type.offset
2436 },
2437 size: elem_type.size,
2438 kind: elem_type.kind,
2439 child: elem_type.child.clone(),
2440 });
2441 }
2442 }
2443
2444 return TypeTree(types);
2445 }
2446 }
2447 }
2448
2449 TypeTree::new()
2450}