-------------------------------------------------------------------------------- I1 cache: 65536 B, 64 B, 4-way associative D1 cache: 32768 B, 64 B, 8-way associative LL cache: 67108864 B, 64 B, 64-way associative Command: /usr/home/liquid/.rustup/toolchains/w-profiling/bin/rustc --crate-name actix_http --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg feature="default" -C metadata=b115854ddd36c30e -C extra-filename=-b115854ddd36c30e --out-dir /usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps -L dependency=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps --extern actix_codec=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libactix_codec-5e28e0826720f258.rmeta --extern actix_rt=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libactix_rt-c0e1e9a792d24d2f.rmeta --extern actix_service=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libactix_service-f4be91b95b4f7329.rmeta --extern actix_utils=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libactix_utils-52d559027f2b9534.rmeta --extern ahash=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libahash-d94d1cce44884ffd.rmeta --extern base64=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libbase64-54768d166c405115.rmeta --extern bitflags=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libbitflags-923cad7af34a271a.rmeta --extern bytes=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libbytes-98dd37541556b672.rmeta --extern bytestring=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libbytestring-b41b27931ed91004.rmeta --extern derive_more=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libderive_more-8d7a466530671496.so --extern encoding_rs=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libencoding_rs-db6e50ee6229bf12.rmeta --extern futures_core=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libfutures_core-a2d93a201d329a91.rmeta --extern h2=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libh2-75a78465102b8892.rmeta --extern http=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libhttp-afd68132e94f7972.rmeta --extern httparse=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libhttparse-e094dd5d41db71f0.rmeta --extern httpdate=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libhttpdate-5cf49b7f6952d8ca.rmeta --extern itoa=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libitoa-d4730e97a104a01d.rmeta --extern language_tags=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/liblanguage_tags-b1f99bc652e69b8a.rmeta --extern local_channel=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/liblocal_channel-4dd4d9c7182d184c.rmeta --extern log=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/liblog-66ade8caaf0ded5f.rmeta --extern mime=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libmime-6505a59d8d83a89e.rmeta --extern percent_encoding=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libpercent_encoding-c459b8b7cc5f75c4.rmeta --extern pin_project_lite=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libpin_project_lite-5e3822a68863ba80.rmeta --extern rand=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/librand-8766964bd4b3d5c8.rmeta --extern sha1=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libsha1-bdaf7fd74573f616.rmeta --extern smallvec=/usr/home/liquid/tmp/.tmpeN3Kzf/target/release/deps/libsmallvec-36e177f658a81798.rmeta -Adeprecated -Aunknown-lints -Zincremental-verify-ich Data file: results/cgout-w-profiling-actix-http-3.0.0-beta.19-Opt-Full Events recorded: Ir Events shown: Ir Event sort order: Ir Thresholds: 0.1 Include dirs: User annotated: Auto-annotation: on -------------------------------------------------------------------------------- Ir -------------------------------------------------------------------------------- 38,598,359,764 (100.0%) PROGRAM TOTALS -------------------------------------------------------------------------------- Ir file:function -------------------------------------------------------------------------------- 1,141,747,256 ( 2.96%) ./malloc/malloc.c:_int_free 1,015,248,210 ( 2.63%) ./malloc/malloc.c:_int_malloc 743,032,174 ( 1.93%) ???:llvm::InstCombinerImpl::run() 718,722,400 ( 1.86%) ./malloc/malloc.c:malloc 589,985,893 ( 1.53%) ???:llvm::FPPassManager::runOnFunction(llvm::Function&) 559,653,857 ( 1.45%) ???:llvm::BitstreamCursor::readRecord(unsigned int, llvm::SmallVectorImpl&, llvm::StringRef*) 510,812,658 ( 1.32%) ???:combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, unsigned int, llvm::LoopInfo*) 421,728,431 ( 1.09%) ???:llvm::AnalysisManager::getResultImpl(llvm::AnalysisKey*, llvm::Function&) 419,937,697 ( 1.09%) ???:llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) 405,130,135 ( 1.05%) ???:llvm::AnalysisManager::invalidate(llvm::Function&, llvm::PreservedAnalyses const&) 372,801,541 ( 0.97%) ./malloc/malloc.c:free 309,612,407 ( 0.80%) ???:computeKnownBits(llvm::Value const*, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) [clone .llvm.15619146473165121143] 306,613,514 ( 0.79%) ???:llvm::BasicAAResult::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&, llvm::AAQueryInfo&) 300,630,069 ( 0.78%) ???:computeKnownBits(llvm::Value const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) 299,254,430 ( 0.78%) ???:llvm::AttributeList::get(llvm::LLVMContext&, llvm::ArrayRef) 292,508,572 ( 0.76%) ???:llvm::isNonEscapingLocalObject(llvm::Value const*, llvm::SmallDenseMap, llvm::detail::DenseMapPair >*) 267,655,461 ( 0.69%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::CalculateFromScratch(llvm::DominatorTreeBase&, llvm::DomTreeBuilder::SemiNCAInfo >::BatchUpdateInfo*) 257,143,502 ( 0.67%) ???:llvm::ValueHandleBase::AddToUseList() 256,694,933 ( 0.67%) ???:computeKnownBitsFromOperator(llvm::Operator const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) 247,285,650 ( 0.64%) ???:runCVP(llvm::Module&) [clone .llvm.11785992503873176614] 232,101,481 ( 0.60%) ???:llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const 229,454,206 ( 0.59%) ???:llvm::DataLayout::getAlignment(llvm::Type*, bool) const 225,285,005 ( 0.58%) ???:bool llvm::DenseMapBase*, llvm::DenseMapInfo<(anonymous namespace)::SimpleValue>, llvm::detail::DenseMapPair<(anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*> >, (anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*, llvm::DenseMapInfo<(anonymous namespace)::SimpleValue>, llvm::detail::DenseMapPair<(anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*> >::LookupBucketFor<(anonymous namespace)::SimpleValue>((anonymous namespace)::SimpleValue const&, llvm::detail::DenseMapPair<(anonymous namespace)::SimpleValue, llvm::ScopedHashTableVal<(anonymous namespace)::SimpleValue, llvm::Value*>*> const*&) const 224,374,032 ( 0.58%) ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:__memcmp_avx2_movbe 220,615,328 ( 0.57%) ???:llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const 211,142,591 ( 0.55%) ???:(anonymous namespace)::LazyValueInfoImpl::solve() [clone .llvm.4316243980339171764] 206,958,011 ( 0.54%) ???:llvm::TargetLibraryInfoImpl::getLibFunc(llvm::Function const&, llvm::LibFunc&) const 195,267,153 ( 0.51%) ???:llvm::removeUnreachableBlocks(llvm::Function&, llvm::DomTreeUpdater*, llvm::MemorySSAUpdater*) 186,871,250 ( 0.48%) ???:llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) 179,587,010 ( 0.47%) ???:llvm::SimplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&, llvm::OptimizationRemarkEmitter*) 175,681,257 ( 0.46%) ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms 174,142,316 ( 0.45%) ???:SimplifyICmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) [clone .llvm.1619516508949622737] 172,905,836 ( 0.45%) ???:computeKnownBitsFromAssume(llvm::Value const*, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) 170,745,868 ( 0.44%) ???:llvm::AttributeSetNode::get(llvm::LLVMContext&, llvm::AttrBuilder const&) 166,905,837 ( 0.43%) ???:(anonymous namespace)::LazyValueInfoImpl::getEdgeValue(llvm::Value*, llvm::BasicBlock*, llvm::BasicBlock*, llvm::Instruction*) [clone .llvm.4316243980339171764] 156,662,127 ( 0.41%) ./malloc/malloc.c:malloc_consolidate 151,629,744 ( 0.39%) ???:llvm::LiveVariables::runOnBlock(llvm::MachineBasicBlock*, unsigned int) 133,931,334 ( 0.35%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::runSemiNCA(llvm::DominatorTreeBase&, unsigned int) 129,233,233 ( 0.33%) ???:llvm::InlineFunction(llvm::CallBase&, llvm::InlineFunctionInfo&, llvm::AAResults*, bool, llvm::Function*) 129,008,213 ( 0.33%) ???:llvm::InstCombinerImpl::visitICmpInst(llvm::ICmpInst&) 126,500,021 ( 0.33%) ???:isKnownNonZero(llvm::Value const*, llvm::APInt const&, unsigned int, (anonymous namespace)::Query const&) [clone .llvm.15619146473165121143] 126,362,554 ( 0.33%) ???:(anonymous namespace)::BitcodeReader::parseModule(unsigned long, bool, llvm::function_ref, std::allocator > > (llvm::StringRef)>) 121,563,262 ( 0.31%) ???:llvm::coro::declaresIntrinsics(llvm::Module const&, std::initializer_list) 121,262,361 ( 0.31%) /tmp/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/../../../../gcc-5.5.0/libstdc++-v3/libsupc++/new_op.cc:operator new(unsigned long) 119,748,374 ( 0.31%) ???:llvm::FindFunctionBackedges(llvm::Function const&, llvm::SmallVectorImpl >&) 118,604,677 ( 0.31%) ???:llvm::simplifyCFG(llvm::BasicBlock*, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&, llvm::ArrayRef) 118,459,816 ( 0.31%) ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_erms 114,966,152 ( 0.30%) ???:llvm::SimplifyGEPInst(llvm::Type*, llvm::ArrayRef, llvm::SimplifyQuery const&) 113,336,878 ( 0.29%) ???:(anonymous namespace)::MachineCopyPropagation::runOnMachineFunction(llvm::MachineFunction&) 112,935,494 ( 0.29%) ???:llvm::MD5::final(llvm::MD5::MD5Result&) 112,323,968 ( 0.29%) ???:llvm::InstCombinerImpl::visitLoadInst(llvm::LoadInst&) 112,026,994 ( 0.29%) ???:(anonymous namespace)::EarlyCSE::run() [clone .llvm.7062997131228810369] 111,807,347 ( 0.29%) ???:llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) 109,866,977 ( 0.28%) ./string/../sysdeps/x86_64/multiarch/strcmp-avx2.S:__strncmp_avx2 106,962,451 ( 0.28%) ???:llvm::MemorySSA::buildMemorySSA(llvm::BatchAAResults&) 105,393,882 ( 0.27%) ./malloc/malloc.c:unlink_chunk.constprop.0 100,000,826 ( 0.26%) ???:llvm::detail::PassModel>, llvm::PreservedAnalyses, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) 99,670,781 ( 0.26%) ???:llvm::PMDataManager::verifyPreservedAnalysis(llvm::Pass*) 96,687,014 ( 0.25%) ???:llvm::GVN::processBlock(llvm::BasicBlock*) 94,028,789 ( 0.24%) ???:llvm::MD5::update(llvm::StringRef) 91,981,764 ( 0.24%) ???:(anonymous namespace)::eliminateDeadStores(llvm::Function&, llvm::AAResults&, llvm::MemorySSA&, llvm::DominatorTree&, llvm::PostDominatorTree&, llvm::TargetLibraryInfo const&, llvm::LoopInfo const&) [clone .llvm.5769264623867638418] 91,340,869 ( 0.24%) ???:(anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) 87,018,938 ( 0.23%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/sty.rs:::eq 85,779,110 ( 0.22%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::CalculateFromScratch(llvm::DominatorTreeBase&, llvm::DomTreeBuilder::SemiNCAInfo >::BatchUpdateInfo*) 85,562,653 ( 0.22%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:, (), core::hash::BuildHasherDefault>>::from_hash::>::{closure#0}> 84,850,288 ( 0.22%) ???:llvm::MemoryDependenceResults::getNonLocalPointerDepFromBB(llvm::Instruction*, llvm::PHITransAddr const&, llvm::MemoryLocation const&, bool, llvm::BasicBlock*, llvm::SmallVectorImpl&, llvm::DenseMap, llvm::detail::DenseMapPair >&, bool, bool) 84,670,933 ( 0.22%) ???:(anonymous namespace)::PruningFunctionCloner::CloneBlock(llvm::BasicBlock const*, llvm::ilist_iterator, false, true>, std::vector >&) 83,504,774 ( 0.22%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::FindRoots(llvm::DominatorTreeBase const&, llvm::DomTreeBuilder::SemiNCAInfo >::BatchUpdateInfo*) 82,423,540 ( 0.21%) ???:llvm::Type::isSizedDerivedType(llvm::SmallPtrSetImpl*) const 82,409,407 ( 0.21%) ???:llvm::SROA::runOnAlloca(llvm::AllocaInst&) 81,982,569 ( 0.21%) ???:llvm::BasicAAResult::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&, llvm::AAQueryInfo&) 81,780,052 ( 0.21%) ???:llvm::TryToSimplifyUncondBranchFromEmptyBlock(llvm::BasicBlock*, llvm::DomTreeUpdater*) 80,559,574 ( 0.21%) ???:(anonymous namespace)::DeadMachineInstructionElim::eliminateDeadMI(llvm::MachineFunction&) 78,761,179 ( 0.20%) ???:llvm::InstCombinerImpl::SimplifyDemandedUseBits(llvm::Value*, llvm::APInt, llvm::KnownBits&, unsigned int, llvm::Instruction*) 77,601,453 ( 0.20%) ???:(anonymous namespace)::LazyValueInfoImpl::getValueInBlock(llvm::Value*, llvm::BasicBlock*, llvm::Instruction*) [clone .llvm.4316243980339171764] 77,079,451 ( 0.20%) ???:(anonymous namespace)::AggressiveDeadCodeElimination::performDeadCodeElimination() 74,396,820 ( 0.19%) ???:llvm::DemandedBits::isInstructionDead(llvm::Instruction*) 73,784,996 ( 0.19%) ???:updateCGAndAnalysisManagerForPass(llvm::LazyCallGraph&, llvm::LazyCallGraph::SCC&, llvm::LazyCallGraph::Node&, llvm::AnalysisManager&, llvm::CGSCCUpdateResult&, llvm::AnalysisManager&, bool) [clone .llvm.5426518467876156712] 71,329,646 ( 0.18%) ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_unaligned_erms 70,392,280 ( 0.18%) ???:llvm::TargetLoweringBase::getTypeConversion(llvm::LLVMContext&, llvm::EVT) const 70,096,432 ( 0.18%) ???:(anonymous namespace)::Verifier::visitInstruction(llvm::Instruction&) 69,779,471 ( 0.18%) ???:(anonymous namespace)::SimplifyCFGOpt::simplifyCondBranch(llvm::BranchInst*, llvm::IRBuilder&) 69,666,397 ( 0.18%) ???:llvm::ScheduleDAGSDNodes::BuildSchedUnits() 69,116,526 ( 0.18%) ???:llvm::AttributeList::addAttribute(llvm::LLVMContext&, unsigned int, llvm::Attribute::AttrKind) const 68,342,314 ( 0.18%) ???:llvm::LoopBase::verifyLoop() const 68,044,106 ( 0.18%) ???:llvm::LivePhysRegs::stepBackward(llvm::MachineInstr const&) 67,923,752 ( 0.18%) ???:llvm::LiveVariables::HandleRegMask(llvm::MachineOperand const&) 66,881,473 ( 0.17%) ???:llvm::AAResults::getModRefInfo(llvm::Instruction const*, llvm::Optional const&, llvm::AAQueryInfo&) 66,711,103 ( 0.17%) ???:llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, void*&, llvm::FoldingSetBase::FoldingSetInfo const&) 66,566,196 ( 0.17%) ???:(anonymous namespace)::CVPLatticeFunc::ComputeInstructionState(llvm::Instruction&, llvm::DenseMap, llvm::PointerIntPairInfo > >, (anonymous namespace)::CVPLatticeVal, llvm::DenseMapInfo, llvm::PointerIntPairInfo > > >, llvm::detail::DenseMapPair, llvm::PointerIntPairInfo > >, (anonymous namespace)::CVPLatticeVal> >&, llvm::SparseSolver, llvm::PointerIntPairInfo > >, (anonymous namespace)::CVPLatticeVal, llvm::LatticeKeyInfo, llvm::PointerIntPairInfo > > > >&) 66,478,511 ( 0.17%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs:::fold_ty 66,057,714 ( 0.17%) ???:llvm::SmallPtrSetImplBase::insert_imp_big(void const*) 64,458,668 ( 0.17%) ???:llvm::LazyCallGraph::removeDeadFunction(llvm::Function&) 64,418,341 ( 0.17%) ???:llvm::PopulateLoopsDFS::traverse(llvm::BasicBlock*) 64,350,956 ( 0.17%) ???:llvm::LoopInfoBase::analyze(llvm::DominatorTreeBase const&) 62,882,051 ( 0.16%) ???:llvm::IDFCalculatorBase::calculate(llvm::SmallVectorImpl&) 62,616,832 ( 0.16%) ???:llvm::MemorySSA::OptimizeUses::optimizeUses() 62,005,315 ( 0.16%) ???:llvm::BlockFrequencyInfoImpl::initializeRPOT() 61,709,560 ( 0.16%) ???:llvm::Value::stripAndAccumulateConstantOffsets(llvm::DataLayout const&, llvm::APInt&, bool, llvm::function_ref) const 60,943,690 ( 0.16%) ???:llvm::Value::~Value() 60,902,977 ( 0.16%) ???:llvm::InstCombinerImpl::visitStoreInst(llvm::StoreInst&) 60,560,097 ( 0.16%) ???:runImpl(llvm::Function&, llvm::LazyValueInfo*, llvm::DominatorTree*, llvm::SimplifyQuery const&) [clone .llvm.16011871802505272439] 60,465,224 ( 0.16%) ???:llvm::InstCombinerImpl::visitBitCast(llvm::BitCastInst&) 60,042,675 ( 0.16%) ???:llvm::AAResults::Model::pointsToConstantMemory(llvm::MemoryLocation const&, llvm::AAQueryInfo&, bool) 59,678,866 ( 0.15%) ???:llvm::PointerMayBeCaptured(llvm::Value const*, llvm::CaptureTracker*, unsigned int) 59,432,235 ( 0.15%) ???:??? 58,596,404 ( 0.15%) ???:llvm::ScalarEvolution::getAddExpr(llvm::SmallVectorImpl&, llvm::SCEV::NoWrapFlags, unsigned int) 58,381,695 ( 0.15%) ???:llvm::AAResults::Model::getModRefBehavior(llvm::CallBase const*) 58,298,212 ( 0.15%) ???:llvm::ConstantRange::makeExactICmpRegion(llvm::CmpInst::Predicate, llvm::APInt const&) 56,574,978 ( 0.15%) ???:llvm::Value::setName(llvm::Twine const&) 56,310,626 ( 0.15%) ???:llvm::ReassociatePass::BuildRankMap(llvm::Function&, llvm::ReversePostOrderTraversal >&) 55,963,685 ( 0.14%) ???:llvm::SCCPInstVisitor::solve() 55,776,290 ( 0.14%) ???:llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) 54,604,604 ( 0.14%) ???:llvm::JumpThreadingPass::processBlock(llvm::BasicBlock*) 53,597,862 ( 0.14%) ???:llvm::Intrinsic::getDeclaration(llvm::Module*, unsigned int, llvm::ArrayRef) 52,698,994 ( 0.14%) ???:llvm::DenseMapBase, std::unique_ptr<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry, std::default_delete<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry> >, llvm::DenseMapInfo >, llvm::detail::DenseMapPair, std::unique_ptr<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry, std::default_delete<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry> > > >, llvm::PoisoningVH, std::unique_ptr<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry, std::default_delete<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry> >, llvm::DenseMapInfo >, llvm::detail::DenseMapPair, std::unique_ptr<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry, std::default_delete<(anonymous namespace)::LazyValueInfoCache::BlockCacheEntry> > > >::destroyAll() [clone .llvm.4316243980339171764] 51,236,139 ( 0.13%) ???:llvm::ConstantFoldTerminator(llvm::BasicBlock*, bool, llvm::TargetLibraryInfo const*, llvm::DomTreeUpdater*) 50,227,239 ( 0.13%) ???:llvm::BlockFrequencyInfoImplBase::finalizeMetrics() 49,993,397 ( 0.13%) ???:llvm::FoldingSet::NodeEquals(llvm::FoldingSetBase const*, llvm::FoldingSetBase::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) 49,648,608 ( 0.13%) ???:llvm::SelectionDAG::computeKnownBits(llvm::SDValue, llvm::APInt const&, unsigned int) const 49,543,299 ( 0.13%) ???:llvm::Type::getPrimitiveSizeInBits() const 49,330,237 ( 0.13%) ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_sse2_unaligned_erms 49,008,671 ( 0.13%) ./string/../sysdeps/x86_64/multiarch/strlen-avx2.S:__strlen_avx2 48,479,865 ( 0.13%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::runSemiNCA(llvm::DominatorTreeBase&, unsigned int) 47,429,229 ( 0.12%) ???:llvm::BlockFrequencyInfoImpl::tryToComputeMassInFunction() 47,371,587 ( 0.12%) ???:std::back_insert_iterator > > std::__copy_move_a2, false, llvm::GraphTraits >, std::back_insert_iterator > > >(llvm::po_iterator, false, llvm::GraphTraits >, llvm::po_iterator, false, llvm::GraphTraits >, std::back_insert_iterator > >) 47,032,320 ( 0.12%) ???:llvm::DAGTypeLegalizer::run() 46,764,772 ( 0.12%) ???:llvm::UpgradeFunctionAttributes(llvm::Function&) 46,714,329 ( 0.12%) ???:llvm::ReassociatePass::run(llvm::Function&, llvm::AnalysisManager&) 46,376,680 ( 0.12%) ???:(anonymous namespace)::ClobberWalker::addSearches(llvm::MemoryPhi*, llvm::SmallVectorImpl&, unsigned int) 46,073,114 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/fold.rs:<&rustc_middle::ty::list::List as rustc_middle::ty::fold::TypeFoldable>::try_fold_with:: 46,058,160 ( 0.12%) ???:llvm::Function::Function(llvm::FunctionType*, llvm::GlobalValue::LinkageTypes, unsigned int, llvm::Twine const&, llvm::Module*) 44,993,723 ( 0.12%) ???:(anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) [clone .llvm.8386621111310650999] 44,635,532 ( 0.12%) ???:llvm::SelectionDAG::MorphNodeTo(llvm::SDNode*, unsigned int, llvm::SDVTList, llvm::ArrayRef) 44,310,452 ( 0.11%) ???:llvm::SelectionDAG::Legalize() 44,264,849 ( 0.11%) ???:llvm::Instruction::~Instruction() 43,589,292 ( 0.11%) ???:llvm::InstrEmitter::EmitMachineNode(llvm::SDNode*, bool, bool, llvm::DenseMap, llvm::detail::DenseMapPair >&) 43,444,391 ( 0.11%) ???:llvm::SelectionDAG::getConstant(llvm::ConstantInt const&, llvm::SDLoc const&, llvm::EVT, bool, bool) 43,428,907 ( 0.11%) ???:llvm::SROA::runImpl(llvm::Function&, llvm::DominatorTree&, llvm::AssumptionCache&) 43,033,010 ( 0.11%) ???:llvm::getObjectSize(llvm::Value const*, unsigned long&, llvm::DataLayout const&, llvm::TargetLibraryInfo const*, llvm::ObjectSizeOpts) 42,993,063 ( 0.11%) ???:llvm::SROA::rewritePartition(llvm::AllocaInst&, llvm::sroa::AllocaSlices&, llvm::sroa::Partition&) 42,610,766 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/subst.rs:<&rustc_middle::ty::list::List as rustc_middle::ty::fold::TypeFoldable>::try_fold_with:: 42,363,946 ( 0.11%) ???:(anonymous namespace)::CallAnalyzer::analyze() 41,982,765 ( 0.11%) ???:llvm::Instruction::eraseFromParent() 40,439,586 ( 0.10%) ???:llvm::PMDataManager::removeNotPreservedAnalysis(llvm::Pass*) 40,418,682 ( 0.10%) ???:(anonymous namespace)::BitcodeReader::parseFunctionBody(llvm::Function*) 40,363,160 ( 0.10%) ???:llvm::MemoryLocation::getOrNone(llvm::Instruction const*) 40,251,851 ( 0.10%) ./string/../sysdeps/x86_64/multiarch/memchr-avx2.S:__memchr_avx2 39,794,114 ( 0.10%) ???:llvm::FoldBranchToCommonDest(llvm::BranchInst*, llvm::DomTreeUpdater*, llvm::MemorySSAUpdater*, llvm::TargetTransformInfo const*, unsigned int) 39,650,887 ( 0.10%) ???:llvm::X86TargetMachine::getTargetTransformInfo(llvm::Function const&) 39,605,984 ( 0.10%) ???:llvm::MemoryLocation::get(llvm::LoadInst const*) 39,391,237 ( 0.10%) ./stdlib/msort.c:msort_with_tmp.part.0 39,190,572 ( 0.10%) ???:llvm::IRMover::move(std::unique_ptr >, llvm::ArrayRef, std::function)>, bool) 39,102,875 ( 0.10%) ???:llvm::GlobalsAAResult::DeletionCallbackHandle::deleted() 38,980,694 ( 0.10%) ???:llvm::detail::AnalysisResultModel, llvm::Function>, llvm::OuterAnalysisManagerProxy, llvm::Function>::Result, llvm::PreservedAnalyses, llvm::AnalysisManager::Invalidator, true>::invalidate(llvm::Function&, llvm::PreservedAnalyses const&, llvm::AnalysisManager::Invalidator&) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs -------------------------------------------------------------------------------- Ir -- line 111 ---------------------------------------- . const EMPTY: u8 = 0b1111_1111; . . /// Control byte value for a deleted bucket. . const DELETED: u8 = 0b1000_0000; . . /// Checks whether a control byte represents a full bucket (top bit is clear). . #[inline] . fn is_full(ctrl: u8) -> bool { 7,063,062 ( 0.02%) ctrl & 0x80 == 0 . } . . /// Checks whether a control byte represents a special value (top bit is set). . #[inline] . fn is_special(ctrl: u8) -> bool { . ctrl & 0x80 != 0 . } . . /// Checks whether a special control value is EMPTY (just check 1 bit). . #[inline] . fn special_is_empty(ctrl: u8) -> bool { . debug_assert!(is_special(ctrl)); 551,221 ( 0.00%) ctrl & 0x01 != 0 . } . . /// Primary hash function, used to select the initial bucket to probe from. . #[inline] . #[allow(clippy::cast_possible_truncation)] . fn h1(hash: u64) -> usize { . // On 32-bit platforms we simply ignore the higher hash bits. . hash as usize -- line 140 ---------------------------------------- -- line 143 ---------------------------------------- . /// Secondary hash function, saved in the low 7 bits of the control byte. . #[inline] . #[allow(clippy::cast_possible_truncation)] . fn h2(hash: u64) -> u8 { . // Grab the top 7 bits of the hash. While the hash is normally a full 64-bit . // value, some hash functions (such as FxHash) produce a usize result . // instead, which means that the top 32 bits are 0 on 32-bit platforms. . let hash_len = usize::min(mem::size_of::(), mem::size_of::()); 162,048,104 ( 0.42%) let top7 = hash >> (hash_len * 8 - 7); . (top7 & 0x7f) as u8 // truncation . } . . /// Probe sequence based on triangular numbers, which is guaranteed (since our . /// table size is a power of two) to visit every group of elements exactly once. . /// . /// A triangular probe has us jump by 1 more group every time. So first we . /// jump by 1 group (meaning we just continue our linear scan), then 2 groups -- line 159 ---------------------------------------- -- line 170 ---------------------------------------- . #[inline] . fn move_next(&mut self, bucket_mask: usize) { . // We should have found an empty bucket by now and ended the probe. . debug_assert!( . self.stride <= bucket_mask, . "Went past end of probe sequence" . ); . 1,357,722 ( 0.00%) self.stride += Group::WIDTH; 1,357,722 ( 0.00%) self.pos += self.stride; 1,178,134 ( 0.00%) self.pos &= bucket_mask; . } . } . . /// Returns the number of buckets needed to hold the given number of items, . /// taking the maximum load factor into account. . /// . /// Returns `None` if an overflow occurs. . // Workaround for emscripten bug emscripten-core/emscripten-fastcomp#258 . #[cfg_attr(target_os = "emscripten", inline(never))] . #[cfg_attr(not(target_os = "emscripten"), inline)] . fn capacity_to_buckets(cap: usize) -> Option { . debug_assert_ne!(cap, 0); . . // For small tables we require at least 1 empty bucket so that lookups are . // guaranteed to terminate if an element doesn't exist in the table. 489,188 ( 0.00%) if cap < 8 { . // We don't bother with a table size of 2 buckets since that can only . // hold a single element. Instead we skip directly to a 4 bucket table . // which can hold 3 elements. 997,225 ( 0.00%) return Some(if cap < 4 { 4 } else { 8 }); . } . . // Otherwise require 1/8 buckets to be empty (87.5% load) . // . // Be careful when modifying this, calculate_layout relies on the . // overflow check here. 270,894 ( 0.00%) let adjusted_cap = cap.checked_mul(8)? / 7; . . // Any overflows will have been caught by the checked_mul. Also, any . // rounding errors from the division above will be cleaned up by . // next_power_of_two (which can't overflow because of the previous division). . Some(adjusted_cap.next_power_of_two()) . } . . /// Returns the maximum effective capacity for the given bucket mask, taking . /// the maximum load factor into account. . #[inline] . fn bucket_mask_to_capacity(bucket_mask: usize) -> usize { 1,321,027 ( 0.00%) if bucket_mask < 8 { . // For tables with 1/2/4/8 buckets, we always reserve one empty slot. . // Keep in mind that the bucket mask is one less than the bucket count. . bucket_mask . } else { . // For larger tables we reserve 12.5% of the slots as empty. 320,232 ( 0.00%) ((bucket_mask + 1) / 8) * 7 . } . } . . /// Helper which allows the max calculation for ctrl_align to be statically computed for each T . /// while keeping the rest of `calculate_layout_for` independent of `T` . #[derive(Copy, Clone)] . struct TableLayout { . size: usize, -- line 233 ---------------------------------------- -- line 246 ---------------------------------------- . . #[inline] . fn calculate_layout_for(self, buckets: usize) -> Option<(Layout, usize)> { . debug_assert!(buckets.is_power_of_two()); . . let TableLayout { size, ctrl_align } = self; . // Manual layout calculation since Layout methods are not yet stable. . let ctrl_offset = 959,097 ( 0.00%) size.checked_mul(buckets)?.checked_add(ctrl_align - 1)? & !(ctrl_align - 1); 1,315,092 ( 0.00%) let len = ctrl_offset.checked_add(buckets + Group::WIDTH)?; . . Some(( . unsafe { Layout::from_size_align_unchecked(len, ctrl_align) }, . ctrl_offset, . )) . } . } . -- line 263 ---------------------------------------- -- line 337 ---------------------------------------- . } . } . #[cfg_attr(feature = "inline-more", inline)] . pub unsafe fn drop(&self) { . self.as_ptr().drop_in_place(); . } . #[inline] . pub unsafe fn read(&self) -> T { 4,746 ( 0.00%) self.as_ptr().read() . } . #[inline] . pub unsafe fn write(&self, val: T) { . self.as_ptr().write(val); . } . #[inline] . pub unsafe fn as_ref<'a>(&self) -> &'a T { . &*self.as_ptr() -- line 353 ---------------------------------------- -- line 422 ---------------------------------------- . /// Creates a new empty hash table without allocating any memory, using the . /// given allocator. . /// . /// In effect this returns a table with exactly 1 bucket. However we can . /// leave the data pointer dangling since that bucket is never written to . /// due to our load factor forcing us to always have at least 1 free bucket. . #[inline] . pub fn new_in(alloc: A) -> Self { 34,509 ( 0.00%) Self { . table: RawTableInner::new_in(alloc), . marker: PhantomData, . } . } . . /// Allocates a new hash table with the given number of buckets. . /// . /// The control bytes are left uninitialized. -- line 438 ---------------------------------------- -- line 440 ---------------------------------------- . unsafe fn new_uninitialized( . alloc: A, . buckets: usize, . fallibility: Fallibility, . ) -> Result { . debug_assert!(buckets.is_power_of_two()); . . Ok(Self { 525 ( 0.00%) table: RawTableInner::new_uninitialized( . alloc, . TableLayout::new::(), . buckets, . fallibility, . )?, . marker: PhantomData, . }) . } -- line 456 ---------------------------------------- -- line 458 ---------------------------------------- . /// Attempts to allocate a new hash table with at least enough capacity . /// for inserting the given number of elements without reallocating. . fn fallible_with_capacity( . alloc: A, . capacity: usize, . fallibility: Fallibility, . ) -> Result { . Ok(Self { 37,578 ( 0.00%) table: RawTableInner::fallible_with_capacity( . alloc, . TableLayout::new::(), . capacity, . fallibility, . )?, . marker: PhantomData, . }) . } -- line 474 ---------------------------------------- -- line 527 ---------------------------------------- . debug_assert_ne!(self.table.bucket_mask, 0); . debug_assert!(index < self.buckets()); . Bucket::from_base_index(self.data_end(), index) . } . . /// Erases an element from the table without dropping it. . #[cfg_attr(feature = "inline-more", inline)] . #[deprecated(since = "0.8.1", note = "use erase or remove instead")] 86,999 ( 0.00%) pub unsafe fn erase_no_drop(&mut self, item: &Bucket) { 86,999 ( 0.00%) let index = self.bucket_index(item); . self.table.erase(index); 173,998 ( 0.00%) } . . /// Erases an element from the table, dropping it in place. . #[cfg_attr(feature = "inline-more", inline)] . #[allow(clippy::needless_pass_by_value)] . #[allow(deprecated)] . pub unsafe fn erase(&mut self, item: Bucket) { . // Erase the element from the table first since drop might panic. 33,020 ( 0.00%) self.erase_no_drop(&item); . item.drop(); . } . . /// Finds and erases an element from the table, dropping it in place. . /// Returns true if an element was found. . #[cfg(feature = "raw")] . #[cfg_attr(feature = "inline-more", inline)] . pub fn erase_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> bool { -- line 554 ---------------------------------------- -- line 563 ---------------------------------------- . } . } . . /// Removes an element from the table, returning it. . #[cfg_attr(feature = "inline-more", inline)] . #[allow(clippy::needless_pass_by_value)] . #[allow(deprecated)] . pub unsafe fn remove(&mut self, item: Bucket) -> T { 140,978 ( 0.00%) self.erase_no_drop(&item); 729 ( 0.00%) item.read() . } . . /// Finds and removes an element from the table, returning it. . #[cfg_attr(feature = "inline-more", inline)] 2,682,340 ( 0.01%) pub fn remove_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option { . // Avoid `Option::map` because it bloats LLVM IR. 9,942 ( 0.00%) match self.find(hash, eq) { 27,367 ( 0.00%) Some(bucket) => Some(unsafe { self.remove(bucket) }), 464,947 ( 0.00%) None => None, . } 3,652,523 ( 0.01%) } . . /// Marks all table buckets as empty without dropping their contents. . #[cfg_attr(feature = "inline-more", inline)] . pub fn clear_no_drop(&mut self) { . self.table.clear_no_drop(); . } . . /// Removes all elements from the table without freeing the backing memory. . #[cfg_attr(feature = "inline-more", inline)] . pub fn clear(&mut self) { . // Ensure that the table is reset even if one of the drops panic . let mut self_ = guard(self, |self_| self_.clear_no_drop()); . unsafe { 1 ( 0.00%) self_.drop_elements(); . } . } . 7 ( 0.00%) unsafe fn drop_elements(&mut self) { 54,814 ( 0.00%) if mem::needs_drop::() && !self.is_empty() { . for item in self.iter() { . item.drop(); . } . } 8 ( 0.00%) } . . /// Shrinks the table to fit `max(self.len(), min_size)` elements. . #[cfg_attr(feature = "inline-more", inline)] . pub fn shrink_to(&mut self, min_size: usize, hasher: impl Fn(&T) -> u64) { . // Calculate the minimal number of elements that we need to reserve . // space for. . let min_size = usize::max(self.table.items, min_size); . if min_size == 0 { -- line 615 ---------------------------------------- -- line 642 ---------------------------------------- . } . } . } . . /// Ensures that at least `additional` items can be inserted into the table . /// without reallocation. . #[cfg_attr(feature = "inline-more", inline)] . pub fn reserve(&mut self, additional: usize, hasher: impl Fn(&T) -> u64) { 1,461,519 ( 0.00%) if additional > self.table.growth_left { . // Avoid `Result::unwrap_or_else` because it bloats LLVM IR. 828,924 ( 0.00%) if self . .reserve_rehash(additional, hasher, Fallibility::Infallible) . .is_err() . { . unsafe { hint::unreachable_unchecked() } . } . } . } . -- line 660 ---------------------------------------- -- line 671 ---------------------------------------- . } else { . Ok(()) . } . } . . /// Out-of-line slow path for `reserve` and `try_reserve`. . #[cold] . #[inline(never)] 1,950,344 ( 0.01%) fn reserve_rehash( . &mut self, . additional: usize, . hasher: impl Fn(&T) -> u64, . fallibility: Fallibility, . ) -> Result<(), TryReserveError> { . unsafe { . self.table.reserve_rehash_inner( . additional, -- line 687 ---------------------------------------- -- line 690 ---------------------------------------- . TableLayout::new::(), . if mem::needs_drop::() { . Some(mem::transmute(ptr::drop_in_place:: as unsafe fn(*mut T))) . } else { . None . }, . ) . } 1,373,352 ( 0.00%) } . . /// Allocates a new table of a different size and moves the contents of the . /// current table into it. . fn resize( . &mut self, . capacity: usize, . hasher: impl Fn(&T) -> u64, . fallibility: Fallibility, -- line 706 ---------------------------------------- -- line 714 ---------------------------------------- . ) . } . } . . /// Inserts a new element into the table, and returns its raw bucket. . /// . /// This does not check if the given element already exists in the table. . #[cfg_attr(feature = "inline-more", inline)] 10,236,376 ( 0.03%) pub fn insert(&mut self, hash: u64, value: T, hasher: impl Fn(&T) -> u64) -> Bucket { . unsafe { . let mut index = self.table.find_insert_slot(hash); . . // We can avoid growing the table once we have reached our load . // factor if we are replacing a tombstone. This works since the . // number of EMPTY slots does not change in this case. 20,951 ( 0.00%) let old_ctrl = *self.table.ctrl(index); 6,785,012 ( 0.02%) if unlikely(self.table.growth_left == 0 && special_is_empty(old_ctrl)) { . self.reserve(1, hasher); . index = self.table.find_insert_slot(hash); . } . . self.table.record_item_insert_at(index, old_ctrl, hash); . . let bucket = self.bucket(index); 4 ( 0.00%) bucket.write(value); . bucket . } 7,574,036 ( 0.02%) } . . /// Attempts to insert a new element without growing the table and return its raw bucket. . /// . /// Returns an `Err` containing the given element if inserting it would require growing the . /// table. . /// . /// This does not check if the given element already exists in the table. . #[cfg(feature = "raw")] -- line 749 ---------------------------------------- -- line 760 ---------------------------------------- . } . } . } . . /// Inserts a new element into the table, and returns a mutable reference to it. . /// . /// This does not check if the given element already exists in the table. . #[cfg_attr(feature = "inline-more", inline)] 2,360,472 ( 0.01%) pub fn insert_entry(&mut self, hash: u64, value: T, hasher: impl Fn(&T) -> u64) -> &mut T { 2,312 ( 0.00%) unsafe { self.insert(hash, value, hasher).as_mut() } 1,770,354 ( 0.00%) } . . /// Inserts a new element into the table, without growing the table. . /// . /// There must be enough space in the table to insert the new element. . /// . /// This does not check if the given element already exists in the table. . #[cfg_attr(feature = "inline-more", inline)] . #[cfg(any(feature = "raw", feature = "rustc-internal-api"))] 10,295 ( 0.00%) pub unsafe fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket { 1,564,463 ( 0.00%) let (index, old_ctrl) = self.table.prepare_insert_slot(hash); 47,861 ( 0.00%) let bucket = self.table.bucket(index); . . // If we are replacing a DELETED entry then we don't need to update . // the load counter. 3,272,576 ( 0.01%) self.table.growth_left -= special_is_empty(old_ctrl) as usize; . . bucket.write(value); 2,551,166 ( 0.01%) self.table.items += 1; . bucket 20,233 ( 0.00%) } . . /// Temporary removes a bucket, applying the given function to the removed . /// element and optionally put back the returned value in the same bucket. . /// . /// Returns `true` if the bucket still contains an element . /// . /// This does not check if the given bucket is actually occupied. . #[cfg_attr(feature = "inline-more", inline)] -- line 798 ---------------------------------------- -- line 813 ---------------------------------------- . true . } else { . false . } . } . . /// Searches for an element in the table. . #[inline] 270,304 ( 0.00%) pub fn find(&self, hash: u64, mut eq: impl FnMut(&T) -> bool) -> Option> { 40,103 ( 0.00%) let result = self.table.find_inner(hash, &mut |index| unsafe { 111,516 ( 0.00%) eq(self.bucket(index).as_ref()) 11,508 ( 0.00%) }); . . // Avoid `Option::map` because it bloats LLVM IR. . match result { 4,617 ( 0.00%) Some(index) => Some(unsafe { self.bucket(index) }), . None => None, . } 307,688 ( 0.00%) } . . /// Gets a reference to an element in the table. . #[inline] . pub fn get(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&T> { . // Avoid `Option::map` because it bloats LLVM IR. 162,707 ( 0.00%) match self.find(hash, eq) { . Some(bucket) => Some(unsafe { bucket.as_ref() }), . None => None, . } . } . . /// Gets a mutable reference to an element in the table. . #[inline] 23,024 ( 0.00%) pub fn get_mut(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&mut T> { . // Avoid `Option::map` because it bloats LLVM IR. 117,437 ( 0.00%) match self.find(hash, eq) { . Some(bucket) => Some(unsafe { bucket.as_mut() }), . None => None, . } 26,692 ( 0.00%) } . . /// Attempts to get mutable references to `N` entries in the table at once. . /// . /// Returns an array of length `N` with the results of each query. . /// . /// At most one mutable reference will be returned to any entry. `None` will be returned if any . /// of the hashes are duplicates. `None` will be returned if the hash is not found. . /// -- line 859 ---------------------------------------- -- line 920 ---------------------------------------- . #[inline] . pub fn len(&self) -> usize { . self.table.items . } . . /// Returns `true` if the table contains no elements. . #[inline] . pub fn is_empty(&self) -> bool { 3,115,721 ( 0.01%) self.len() == 0 . } . . /// Returns the number of buckets in the table. . #[inline] . pub fn buckets(&self) -> usize { . self.table.bucket_mask + 1 . } . . /// Returns an iterator over every element in the table. It is up to . /// the caller to ensure that the `RawTable` outlives the `RawIter`. . /// Because we cannot make the `next` method unsafe on the `RawIter` . /// struct, we have to make the `iter` method unsafe. . #[inline] . pub unsafe fn iter(&self) -> RawIter { 16 ( 0.00%) let data = Bucket::from_base_index(self.data_end(), 0); . RawIter { . iter: RawIterRange::new(self.table.ctrl.as_ptr(), data, self.table.buckets()), 395,141 ( 0.00%) items: self.table.items, . } . } . . /// Returns an iterator over occupied buckets that could match a given hash. . /// . /// `RawTable` only stores 7 bits of the hash value, so this iterator may . /// return items that have a hash value different than the one provided. You . /// should always validate the returned values before using them. -- line 954 ---------------------------------------- -- line 995 ---------------------------------------- . /// Iteration starts at the provided iterator's current location. . /// . /// It is up to the caller to ensure that the iterator is valid for this . /// `RawTable` and covers all items that remain in the table. . pub unsafe fn into_iter_from(self, iter: RawIter) -> RawIntoIter { . debug_assert_eq!(iter.len(), self.len()); . . let alloc = self.table.alloc.clone(); 22,768 ( 0.00%) let allocation = self.into_allocation(); 17,076 ( 0.00%) RawIntoIter { 28,460 ( 0.00%) iter, . allocation, . marker: PhantomData, . alloc, . } . } . . /// Converts the table into a raw allocation. The contents of the table . /// should be dropped using a `RawIter` before freeing the allocation. . #[cfg_attr(feature = "inline-more", inline)] . pub(crate) fn into_allocation(self) -> Option<(NonNull, Layout)> { 10,982 ( 0.00%) let alloc = if self.table.is_empty_singleton() { . None . } else { . // Avoid `Option::unwrap_or_else` because it bloats LLVM IR. . let (layout, ctrl_offset) = match calculate_layout::(self.table.buckets()) { . Some(lco) => lco, . None => unsafe { hint::unreachable_unchecked() }, . }; . Some(( 1,674 ( 0.00%) unsafe { NonNull::new_unchecked(self.table.ctrl.as_ptr().sub(ctrl_offset)) }, . layout, . )) . }; . mem::forget(self); . alloc . } . } . -- line 1033 ---------------------------------------- -- line 1042 ---------------------------------------- . T: Sync, . A: Sync, . { . } . . impl RawTableInner { . #[inline] . const fn new_in(alloc: A) -> Self { 2,822,278 ( 0.01%) Self { . // Be careful to cast the entire slice to a raw pointer. . ctrl: unsafe { NonNull::new_unchecked(Group::static_empty() as *const _ as *mut u8) }, . bucket_mask: 0, . items: 0, . growth_left: 0, . alloc, . } . } . } . . impl RawTableInner { . #[cfg_attr(feature = "inline-more", inline)] 1,686,673 ( 0.00%) unsafe fn new_uninitialized( . alloc: A, . table_layout: TableLayout, . buckets: usize, . fallibility: Fallibility, . ) -> Result { . debug_assert!(buckets.is_power_of_two()); . . // Avoid `Option::ok_or_else` because it bloats LLVM IR. -- line 1071 ---------------------------------------- -- line 1078 ---------------------------------------- . // exceed `isize::MAX`. We can skip this check on 64-bit systems since . // such allocations will never succeed anyways. . // . // This mirrors what Vec does in the standard library. . if mem::size_of::() < 8 && layout.size() > isize::MAX as usize { . return Err(fallibility.capacity_overflow()); . } . 393,632 ( 0.00%) let ptr: NonNull = match do_alloc(&alloc, layout) { . Ok(block) => block.cast(), . Err(_) => return Err(fallibility.alloc_err(layout)), . }; . . let ctrl = NonNull::new_unchecked(ptr.as_ptr().add(ctrl_offset)); 931,260 ( 0.00%) Ok(Self { . ctrl, 399,909 ( 0.00%) bucket_mask: buckets - 1, . items: 0, . growth_left: bucket_mask_to_capacity(buckets - 1), . alloc, . }) 1,227,922 ( 0.00%) } . . #[inline] 115,438 ( 0.00%) fn fallible_with_capacity( . alloc: A, . table_layout: TableLayout, . capacity: usize, . fallibility: Fallibility, . ) -> Result { 29,770 ( 0.00%) if capacity == 0 { 18,578 ( 0.00%) Ok(Self::new_in(alloc)) . } else { . unsafe { . let buckets = . capacity_to_buckets(capacity).ok_or_else(|| fallibility.capacity_overflow())?; . 762,363 ( 0.00%) let result = Self::new_uninitialized(alloc, table_layout, buckets, fallibility)?; . result.ctrl(0).write_bytes(EMPTY, result.num_ctrl_bytes()); . 65,565 ( 0.00%) Ok(result) . } . } 115,438 ( 0.00%) } . . /// Searches for an empty or deleted bucket which is suitable for inserting . /// a new element and sets the hash for that slot. . /// . /// There must be at least 1 empty bucket in the table. . #[inline] 541,195 ( 0.00%) unsafe fn prepare_insert_slot(&self, hash: u64) -> (usize, u8) { . let index = self.find_insert_slot(hash); 541,195 ( 0.00%) let old_ctrl = *self.ctrl(index); . self.set_ctrl_h2(index, hash); . (index, old_ctrl) 1,082,390 ( 0.00%) } . . /// Searches for an empty or deleted bucket which is suitable for inserting . /// a new element. . /// . /// There must be at least 1 empty bucket in the table. . #[inline] . fn find_insert_slot(&self, hash: u64) -> usize { . let mut probe_seq = self.probe_seq(hash); . loop { . unsafe { . let group = Group::load(self.ctrl(probe_seq.pos)); 4,628,028 ( 0.01%) if let Some(bit) = group.match_empty_or_deleted().lowest_set_bit() { 13,485,252 ( 0.03%) let result = (probe_seq.pos + bit) & self.bucket_mask; . . // In tables smaller than the group width, trailing control . // bytes outside the range of the table are filled with . // EMPTY entries. These will unfortunately trigger a . // match, but once masked may point to a full bucket that . // is already occupied. We detect this situation here and . // perform a second scan starting at the beginning of the . // table. This second scan is guaranteed to find an empty . // slot (due to the load factor) before hitting the trailing . // control bytes (containing EMPTY). 6,188,401 ( 0.02%) if unlikely(is_full(*self.ctrl(result))) { . debug_assert!(self.bucket_mask < Group::WIDTH); . debug_assert_ne!(probe_seq.pos, 0); . return Group::load_aligned(self.ctrl(0)) . .match_empty_or_deleted() . .lowest_set_bit_nonzero(); . } . . return result; -- line 1165 ---------------------------------------- -- line 1171 ---------------------------------------- . . /// Searches for an element in the table. This uses dynamic dispatch to reduce the amount of . /// code generated, but it is eliminated by LLVM optimizations. . #[inline] . fn find_inner(&self, hash: u64, eq: &mut dyn FnMut(usize) -> bool) -> Option { . let h2_hash = h2(hash); . let mut probe_seq = self.probe_seq(hash); . 372,332 ( 0.00%) loop { . let group = unsafe { Group::load(self.ctrl(probe_seq.pos)) }; . 15,826,589 ( 0.04%) for bit in group.match_byte(h2_hash) { 31,986,521 ( 0.08%) let index = (probe_seq.pos + bit) & self.bucket_mask; . 20,879,771 ( 0.05%) if likely(eq(index)) { . return Some(index); . } . } . 4,471,359 ( 0.01%) if likely(group.match_empty().any_bit_set()) { . return None; . } . . probe_seq.move_next(self.bucket_mask); . } . } . . #[allow(clippy::mut_mut)] . #[inline] . unsafe fn prepare_rehash_in_place(&mut self) { . // Bulk convert all full control bytes to DELETED, and all DELETED . // control bytes to EMPTY. This effectively frees up all buckets . // containing a DELETED entry. 12 ( 0.00%) for i in (0..self.buckets()).step_by(Group::WIDTH) { . let group = Group::load_aligned(self.ctrl(i)); . let group = group.convert_special_to_empty_and_full_to_deleted(); . group.store_aligned(self.ctrl(i)); . } . . // Fix up the trailing control bytes. See the comments in set_ctrl . // for the handling of tables smaller than the group width. 12 ( 0.00%) if self.buckets() < Group::WIDTH { . self.ctrl(0) . .copy_to(self.ctrl(Group::WIDTH), self.buckets()); . } else { . self.ctrl(0) . .copy_to(self.ctrl(self.buckets()), Group::WIDTH); . } . } . -- line 1220 ---------------------------------------- -- line 1225 ---------------------------------------- . Bucket::from_base_index(self.data_end(), index) . } . . #[inline] . unsafe fn bucket_ptr(&self, index: usize, size_of: usize) -> *mut u8 { . debug_assert_ne!(self.bucket_mask, 0); . debug_assert!(index < self.buckets()); . let base: *mut u8 = self.data_end().as_ptr(); 16,664,656 ( 0.04%) base.sub((index + 1) * size_of) . } . . #[inline] . unsafe fn data_end(&self) -> NonNull { . NonNull::new_unchecked(self.ctrl.as_ptr().cast()) . } . . /// Returns an iterator-like object for a probe sequence on the table. . /// . /// This iterator never terminates, but is guaranteed to visit each bucket . /// group exactly once. The loop using `probe_seq` must terminate upon . /// reaching a group containing an empty bucket. . #[inline] . fn probe_seq(&self, hash: u64) -> ProbeSeq { . ProbeSeq { 86,783,505 ( 0.22%) pos: h1(hash) & self.bucket_mask, . stride: 0, . } . } . . /// Returns the index of a bucket for which a value must be inserted if there is enough rooom . /// in the table, otherwise returns error . #[cfg(feature = "raw")] . #[inline] -- line 1257 ---------------------------------------- -- line 1263 ---------------------------------------- . } else { . self.record_item_insert_at(index, old_ctrl, hash); . Ok(index) . } . } . . #[inline] . unsafe fn record_item_insert_at(&mut self, index: usize, old_ctrl: u8, hash: u64) { 8,478,681 ( 0.02%) self.growth_left -= special_is_empty(old_ctrl) as usize; . self.set_ctrl_h2(index, hash); 6,782,864 ( 0.02%) self.items += 1; . } . . #[inline] . fn is_in_same_group(&self, i: usize, new_i: usize, hash: u64) -> bool { . let probe_seq_pos = self.probe_seq(hash).pos; . let probe_index = . |pos: usize| (pos.wrapping_sub(probe_seq_pos) & self.bucket_mask) / Group::WIDTH; 102 ( 0.00%) probe_index(i) == probe_index(new_i) . } . . /// Sets a control byte to the hash, and possibly also the replicated control byte at . /// the end of the array. . #[inline] . unsafe fn set_ctrl_h2(&self, index: usize, hash: u64) { . self.set_ctrl(index, h2(hash)); . } -- line 1289 ---------------------------------------- -- line 1312 ---------------------------------------- . // replicate the buckets at the end of the trailing group. For example . // with 2 buckets and a group size of 4, the control bytes will look . // like this: . // . // Real | Replicated . // --------------------------------------------- . // | [A] | [B] | [EMPTY] | [EMPTY] | [A] | [B] | . // --------------------------------------------- 12,999,739 ( 0.03%) let index2 = ((index.wrapping_sub(Group::WIDTH)) & self.bucket_mask) + Group::WIDTH; . 4,330,019 ( 0.01%) *self.ctrl(index) = ctrl; 4,332,594 ( 0.01%) *self.ctrl(index2) = ctrl; . } . . /// Returns a pointer to a control byte. . #[inline] . unsafe fn ctrl(&self, index: usize) -> *mut u8 { . debug_assert!(index < self.num_ctrl_bytes()); . self.ctrl.as_ptr().add(index) . } . . #[inline] . fn buckets(&self) -> usize { 1,193,860 ( 0.00%) self.bucket_mask + 1 . } . . #[inline] . fn num_ctrl_bytes(&self) -> usize { 968,146 ( 0.00%) self.bucket_mask + 1 + Group::WIDTH . } . . #[inline] . fn is_empty_singleton(&self) -> bool { 5,188,278 ( 0.01%) self.bucket_mask == 0 . } . . #[allow(clippy::mut_mut)] . #[inline] . unsafe fn prepare_resize( . &self, . table_layout: TableLayout, . capacity: usize, . fallibility: Fallibility, . ) -> Result, TryReserveError> { . debug_assert!(self.items <= capacity); . . // Allocate and initialize the new table. 15,561 ( 0.00%) let mut new_table = RawTableInner::fallible_with_capacity( . self.alloc.clone(), . table_layout, . capacity, . fallibility, . )?; 521,660 ( 0.00%) new_table.growth_left -= self.items; . new_table.items = self.items; . . // The hash function may panic, in which case we simply free the new . // table without dropping any elements that may have been copied into . // it. . // . // This guard is also used to free the old table on success, see . // the comment at the bottom of this function. . Ok(guard(new_table, move |self_| { 238,849 ( 0.00%) if !self_.is_empty_singleton() { . self_.free_buckets(table_layout); . } . })) . } . . /// Reserves or rehashes to make room for `additional` more elements. . /// . /// This uses dynamic dispatch to reduce the amount of -- line 1383 ---------------------------------------- -- line 1388 ---------------------------------------- . &mut self, . additional: usize, . hasher: &dyn Fn(&mut Self, usize) -> u64, . fallibility: Fallibility, . layout: TableLayout, . drop: Option, . ) -> Result<(), TryReserveError> { . // Avoid `Option::ok_or_else` because it bloats LLVM IR. 477,712 ( 0.00%) let new_items = match self.items.checked_add(additional) { . Some(new_items) => new_items, . None => return Err(fallibility.capacity_overflow()), . }; 477,706 ( 0.00%) let full_capacity = bucket_mask_to_capacity(self.bucket_mask); 1,010,207 ( 0.00%) if new_items <= full_capacity / 2 { . // Rehash in-place without re-allocating if we have plenty of spare . // capacity that is locked up due to DELETED entries. . self.rehash_in_place(hasher, layout.size, drop); 5 ( 0.00%) Ok(()) . } else { . // Otherwise, conservatively resize to at least the next size up . // to avoid churning deletes into frequent rehashes. . self.resize_inner( 238,849 ( 0.00%) usize::max(new_items, full_capacity + 1), . hasher, . fallibility, . layout, . ) . } . } . . /// Allocates a new table of a different size and moves the contents of the -- line 1418 ---------------------------------------- -- line 1424 ---------------------------------------- . #[inline(always)] . unsafe fn resize_inner( . &mut self, . capacity: usize, . hasher: &dyn Fn(&mut Self, usize) -> u64, . fallibility: Fallibility, . layout: TableLayout, . ) -> Result<(), TryReserveError> { 38,696 ( 0.00%) let mut new_table = self.prepare_resize(layout, capacity, fallibility)?; . . // Copy all elements to the new table. . for i in 0..self.buckets() { 2,570,377 ( 0.01%) if !is_full(*self.ctrl(i)) { . continue; . } . . // This may panic. . let hash = hasher(self, i); . . // We can use a simpler version of insert() here since: . // - there are no DELETED entries. -- line 1444 ---------------------------------------- -- line 1454 ---------------------------------------- . } . . // We successfully copied all elements without panicking. Now replace . // self with the new table. The old table will have its memory freed but . // the items will not be dropped (since they have been moved into the . // new table). . mem::swap(self, &mut new_table); . 238,849 ( 0.00%) Ok(()) . } . . /// Rehashes the contents of the table in place (i.e. without changing the . /// allocation). . /// . /// If `hasher` panics then some the table's contents may be lost. . /// . /// This uses dynamic dispatch to reduce the amount of -- line 1470 ---------------------------------------- -- line 1496 ---------------------------------------- . } . self_.growth_left = bucket_mask_to_capacity(self_.bucket_mask) - self_.items; . }); . . // At this point, DELETED elements are elements that we haven't . // rehashed yet. Find them and re-insert them at their ideal . // position. . 'outer: for i in 0..guard.buckets() { 256 ( 0.00%) if *guard.ctrl(i) != DELETED { . continue; . } . . let i_p = guard.bucket_ptr(i, size_of); . . 'inner: loop { . // Hash the current item . let hash = hasher(*guard, i); -- line 1512 ---------------------------------------- -- line 1515 ---------------------------------------- . let new_i = guard.find_insert_slot(hash); . let new_i_p = guard.bucket_ptr(new_i, size_of); . . // Probing works by scanning through all of the control . // bytes in groups, which may not be aligned to the group . // size. If both the new and old position fall within the . // same unaligned group, then there is no benefit in moving . // it and we can just continue to the next item. 34 ( 0.00%) if likely(guard.is_in_same_group(i, new_i, hash)) { . guard.set_ctrl_h2(i, hash); . continue 'outer; . } . . // We are moving the current item to a new position. Write . // our H2 to the control byte of the new position. . let prev_ctrl = guard.replace_ctrl_h2(new_i, hash); . if prev_ctrl == EMPTY { -- line 1531 ---------------------------------------- -- line 1541 ---------------------------------------- . // swapped into the old slot. . debug_assert_eq!(prev_ctrl, DELETED); . ptr::swap_nonoverlapping(i_p, new_i_p, size_of); . continue 'inner; . } . } . } . 12 ( 0.00%) guard.growth_left = bucket_mask_to_capacity(guard.bucket_mask) - guard.items; . . mem::forget(guard); . } . . #[inline] . unsafe fn free_buckets(&mut self, table_layout: TableLayout) { . // Avoid `Option::unwrap_or_else` because it bloats LLVM IR. . let (layout, ctrl_offset) = match table_layout.calculate_layout_for(self.buckets()) { . Some(lco) => lco, . None => hint::unreachable_unchecked(), . }; . self.alloc.deallocate( 163,768 ( 0.00%) NonNull::new_unchecked(self.ctrl.as_ptr().sub(ctrl_offset)), . layout, . ); . } . . /// Marks all table buckets as empty without dropping their contents. . #[inline] . fn clear_no_drop(&mut self) { 40,598 ( 0.00%) if !self.is_empty_singleton() { . unsafe { . self.ctrl(0).write_bytes(EMPTY, self.num_ctrl_bytes()); . } . } 49,630 ( 0.00%) self.items = 0; 40,722 ( 0.00%) self.growth_left = bucket_mask_to_capacity(self.bucket_mask); . } . . #[inline] . unsafe fn erase(&mut self, index: usize) { . debug_assert!(is_full(*self.ctrl(index))); 460,562 ( 0.00%) let index_before = index.wrapping_sub(Group::WIDTH) & self.bucket_mask; . let empty_before = Group::load(self.ctrl(index_before)).match_empty(); . let empty_after = Group::load(self.ctrl(index)).match_empty(); . . // If we are inside a continuous block of Group::WIDTH full or deleted . // cells then a probe window may have seen a full block when trying to . // insert. We therefore need to keep that block non-empty so that . // lookups will continue searching to the next probe window. . // . // Note that in this context `leading_zeros` refers to the bytes at the . // end of a group, while `trailing_zeros` refers to the bytes at the . // beginning of a group. 1,842,248 ( 0.00%) let ctrl = if empty_before.leading_zeros() + empty_after.trailing_zeros() >= Group::WIDTH { . DELETED . } else { 2,271,930 ( 0.01%) self.growth_left += 1; . EMPTY . }; . self.set_ctrl(index, ctrl); 1,842,248 ( 0.00%) self.items -= 1; . } . } . . impl Clone for RawTable { 92,040 ( 0.00%) fn clone(&self) -> Self { 11,647 ( 0.00%) if self.table.is_empty_singleton() { . Self::new_in(self.table.alloc.clone()) . } else { . unsafe { . let mut new_table = ManuallyDrop::new( . // Avoid `Result::ok_or_else` because it bloats LLVM IR. . match Self::new_uninitialized( . self.table.alloc.clone(), . self.table.buckets(), -- line 1615 ---------------------------------------- -- line 1624 ---------------------------------------- . // We need to free the memory allocated for the new table. . new_table.free_buckets(); . }); . . // Return the newly created table. . ManuallyDrop::into_inner(new_table) . } . } 103,545 ( 0.00%) } . . fn clone_from(&mut self, source: &Self) { . if source.table.is_empty_singleton() { . *self = Self::new_in(self.table.alloc.clone()); . } else { . unsafe { . // First, drop all our elements without clearing the control bytes. . self.drop_elements(); -- line 1640 ---------------------------------------- -- line 1687 ---------------------------------------- . .table . .ctrl(0) . .copy_to_nonoverlapping(self.table.ctrl(0), self.table.num_ctrl_bytes()); . source . .data_start() . .copy_to_nonoverlapping(self.data_start(), self.table.buckets()); . . self.table.items = source.table.items; 210 ( 0.00%) self.table.growth_left = source.table.growth_left; . } . } . . impl RawTable { . /// Common code for clone and clone_from. Assumes `self.buckets() == source.buckets()`. . #[cfg_attr(feature = "inline-more", inline)] . unsafe fn clone_from_impl(&mut self, source: &Self, mut on_panic: impl FnMut(&mut Self)) { . // Copy the control bytes unchanged. We do this in a single pass -- line 1703 ---------------------------------------- -- line 1790 ---------------------------------------- . fn default() -> Self { . Self::new_in(Default::default()) . } . } . . #[cfg(feature = "nightly")] . unsafe impl<#[may_dangle] T, A: Allocator + Clone> Drop for RawTable { . #[cfg_attr(feature = "inline-more", inline)] 2,751,349 ( 0.01%) fn drop(&mut self) { 2,241,915 ( 0.01%) if !self.table.is_empty_singleton() { . unsafe { . self.drop_elements(); . self.free_buckets(); . } . } 2,954,692 ( 0.01%) } . } . #[cfg(not(feature = "nightly"))] . impl Drop for RawTable { . #[cfg_attr(feature = "inline-more", inline)] . fn drop(&mut self) { . if !self.table.is_empty_singleton() { . unsafe { . self.drop_elements(); -- line 1813 ---------------------------------------- -- line 1817 ---------------------------------------- . } . } . . impl IntoIterator for RawTable { . type Item = T; . type IntoIter = RawIntoIter; . . #[cfg_attr(feature = "inline-more", inline)] 22,768 ( 0.00%) fn into_iter(self) -> RawIntoIter { . unsafe { . let iter = self.iter(); . self.into_iter_from(iter) . } 28,460 ( 0.00%) } . } . . /// Iterator over a sub-range of a table. Unlike `RawIter` this iterator does . /// not track an item count. . pub(crate) struct RawIterRange { . // Mask of full buckets in the current group. Bits are cleared from this . // mask as each element is processed. . current_group: BitMask, -- line 1838 ---------------------------------------- -- line 1934 ---------------------------------------- . . impl Iterator for RawIterRange { . type Item = Bucket; . . #[cfg_attr(feature = "inline-more", inline)] . fn next(&mut self) -> Option> { . unsafe { . loop { 1,106,295 ( 0.00%) if let Some(index) = self.current_group.lowest_set_bit() { 154,384 ( 0.00%) self.current_group = self.current_group.remove_lowest_bit(); 242,658 ( 0.00%) return Some(self.data.next_n(index)); . } . 815,393 ( 0.00%) if self.next_ctrl >= self.end { . return None; . } . . // We might read past self.end up to the next group boundary, . // but this is fine because it only occurs on tables smaller . // than the group size where the trailing control bytes are all . // EMPTY. On larger tables self.end is guaranteed to be aligned . // to the group size (since tables are power-of-two sized). 29,605 ( 0.00%) self.current_group = Group::load_aligned(self.next_ctrl).match_full(); 21,990 ( 0.00%) self.data = self.data.next_n(Group::WIDTH); 62,955 ( 0.00%) self.next_ctrl = self.next_ctrl.add(Group::WIDTH); . } . } . } . . #[inline] . fn size_hint(&self) -> (usize, Option) { . // We don't have an item count, so just guess based on the range size. . ( -- line 1966 ---------------------------------------- -- line 2102 ---------------------------------------- . } . } else { . // We must have already iterated past the removed item. . } . } . } . . unsafe fn drop_elements(&mut self) { 6,496 ( 0.00%) if mem::needs_drop::() && self.len() != 0 { . for item in self { . item.drop(); . } . } . } . } . . impl Clone for RawIter { -- line 2118 ---------------------------------------- -- line 2124 ---------------------------------------- . } . } . } . . impl Iterator for RawIter { . type Item = Bucket; . . #[cfg_attr(feature = "inline-more", inline)] 162,355 ( 0.00%) fn next(&mut self) -> Option> { 583,616 ( 0.00%) if let Some(b) = self.iter.next() { 1,503,371 ( 0.00%) self.items -= 1; . Some(b) . } else { . // We don't check against items == 0 here to allow the . // compiler to optimize away the item count entirely if the . // iterator length is never queried. . debug_assert_eq!(self.items, 0); . None . } 324,710 ( 0.00%) } . . #[inline] . fn size_hint(&self) -> (usize, Option) { . (self.items, Some(self.items)) . } . } . . impl ExactSizeIterator for RawIter {} -- line 2151 ---------------------------------------- -- line 2177 ---------------------------------------- . T: Sync, . A: Sync, . { . } . . #[cfg(feature = "nightly")] . unsafe impl<#[may_dangle] T, A: Allocator + Clone> Drop for RawIntoIter { . #[cfg_attr(feature = "inline-more", inline)] 8,808 ( 0.00%) fn drop(&mut self) { . unsafe { . // Drop all remaining elements . self.iter.drop_elements(); . . // Free the table 51,898 ( 0.00%) if let Some((ptr, layout)) = self.allocation { . self.alloc.deallocate(ptr, layout); . } . } 1,000 ( 0.00%) } . } . #[cfg(not(feature = "nightly"))] . impl Drop for RawIntoIter { . #[cfg_attr(feature = "inline-more", inline)] . fn drop(&mut self) { . unsafe { . // Drop all remaining elements . self.iter.drop_elements(); -- line 2203 ---------------------------------------- -- line 2209 ---------------------------------------- . } . } . } . . impl Iterator for RawIntoIter { . type Item = T; . . #[cfg_attr(feature = "inline-more", inline)] 11,677 ( 0.00%) fn next(&mut self) -> Option { 4,443 ( 0.00%) unsafe { Some(self.iter.next()?.read()) } 30,832 ( 0.00%) } . . #[inline] . fn size_hint(&self) -> (usize, Option) { 18 ( 0.00%) self.iter.size_hint() . } . } . . impl ExactSizeIterator for RawIntoIter {} . impl FusedIterator for RawIntoIter {} . . /// Iterator which consumes elements without freeing the table storage. . pub struct RawDrain<'a, T, A: Allocator + Clone = Global> { -- line 2231 ---------------------------------------- -- line 2259 ---------------------------------------- . where . T: Sync, . A: Sync, . { . } . . impl Drop for RawDrain<'_, T, A> { . #[cfg_attr(feature = "inline-more", inline)] 7,968 ( 0.00%) fn drop(&mut self) { . unsafe { . // Drop all remaining elements. Note that this may panic. . self.iter.drop_elements(); . . // Reset the contents of the table now that all elements have been . // dropped. . self.table.clear_no_drop(); . . // Move the now empty table back to its original location. 996 ( 0.00%) self.orig_table . .as_ptr() . .copy_from_nonoverlapping(&*self.table, 1); . } 7,968 ( 0.00%) } . } . . impl Iterator for RawDrain<'_, T, A> { . type Item = T; . . #[cfg_attr(feature = "inline-more", inline)] . fn next(&mut self) -> Option { . unsafe { -- line 2289 ---------------------------------------- 49,897,682 ( 0.13%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs -------------------------------------------------------------------------------- Ir -- line 39 ---------------------------------------- . pub fn canonicalize_query( . &self, . value: V, . query_state: &mut OriginalQueryValues<'tcx>, . ) -> Canonicalized<'tcx, V> . where . V: TypeFoldable<'tcx>, . { 42,786 ( 0.00%) self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed); . 210,827 ( 0.00%) Canonicalizer::canonicalize(value, self, self.tcx, &CanonicalizeAllFreeRegions, query_state) . } . . /// Canonicalizes a query *response* `V`. When we canonicalize a . /// query response, we only canonicalize unbound inference . /// variables, and we leave other free regions alone. So, . /// continuing with the example from `canonicalize_query`, if . /// there was an input query `T: Trait<'static>`, it would have . /// been canonicalized to -- line 57 ---------------------------------------- -- line 69 ---------------------------------------- . /// things) includes a mapping to `'?0 := 'static`. When . /// canonicalizing this query result R, we would leave this . /// reference to `'static` alone. . /// . /// To get a good understanding of what is happening here, check . /// out the [chapter in the rustc dev guide][c]. . /// . /// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query-result 981 ( 0.00%) pub fn canonicalize_response(&self, value: V) -> Canonicalized<'tcx, V> . where . V: TypeFoldable<'tcx>, . { 27,894 ( 0.00%) let mut query_state = OriginalQueryValues::default(); 97,629 ( 0.00%) Canonicalizer::canonicalize( 165,144 ( 0.00%) value, . self, 13,947 ( 0.00%) self.tcx, . &CanonicalizeQueryResponse, . &mut query_state, . ) 763 ( 0.00%) } . 25,713 ( 0.00%) pub fn canonicalize_user_type_annotation(&self, value: V) -> Canonicalized<'tcx, V> . where . V: TypeFoldable<'tcx>, . { 6,200 ( 0.00%) let mut query_state = OriginalQueryValues::default(); 21,700 ( 0.00%) Canonicalizer::canonicalize( 18,357 ( 0.00%) value, . self, 3,100 ( 0.00%) self.tcx, . &CanonicalizeUserTypeAnnotation, . &mut query_state, . ) 19,999 ( 0.00%) } . . /// A variant of `canonicalize_query` that does not . /// canonicalize `'static`. This is useful when . /// the query implementation can perform more efficient . /// handling of `'static` regions (e.g. trait evaluation). 24,050 ( 0.00%) pub fn canonicalize_query_keep_static( . &self, . value: V, . query_state: &mut OriginalQueryValues<'tcx>, . ) -> Canonicalized<'tcx, V> . where . V: TypeFoldable<'tcx>, . { 137,894 ( 0.00%) self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed); . 612,554 ( 0.00%) Canonicalizer::canonicalize( 32,240 ( 0.00%) value, . self, 68,947 ( 0.00%) self.tcx, . &CanonicalizeFreeRegionsOtherThanStatic, . query_state, . ) 24,050 ( 0.00%) } . } . . /// Controls how we canonicalize "free regions" that are not inference . /// variables. This depends on what we are canonicalizing *for* -- . /// e.g., if we are canonicalizing to create a query, we want to . /// replace those with inference variables, since we want to make a . /// maximally general query. But if we are canonicalizing a *query . /// response*, then we don't typically replace free regions, as they -- line 134 ---------------------------------------- -- line 141 ---------------------------------------- . ) -> ty::Region<'tcx>; . . fn any(&self) -> bool; . } . . struct CanonicalizeQueryResponse; . . impl CanonicalizeRegionMode for CanonicalizeQueryResponse { 135,565 ( 0.00%) fn canonicalize_free_region<'tcx>( . &self, . canonicalizer: &mut Canonicalizer<'_, 'tcx>, . r: ty::Region<'tcx>, . ) -> ty::Region<'tcx> { 81,339 ( 0.00%) match r { . ty::ReFree(_) . | ty::ReErased . | ty::ReStatic . | ty::ReEmpty(ty::UniverseIndex::ROOT) . | ty::ReEarlyBound(..) => r, . . ty::RePlaceholder(placeholder) => canonicalizer.canonical_var_for_region( . CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderRegion(*placeholder) }, . r, . ), . . ty::ReVar(vid) => { 25,750 ( 0.00%) let universe = canonicalizer.region_var_universe(*vid); . canonicalizer.canonical_var_for_region( . CanonicalVarInfo { kind: CanonicalVarKind::Region(universe) }, . r, . ) . } . . ty::ReEmpty(ui) => { . bug!("canonicalizing 'empty in universe {:?}", ui) // FIXME -- line 175 ---------------------------------------- -- line 188 ---------------------------------------- . tcx.sess.delay_span_bug( . rustc_span::DUMMY_SP, . &format!("unexpected region in query response: `{:?}`", r), . ); . }); . r . } . } 135,565 ( 0.00%) } . . fn any(&self) -> bool { . false . } . } . . struct CanonicalizeUserTypeAnnotation; . . impl CanonicalizeRegionMode for CanonicalizeUserTypeAnnotation { 4,794 ( 0.00%) fn canonicalize_free_region<'tcx>( . &self, . canonicalizer: &mut Canonicalizer<'_, 'tcx>, . r: ty::Region<'tcx>, . ) -> ty::Region<'tcx> { 4,794 ( 0.00%) match r { . ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic => r, . ty::ReVar(_) => canonicalizer.canonical_var_for_region_in_root_universe(r), . _ => { . // We only expect region names that the user can type. . bug!("unexpected region in query response: `{:?}`", r) . } . } 4,794 ( 0.00%) } . . fn any(&self) -> bool { . false 34,094 ( 0.00%) } . } . . struct CanonicalizeAllFreeRegions; . . impl CanonicalizeRegionMode for CanonicalizeAllFreeRegions { 222,760 ( 0.00%) fn canonicalize_free_region<'tcx>( . &self, . canonicalizer: &mut Canonicalizer<'_, 'tcx>, . r: ty::Region<'tcx>, . ) -> ty::Region<'tcx> { . canonicalizer.canonical_var_for_region_in_root_universe(r) 167,070 ( 0.00%) } . . fn any(&self) -> bool { . true 180,680 ( 0.00%) } . } . . struct CanonicalizeFreeRegionsOtherThanStatic; . . impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic { 1,212,252 ( 0.00%) fn canonicalize_free_region<'tcx>( . &self, . canonicalizer: &mut Canonicalizer<'_, 'tcx>, . r: ty::Region<'tcx>, . ) -> ty::Region<'tcx> { 808,168 ( 0.00%) if let ty::ReStatic = r { . r . } else { . canonicalizer.canonical_var_for_region_in_root_universe(r) . } 1,212,252 ( 0.00%) } . . fn any(&self) -> bool { . true . } . } . . struct Canonicalizer<'cx, 'tcx> { . infcx: &'cx InferCtxt<'cx, 'tcx>, -- line 263 ---------------------------------------- -- line 270 ---------------------------------------- . canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode, . needs_canonical_flags: TypeFlags, . . binder_index: ty::DebruijnIndex, . } . . impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { . fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { 1,328,550 ( 0.00%) self.tcx 680,848 ( 0.00%) } . . fn fold_binder(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T> . where . T: TypeFoldable<'tcx>, . { 4,084,569 ( 0.01%) self.binder_index.shift_in(1); 13,234,065 ( 0.03%) let t = t.super_fold_with(self); 4,055,492 ( 0.01%) self.binder_index.shift_out(1); . t . } . 1,954,716 ( 0.01%) fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { 2,932,074 ( 0.01%) match *r { 194 ( 0.00%) ty::ReLateBound(index, ..) => { 194 ( 0.00%) if index >= self.binder_index { . bug!("escaping late-bound region during canonicalization"); . } else { . r . } . } . . ty::ReVar(vid) => { 65,661 ( 0.00%) let resolved_vid = self . .infcx . .inner . .borrow_mut() . .unwrap_region_constraints() . .opportunistic_resolve_var(vid); . debug!( . "canonical: region var found with vid {:?}, \ . opportunistically resolved to {:?}", . vid, r . ); 262,644 ( 0.00%) let r = self.tcx.reuse_or_mk_region(r, ty::ReVar(resolved_vid)); 393,966 ( 0.00%) self.canonicalize_region_mode.canonicalize_free_region(self, r) . } . . ty::ReStatic . | ty::ReEarlyBound(..) . | ty::ReFree(_) . | ty::ReEmpty(_) . | ty::RePlaceholder(..) 4,228,240 ( 0.01%) | ty::ReErased => self.canonicalize_region_mode.canonicalize_free_region(self, r), . } 395,130 ( 0.00%) } . 20,388,858 ( 0.05%) fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { 17,023,631 ( 0.04%) match *t.kind() { 9,342 ( 0.00%) ty::Infer(ty::TyVar(vid)) => { . debug!("canonical: type var found with vid {:?}", vid); 37,368 ( 0.00%) match self.infcx.probe_ty_var(vid) { . // `t` could be a float / int variable; canonicalize that instead. . Ok(t) => { . debug!("(resolved to {:?})", t); . self.fold_ty(t) . } . . // `TyVar(vid)` is unresolved, track its universe index in the canonicalized . // result. . Err(mut ui) => { . // FIXME: perf problem described in #55921. . ui = ty::UniverseIndex::ROOT; . self.canonicalize_ty_var( 8,381 ( 0.00%) CanonicalVarInfo { . kind: CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui)), . }, . t, . ) . } . } . } . -- line 351 ---------------------------------------- -- line 395 ---------------------------------------- . | ty::FnPtr(_) . | ty::Dynamic(..) . | ty::Never . | ty::Tuple(..) . | ty::Projection(..) . | ty::Foreign(..) . | ty::Param(..) . | ty::Opaque(..) => { 6,779,490 ( 0.02%) if t.flags().intersects(self.needs_canonical_flags) { 12,603,794 ( 0.03%) t.super_fold_with(self) . } else { . t . } . } . } 9,585,606 ( 0.02%) } . 3,213 ( 0.00%) fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { 3,213 ( 0.00%) match ct.val { . ty::ConstKind::Infer(InferConst::Var(vid)) => { . debug!("canonical: const var found with vid {:?}", vid); . match self.infcx.probe_const_var(vid) { . Ok(c) => { . debug!("(resolved to {:?})", c); . return self.fold_const(c); . } . -- line 421 ---------------------------------------- -- line 445 ---------------------------------------- . return self.canonicalize_const_var( . CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderConst(placeholder) }, . ct, . ); . } . _ => {} . } . 918 ( 0.00%) let flags = FlagComputation::for_const(ct); 459 ( 0.00%) if flags.intersects(self.needs_canonical_flags) { ct.super_fold_with(self) } else { ct } 2,754 ( 0.00%) } . } . . impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> { . /// The main `canonicalize` method, shared impl of . /// `canonicalize_query` and `canonicalize_response`. 1,471,922 ( 0.00%) fn canonicalize( . value: V, . infcx: &InferCtxt<'_, 'tcx>, . tcx: TyCtxt<'tcx>, . canonicalize_region_mode: &dyn CanonicalizeRegionMode, . query_state: &mut OriginalQueryValues<'tcx>, . ) -> Canonicalized<'tcx, V> . where . V: TypeFoldable<'tcx>, . { 651,490 ( 0.00%) let needs_canonical_flags = if canonicalize_region_mode.any() { . TypeFlags::NEEDS_INFER | . TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS` . TypeFlags::HAS_TY_PLACEHOLDER | . TypeFlags::HAS_CT_PLACEHOLDER . } else { . TypeFlags::NEEDS_INFER . | TypeFlags::HAS_RE_PLACEHOLDER . | TypeFlags::HAS_TY_PLACEHOLDER . | TypeFlags::HAS_CT_PLACEHOLDER . }; . . // Fast path: nothing that needs to be canonicalized. 116,637 ( 0.00%) if !value.has_type_flags(needs_canonical_flags) { . let canon_value = Canonical { . max_universe: ty::UniverseIndex::ROOT, . variables: List::empty(), 87,630 ( 0.00%) value, . }; 241,339 ( 0.00%) return canon_value; . } . 612,521 ( 0.00%) let mut canonicalizer = Canonicalizer { . infcx, . tcx, . canonicalize_region_mode, . needs_canonical_flags, . variables: SmallVec::new(), . query_state, . indices: FxHashMap::default(), . binder_index: ty::INNERMOST, . }; 208,881 ( 0.00%) let out_value = value.fold_with(&mut canonicalizer); . . // Once we have canonicalized `out_value`, it should not . // contain anything that ties it to this inference context . // anymore, so it should live in the global arena. . debug_assert!(!out_value.needs_infer()); . 109,295 ( 0.00%) let canonical_variables = tcx.intern_canonical_var_infos(&canonicalizer.variables); . . let max_universe = canonical_variables . .iter() 175,620 ( 0.00%) .map(|cvar| cvar.universe()) . .max() . .unwrap_or(ty::UniverseIndex::ROOT); . 343,048 ( 0.00%) Canonical { max_universe, variables: canonical_variables, value: out_value } 972,330 ( 0.00%) } . . /// Creates a canonical variable replacing `kind` from the input, . /// or returns an existing variable if `kind` has already been . /// seen. `kind` is expected to be an unbound variable (or . /// potentially a free region). 1,307,490 ( 0.00%) fn canonical_var(&mut self, info: CanonicalVarInfo<'tcx>, kind: GenericArg<'tcx>) -> BoundVar { 261,498 ( 0.00%) let Canonicalizer { variables, query_state, indices, .. } = self; . 261,498 ( 0.00%) let var_values = &mut query_state.var_values; . . // This code is hot. `variables` and `var_values` are usually small . // (fewer than 8 elements ~95% of the time). They are SmallVec's to . // avoid allocations in those cases. We also don't use `indices` to . // determine if a kind has been seen before until the limit of 8 has . // been exceeded, to also avoid allocations for `indices`. 261,498 ( 0.00%) if !var_values.spilled() { . // `var_values` is stack-allocated. `indices` isn't used yet. Do a . // direct linear search of `var_values`. . if let Some(idx) = var_values.iter().position(|&k| k == kind) { . // `kind` is already present in `var_values`. . BoundVar::new(idx) . } else { . // `kind` isn't present in `var_values`. Append it. Likewise . // for `info` and `variables`. . variables.push(info); . var_values.push(kind); 287,360 ( 0.00%) assert_eq!(variables.len(), var_values.len()); . . // If `var_values` has become big enough to be heap-allocated, . // fill up `indices` to facilitate subsequent lookups. 57,472 ( 0.00%) if var_values.spilled() { 55 ( 0.00%) assert!(indices.is_empty()); 220 ( 0.00%) *indices = var_values . .iter() . .enumerate() . .map(|(i, &kind)| (kind, BoundVar::new(i))) . .collect(); . } . // The cv is the index of the appended element. 114,944 ( 0.00%) BoundVar::new(var_values.len() - 1) . } . } else { . // `var_values` is large. Do a hashmap search via `indices`. 915 ( 0.00%) *indices.entry(kind).or_insert_with(|| { . variables.push(info); . var_values.push(kind); 548 ( 0.00%) assert_eq!(variables.len(), var_values.len()); 274 ( 0.00%) BoundVar::new(variables.len() - 1) . }) . } 1,176,741 ( 0.00%) } . . /// Shorthand helper that creates a canonical region variable for . /// `r` (always in the root universe). The reason that we always . /// put these variables into the root universe is because this . /// method is used during **query construction:** in that case, we . /// are taking all the regions and just putting them into the most . /// generic context we can. This may generate solutions that don't . /// fit (e.g., that equate some region variable with a placeholder -- line 578 ---------------------------------------- -- line 599 ---------------------------------------- . . /// Creates a canonical variable (with the given `info`) . /// representing the region `r`; return a region referencing it. . fn canonical_var_for_region( . &mut self, . info: CanonicalVarInfo<'tcx>, . r: ty::Region<'tcx>, . ) -> ty::Region<'tcx> { 464,136 ( 0.00%) let var = self.canonical_var(info, r.into()); . let br = ty::BoundRegion { var, kind: ty::BrAnon(var.as_u32()) }; 96,134 ( 0.00%) let region = ty::ReLateBound(self.binder_index, br); 672,938 ( 0.00%) self.tcx().mk_region(region) . } . . /// Given a type variable `ty_var` of the given kind, first check . /// if `ty_var` is bound to anything; if so, canonicalize . /// *that*. Otherwise, create a new canonical variable for . /// `ty_var`. 67,184 ( 0.00%) fn canonicalize_ty_var(&mut self, info: CanonicalVarInfo<'tcx>, ty_var: Ty<'tcx>) -> Ty<'tcx> { 8,398 ( 0.00%) let infcx = self.infcx; . let bound_to = infcx.shallow_resolve(ty_var); 8,398 ( 0.00%) if bound_to != ty_var { 24 ( 0.00%) self.fold_ty(bound_to) . } else { 58,765 ( 0.00%) let var = self.canonical_var(info, ty_var.into()); 8,395 ( 0.00%) self.tcx().mk_ty(ty::Bound(self.binder_index, var.into())) . } 50,370 ( 0.00%) } . . /// Given a type variable `const_var` of the given kind, first check . /// if `const_var` is bound to anything; if so, canonicalize . /// *that*. Otherwise, create a new canonical variable for . /// `const_var`. . fn canonicalize_const_var( . &mut self, . info: CanonicalVarInfo<'tcx>, -- line 634 ---------------------------------------- 1,346,521 ( 0.00%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/sty.rs -------------------------------------------------------------------------------- Ir -- line 21 ---------------------------------------- . use rustc_target::spec::abi; . use std::borrow::Cow; . use std::cmp::Ordering; . use std::marker::PhantomData; . use std::ops::Range; . use ty::util::IntTypeExt; . . #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] 112 ( 0.00%) #[derive(HashStable, TypeFoldable, Lift)] . pub struct TypeAndMut<'tcx> { 33,823 ( 0.00%) pub ty: Ty<'tcx>, 169,115 ( 0.00%) pub mutbl: hir::Mutability, . } . . #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)] . #[derive(HashStable)] . /// A "free" region `fr` can be interpreted as "some region . /// at least as big as the scope `fr.scope`". . pub struct FreeRegion { 79,457 ( 0.00%) pub scope: DefId, 134,167 ( 0.00%) pub bound_region: BoundRegionKind, . } . 1,434,066 ( 0.00%) #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)] 108 ( 0.00%) #[derive(HashStable)] . pub enum BoundRegionKind { . /// An anonymous region parameter for a given fn (&T) 93,556 ( 0.00%) BrAnon(u32), . . /// Named region parameters for functions (a in &'a T) . /// . /// The `DefId` is needed to distinguish free regions in . /// the event of shadowing. 1,235 ( 0.00%) BrNamed(DefId, Symbol), . . /// Anonymous region for the implicit env pointer parameter . /// to a closure . BrEnv, . } . 2,738 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, PartialOrd, Ord)] . #[derive(HashStable)] . pub struct BoundRegion { 331,708 ( 0.00%) pub var: BoundVar, 295,600 ( 0.00%) pub kind: BoundRegionKind, . } . . impl BoundRegionKind { . pub fn is_named(&self) -> bool { . match *self { . BoundRegionKind::BrNamed(_, name) => name != kw::UnderscoreLifetime, . _ => false, . } . } . } . . /// Defines the kinds of types. . /// . /// N.B., if you change this, you'll probably want to change the corresponding . /// AST structure in `rustc_ast/src/ast.rs` as well. 67,852,321 ( 0.18%) #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable, Debug)] 307,063 ( 0.00%) #[derive(HashStable)] . #[rustc_diagnostic_item = "TyKind"] . pub enum TyKind<'tcx> { . /// The primitive boolean type. Written as `bool`. . Bool, . . /// The primitive character type; holds a Unicode scalar value . /// (a non-surrogate code point). Written as `char`. . Char, -- line 90 ---------------------------------------- -- line 99 ---------------------------------------- . Float(ty::FloatTy), . . /// Algebraic data types (ADT). For example: structures, enumerations and unions. . /// . /// InternalSubsts here, possibly against intuition, *may* contain `Param`s. . /// That is, even after substitution it is possible that there are type . /// variables. This happens when the `Adt` corresponds to an ADT . /// definition and not a concrete use of it. 14,932,972 ( 0.04%) Adt(&'tcx AdtDef, SubstsRef<'tcx>), . . /// An unsized FFI type that is opaque to Rust. Written as `extern type T`. . Foreign(DefId), . . /// The pointee of a string slice. Written as `str`. . Str, . . /// An array with the given length. Written as `[T; n]`. 72,636 ( 0.00%) Array(Ty<'tcx>, &'tcx ty::Const<'tcx>), . . /// The pointee of an array slice. Written as `[T]`. . Slice(Ty<'tcx>), . . /// A raw pointer. Written as `*mut T` or `*const T` . RawPtr(TypeAndMut<'tcx>), . . /// A reference; a pointer with an associated lifetime. Written as . /// `&'a mut T` or `&'a T`. 2,879,725 ( 0.01%) Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability), . . /// The anonymous type of a function declaration/definition. Each . /// function has a unique type, which is output (for a function . /// named `foo` returning an `i32`) as `fn() -> i32 {foo}`. . /// . /// For example the type of `bar` here: . /// . /// ```rust -- line 134 ---------------------------------------- -- line 143 ---------------------------------------- . /// . /// ```rust . /// fn foo() -> i32 { 1 } . /// let bar: fn() -> i32 = foo; . /// ``` . FnPtr(PolyFnSig<'tcx>), . . /// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`. 3,805,383 ( 0.01%) Dynamic(&'tcx List>>, ty::Region<'tcx>), . . /// The anonymous type of a closure. Used to represent the type of . /// `|a| a`. . Closure(DefId, SubstsRef<'tcx>), . . /// The anonymous type of a generator. Used to represent the type of . /// `|a| yield a`. 22,999 ( 0.00%) Generator(DefId, SubstsRef<'tcx>, hir::Movability), . . /// A type representing the types stored inside a generator. . /// This should only appear in GeneratorInteriors. . GeneratorWitness(Binder<'tcx, &'tcx List>>), . . /// The never type `!`. . Never, . -- line 167 ---------------------------------------- -- line 180 ---------------------------------------- . /// The substitutions are for the generics of the function in question. . /// After typeck, the concrete type can be found in the `types` map. . Opaque(DefId, SubstsRef<'tcx>), . . /// A type parameter; for example, `T` in `fn f(x: T) {}`. . Param(ParamTy), . . /// Bound type variable, used only when preparing a trait query. 8,371 ( 0.00%) Bound(ty::DebruijnIndex, BoundTy), . . /// A placeholder type - universally quantified higher-ranked type. . Placeholder(ty::PlaceholderType), . . /// A type variable used during type checking. . Infer(InferTy), . . /// A placeholder for a type which could not be computed; this is -- line 196 ---------------------------------------- -- line 330 ---------------------------------------- . pub closure_kind_ty: T, . pub closure_sig_as_fn_ptr_ty: T, . pub tupled_upvars_ty: T, . } . . impl<'tcx> ClosureSubsts<'tcx> { . /// Construct `ClosureSubsts` from `ClosureSubstsParts`, containing `Substs` . /// for the closure parent, alongside additional closure-specific components. 93 ( 0.00%) pub fn new( . tcx: TyCtxt<'tcx>, . parts: ClosureSubstsParts<'tcx, Ty<'tcx>>, . ) -> ClosureSubsts<'tcx> { . ClosureSubsts { . substs: tcx.mk_substs( 186 ( 0.00%) parts.parent_substs.iter().copied().chain( 372 ( 0.00%) [parts.closure_kind_ty, parts.closure_sig_as_fn_ptr_ty, parts.tupled_upvars_ty] . .iter() . .map(|&ty| ty.into()), . ), . ), . } 186 ( 0.00%) } . . /// Divides the closure substs into their respective components. . /// The ordering assumed here must match that used by `ClosureSubsts::new` above. 2,914 ( 0.00%) fn split(self) -> ClosureSubstsParts<'tcx, GenericArg<'tcx>> { . match self.substs[..] { 19,830 ( 0.00%) [ 5,180 ( 0.00%) ref parent_substs @ .., 5,772 ( 0.00%) closure_kind_ty, 2,559 ( 0.00%) closure_sig_as_fn_ptr_ty, 4,502 ( 0.00%) tupled_upvars_ty, 11,656 ( 0.00%) ] => ClosureSubstsParts { . parent_substs, . closure_kind_ty, . closure_sig_as_fn_ptr_ty, . tupled_upvars_ty, . }, . _ => bug!("closure substs missing synthetics"), . } 8,742 ( 0.00%) } . . /// Returns `true` only if enough of the synthetic types are known to . /// allow using all of the methods on `ClosureSubsts` without panicking. . /// . /// Used primarily by `ty::print::pretty` to be able to handle closure . /// types that haven't had their synthetic types substituted in. 4 ( 0.00%) pub fn is_valid(self) -> bool { 8 ( 0.00%) self.substs.len() >= 3 8 ( 0.00%) && matches!(self.split().tupled_upvars_ty.expect_ty().kind(), Tuple(_)) 8 ( 0.00%) } . . /// Returns the substitutions of the closure's parent. . pub fn parent_substs(self) -> &'tcx [GenericArg<'tcx>] { . self.split().parent_substs . } . . /// Returns an iterator over the list of types of captured paths by the closure. . /// In case there was a type error in figuring out the types of the captured path, an . /// empty iterator is returned. . #[inline] 282 ( 0.00%) pub fn upvar_tys(self) -> impl Iterator> + 'tcx { 1,831 ( 0.00%) match self.tupled_upvars_ty().kind() { . TyKind::Error(_) => None, 742 ( 0.00%) TyKind::Tuple(..) => Some(self.tupled_upvars_ty().tuple_fields()), . TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"), . ty => bug!("Unexpected representation of upvar types tuple {:?}", ty), . } . .into_iter() . .flatten() 188 ( 0.00%) } . . /// Returns the tuple type representing the upvars for this closure. . #[inline] . pub fn tupled_upvars_ty(self) -> Ty<'tcx> { 15,175 ( 0.00%) self.split().tupled_upvars_ty.expect_ty() . } . . /// Returns the closure kind for this closure; may return a type . /// variable during inference. To get the closure kind during . /// inference, use `infcx.closure_kind(substs)`. 1,264 ( 0.00%) pub fn kind_ty(self) -> Ty<'tcx> { . self.split().closure_kind_ty.expect_ty() 2,528 ( 0.00%) } . . /// Returns the `fn` pointer type representing the closure signature for this . /// closure. . // FIXME(eddyb) this should be unnecessary, as the shallowly resolved . // type is known at the time of the creation of `ClosureSubsts`, . // see `rustc_typeck::check::closure`. 1 ( 0.00%) pub fn sig_as_fn_ptr_ty(self) -> Ty<'tcx> { . self.split().closure_sig_as_fn_ptr_ty.expect_ty() 2 ( 0.00%) } . . /// Returns the closure kind for this closure; only usable outside . /// of an inference context, because in that context we know that . /// there are no type variables. . /// . /// If you have an inference context, use `infcx.closure_kind()`. 25 ( 0.00%) pub fn kind(self) -> ty::ClosureKind { 155 ( 0.00%) self.kind_ty().to_opt_closure_kind().unwrap() 50 ( 0.00%) } . . /// Extracts the signature from the closure. 1,425 ( 0.00%) pub fn sig(self) -> ty::PolyFnSig<'tcx> { . let ty = self.sig_as_fn_ptr_ty(); 2,850 ( 0.00%) match ty.kind() { 5,700 ( 0.00%) ty::FnPtr(sig) => *sig, . _ => bug!("closure_sig_as_fn_ptr_ty is not a fn-ptr: {:?}", ty.kind()), . } 4,275 ( 0.00%) } . } . . /// Similar to `ClosureSubsts`; see the above documentation for more. . #[derive(Copy, Clone, Debug, TypeFoldable)] . pub struct GeneratorSubsts<'tcx> { . pub substs: SubstsRef<'tcx>, . } . -- line 448 ---------------------------------------- -- line 453 ---------------------------------------- . pub return_ty: T, . pub witness: T, . pub tupled_upvars_ty: T, . } . . impl<'tcx> GeneratorSubsts<'tcx> { . /// Construct `GeneratorSubsts` from `GeneratorSubstsParts`, containing `Substs` . /// for the generator parent, alongside additional generator-specific components. 9 ( 0.00%) pub fn new( . tcx: TyCtxt<'tcx>, . parts: GeneratorSubstsParts<'tcx, Ty<'tcx>>, . ) -> GeneratorSubsts<'tcx> { . GeneratorSubsts { . substs: tcx.mk_substs( 18 ( 0.00%) parts.parent_substs.iter().copied().chain( 27 ( 0.00%) [ 9 ( 0.00%) parts.resume_ty, . parts.yield_ty, 9 ( 0.00%) parts.return_ty, . parts.witness, 9 ( 0.00%) parts.tupled_upvars_ty, . ] . .iter() . .map(|&ty| ty.into()), . ), . ), . } 18 ( 0.00%) } . . /// Divides the generator substs into their respective components. . /// The ordering assumed here must match that used by `GeneratorSubsts::new` above. 474 ( 0.00%) fn split(self) -> GeneratorSubstsParts<'tcx, GenericArg<'tcx>> { . match self.substs[..] { 5,802 ( 0.00%) [ref parent_substs @ .., resume_ty, yield_ty, return_ty, witness, tupled_upvars_ty] => { 2,370 ( 0.00%) GeneratorSubstsParts { . parent_substs, . resume_ty, . yield_ty, . return_ty, . witness, . tupled_upvars_ty, . } . } . _ => bug!("generator substs missing synthetics"), . } 1,422 ( 0.00%) } . . /// Returns `true` only if enough of the synthetic types are known to . /// allow using all of the methods on `GeneratorSubsts` without panicking. . /// . /// Used primarily by `ty::print::pretty` to be able to handle generator . /// types that haven't had their synthetic types substituted in. 9 ( 0.00%) pub fn is_valid(self) -> bool { 18 ( 0.00%) self.substs.len() >= 5 18 ( 0.00%) && matches!(self.split().tupled_upvars_ty.expect_ty().kind(), Tuple(_)) 18 ( 0.00%) } . . /// Returns the substitutions of the generator's parent. . pub fn parent_substs(self) -> &'tcx [GenericArg<'tcx>] { . self.split().parent_substs . } . . /// This describes the types that can be contained in a generator. . /// It will be a type variable initially and unified in the last stages of typeck of a body. . /// It contains a tuple of all the types that could end up on a generator frame. . /// The state transformation MIR pass may only produce layouts which mention types . /// in this tuple. Upvars are not counted here. 39 ( 0.00%) pub fn witness(self) -> Ty<'tcx> { . self.split().witness.expect_ty() 78 ( 0.00%) } . . /// Returns an iterator over the list of types of captured paths by the generator. . /// In case there was a type error in figuring out the types of the captured path, an . /// empty iterator is returned. . #[inline] 282 ( 0.00%) pub fn upvar_tys(self) -> impl Iterator> + 'tcx { 588 ( 0.00%) match self.tupled_upvars_ty().kind() { . TyKind::Error(_) => None, 356 ( 0.00%) TyKind::Tuple(..) => Some(self.tupled_upvars_ty().tuple_fields()), . TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"), . ty => bug!("Unexpected representation of upvar types tuple {:?}", ty), . } . .into_iter() . .flatten() 188 ( 0.00%) } . . /// Returns the tuple type representing the upvars for this generator. . #[inline] . pub fn tupled_upvars_ty(self) -> Ty<'tcx> { 1,808 ( 0.00%) self.split().tupled_upvars_ty.expect_ty() . } . . /// Returns the type representing the resume type of the generator. 18 ( 0.00%) pub fn resume_ty(self) -> Ty<'tcx> { . self.split().resume_ty.expect_ty() 36 ( 0.00%) } . . /// Returns the type representing the yield type of the generator. 9 ( 0.00%) pub fn yield_ty(self) -> Ty<'tcx> { . self.split().yield_ty.expect_ty() 18 ( 0.00%) } . . /// Returns the type representing the return type of the generator. 9 ( 0.00%) pub fn return_ty(self) -> Ty<'tcx> { . self.split().return_ty.expect_ty() 18 ( 0.00%) } . . /// Returns the "generator signature", which consists of its yield . /// and return types. . /// . /// N.B., some bits of the code prefers to see this wrapped in a . /// binder, but it never contains bound regions. Probably this . /// function should be removed. 600 ( 0.00%) pub fn poly_sig(self) -> PolyGenSig<'tcx> { 152 ( 0.00%) ty::Binder::dummy(self.sig()) 600 ( 0.00%) } . . /// Returns the "generator signature", which consists of its resume, yield . /// and return types. 161 ( 0.00%) pub fn sig(self) -> GenSig<'tcx> { 483 ( 0.00%) ty::GenSig { . resume_ty: self.resume_ty(), . yield_ty: self.yield_ty(), . return_ty: self.return_ty(), . } 483 ( 0.00%) } . } . . impl<'tcx> GeneratorSubsts<'tcx> { . /// Generator has not been resumed yet. . pub const UNRESUMED: usize = 0; . /// Generator has returned or is completed. . pub const RETURNED: usize = 1; . /// Generator has been poisoned. -- line 586 ---------------------------------------- -- line 589 ---------------------------------------- . const UNRESUMED_NAME: &'static str = "Unresumed"; . const RETURNED_NAME: &'static str = "Returned"; . const POISONED_NAME: &'static str = "Panicked"; . . /// The valid variant indices of this generator. . #[inline] . pub fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range { . // FIXME requires optimized MIR 16 ( 0.00%) let num_variants = tcx.generator_layout(def_id).unwrap().variant_fields.len(); . VariantIdx::new(0)..VariantIdx::new(num_variants) . } . . /// The discriminant for the given variant. Panics if the `variant_index` is . /// out of range. . #[inline] . pub fn discriminant_for_variant( . &self, . def_id: DefId, . tcx: TyCtxt<'tcx>, . variant_index: VariantIdx, . ) -> Discr<'tcx> { . // Generators don't support explicit discriminant values, so they are . // the same as the variant index. 8 ( 0.00%) assert!(self.variant_range(def_id, tcx).contains(&variant_index)); 16 ( 0.00%) Discr { val: variant_index.as_usize() as u128, ty: self.discr_ty(tcx) } . } . . /// The set of all discriminants for the generator, enumerated with their . /// variant indices. . #[inline] . pub fn discriminants( . self, . def_id: DefId, -- line 621 ---------------------------------------- -- line 623 ---------------------------------------- . ) -> impl Iterator)> + Captures<'tcx> { . self.variant_range(def_id, tcx).map(move |index| { . (index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) }) . }) . } . . /// Calls `f` with a reference to the name of the enumerator for the given . /// variant `v`. 18 ( 0.00%) pub fn variant_name(v: VariantIdx) -> Cow<'static, str> { 36 ( 0.00%) match v.as_usize() { . Self::UNRESUMED => Cow::from(Self::UNRESUMED_NAME), . Self::RETURNED => Cow::from(Self::RETURNED_NAME), . Self::POISONED => Cow::from(Self::POISONED_NAME), 42 ( 0.00%) _ => Cow::from(format!("Suspend{}", v.as_usize() - 3)), . } 24 ( 0.00%) } . . /// The type of the state discriminant used in the generator type. . #[inline] . pub fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { 64 ( 0.00%) tcx.types.u32 . } . . /// This returns the types of the MIR locals which had to be stored across suspension points. . /// It is calculated in rustc_const_eval::transform::generator::StateTransform. . /// All the types here must be in the tuple in GeneratorInterior. . /// . /// The locals are grouped by their variant number. Note that some locals may . /// be repeated in multiple variants. . #[inline] . pub fn state_tys( . self, . def_id: DefId, . tcx: TyCtxt<'tcx>, . ) -> impl Iterator> + Captures<'tcx>> { 100 ( 0.00%) let layout = tcx.generator_layout(def_id).unwrap(); . layout.variant_fields.iter().map(move |variant| { 70 ( 0.00%) variant.iter().map(move |field| layout.field_tys[*field].subst(tcx, self.substs)) . }) . } . . /// This is the types of the fields of a generator which are not stored in a . /// variant. . #[inline] 674 ( 0.00%) pub fn prefix_tys(self) -> impl Iterator> { . self.upvar_tys() 476 ( 0.00%) } . } . . #[derive(Debug, Copy, Clone, HashStable)] . pub enum UpvarSubsts<'tcx> { . Closure(SubstsRef<'tcx>), . Generator(SubstsRef<'tcx>), . } . . impl<'tcx> UpvarSubsts<'tcx> { . /// Returns an iterator over the list of types of captured paths by the closure/generator. . /// In case there was a type error in figuring out the types of the captured path, an . /// empty iterator is returned. . #[inline] . pub fn upvar_tys(self) -> impl Iterator> + 'tcx { 272 ( 0.00%) let tupled_tys = match self { 329 ( 0.00%) UpvarSubsts::Closure(substs) => substs.as_closure().tupled_upvars_ty(), 45 ( 0.00%) UpvarSubsts::Generator(substs) => substs.as_generator().tupled_upvars_ty(), . }; . 612 ( 0.00%) match tupled_tys.kind() { . TyKind::Error(_) => None, 510 ( 0.00%) TyKind::Tuple(..) => Some(self.tupled_upvars_ty().tuple_fields()), . TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"), . ty => bug!("Unexpected representation of upvar types tuple {:?}", ty), . } . .into_iter() . .flatten() . } . . #[inline] . pub fn tupled_upvars_ty(self) -> Ty<'tcx> { 476 ( 0.00%) match self { 479 ( 0.00%) UpvarSubsts::Closure(substs) => substs.as_closure().tupled_upvars_ty(), 89 ( 0.00%) UpvarSubsts::Generator(substs) => substs.as_generator().tupled_upvars_ty(), . } . } . } . . /// An inline const is modeled like . /// . /// const InlineConst<'l0...'li, T0...Tj, R>: R; . /// -- line 711 ---------------------------------------- -- line 760 ---------------------------------------- . } . . /// Returns the type of this inline const. . pub fn ty(self) -> Ty<'tcx> { . self.split().ty.expect_ty() . } . } . 5,507,198 ( 0.01%) #[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, TyEncodable, TyDecodable)] 7,327,977 ( 0.02%) #[derive(HashStable, TypeFoldable)] . pub enum ExistentialPredicate<'tcx> { . /// E.g., `Iterator`. . Trait(ExistentialTraitRef<'tcx>), . /// E.g., `Iterator::Item = T`. . Projection(ExistentialProjection<'tcx>), . /// E.g., `Send`. 1,251 ( 0.00%) AutoTrait(DefId), . } . . impl<'tcx> ExistentialPredicate<'tcx> { . /// Compares via an ordering that will not change if modules are reordered or other changes are . /// made to the tree. In particular, this ordering is preserved across incremental compilations. 118,645 ( 0.00%) pub fn stable_cmp(&self, tcx: TyCtxt<'tcx>, other: &Self) -> Ordering { . use self::ExistentialPredicate::*; 156,900 ( 0.00%) match (*self, *other) { . (Trait(_), Trait(_)) => Ordering::Equal, . (Projection(ref a), Projection(ref b)) => { . tcx.def_path_hash(a.item_def_id).cmp(&tcx.def_path_hash(b.item_def_id)) . } . (AutoTrait(ref a), AutoTrait(ref b)) => { . tcx.def_path_hash(*a).cmp(&tcx.def_path_hash(*b)) . } . (Trait(_), _) => Ordering::Less, . (Projection(_), Trait(_)) => Ordering::Greater, . (Projection(_), _) => Ordering::Less, . (AutoTrait(_), _) => Ordering::Greater, . } 142,374 ( 0.00%) } . } . . impl<'tcx> Binder<'tcx, ExistentialPredicate<'tcx>> { 14,238 ( 0.00%) pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> { . use crate::ty::ToPredicate; 7,966 ( 0.00%) match self.skip_binder() { . ExistentialPredicate::Trait(tr) => { . self.rebind(tr).with_self_ty(tcx, self_ty).without_const().to_predicate(tcx) . } . ExistentialPredicate::Projection(p) => { 14 ( 0.00%) self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx) . } . ExistentialPredicate::AutoTrait(did) => { . let trait_ref = self.rebind(ty::TraitRef { . def_id: did, . substs: tcx.mk_substs_trait(self_ty, &[]), . }); . trait_ref.without_const().to_predicate(tcx) . } . } 12,656 ( 0.00%) } . } . . impl<'tcx> List>> { . /// Returns the "principal `DefId`" of this set of existential predicates. . /// . /// A Rust trait object type consists (in addition to a lifetime bound) . /// of a set of trait bounds, which are separated into any number . /// of auto-trait bounds, and at most one non-auto-trait bound. The -- line 826 ---------------------------------------- -- line 839 ---------------------------------------- . /// are the set `{Sync}`. . /// . /// It is also possible to have a "trivial" trait object that . /// consists only of auto traits, with no principal - for example, . /// `dyn Send + Sync`. In that case, the set of auto-trait bounds . /// is `{Send, Sync}`, while there is no principal. These trait objects . /// have a "trivial" vtable consisting of just the size, alignment, . /// and destructor. 596 ( 0.00%) pub fn principal(&self) -> Option>> { 8,317 ( 0.00%) self[0] 5,837 ( 0.00%) .map_bound(|this| match this { . ExistentialPredicate::Trait(tr) => Some(tr), . _ => None, 2,384 ( 0.00%) }) . .transpose() 1,788 ( 0.00%) } . 1,585 ( 0.00%) pub fn principal_def_id(&self) -> Option { . self.principal().map(|trait_ref| trait_ref.skip_binder().def_id) 3,170 ( 0.00%) } . . #[inline] . pub fn projection_bounds<'a>( . &'a self, . ) -> impl Iterator>> + 'a { . self.iter().filter_map(|predicate| { 156 ( 0.00%) predicate 1,544 ( 0.00%) .map_bound(|pred| match pred { 234 ( 0.00%) ExistentialPredicate::Projection(projection) => Some(projection), . _ => None, . }) . .transpose() . }) . } . . #[inline] . pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { 14 ( 0.00%) self.iter().filter_map(|predicate| match predicate.skip_binder() { . ExistentialPredicate::AutoTrait(did) => Some(did), . _ => None, . }) . } . } . . /// A complete reference to a trait. These take numerous guises in syntax, . /// but perhaps the most recognizable form is in a where-clause: -- line 884 ---------------------------------------- -- line 886 ---------------------------------------- . /// T: Foo . /// . /// This would be represented by a trait-reference where the `DefId` is the . /// `DefId` for the trait `Foo` and the substs define `T` as parameter 0, . /// and `U` as parameter 1. . /// . /// Trait references also appear in object types like `Foo`, but in . /// that case the `Self` parameter is absent from the substitutions. 49,433 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 8,021,567 ( 0.02%) #[derive(HashStable, TypeFoldable)] . pub struct TraitRef<'tcx> { 11,321 ( 0.00%) pub def_id: DefId, 4,130,893 ( 0.01%) pub substs: SubstsRef<'tcx>, . } . . impl<'tcx> TraitRef<'tcx> { 5,787 ( 0.00%) pub fn new(def_id: DefId, substs: SubstsRef<'tcx>) -> TraitRef<'tcx> { . TraitRef { def_id, substs } 23,148 ( 0.00%) } . . /// Returns a `TraitRef` of the form `P0: Foo` where `Pi` . /// are the parameters defined on trait. 4,545 ( 0.00%) pub fn identity(tcx: TyCtxt<'tcx>, def_id: DefId) -> Binder<'tcx, TraitRef<'tcx>> { 2,020 ( 0.00%) ty::Binder::dummy(TraitRef { . def_id, 3,030 ( 0.00%) substs: InternalSubsts::identity_for_item(tcx, def_id), . }) 4,040 ( 0.00%) } . . #[inline] 3 ( 0.00%) pub fn self_ty(&self) -> Ty<'tcx> { . self.substs.type_at(0) 2 ( 0.00%) } . 15,616 ( 0.00%) pub fn from_method( . tcx: TyCtxt<'tcx>, . trait_id: DefId, . substs: SubstsRef<'tcx>, . ) -> ty::TraitRef<'tcx> { . let defs = tcx.generics_of(trait_id); . 1,952 ( 0.00%) ty::TraitRef { def_id: trait_id, substs: tcx.intern_substs(&substs[..defs.params.len()]) } 21,472 ( 0.00%) } . } . . pub type PolyTraitRef<'tcx> = Binder<'tcx, TraitRef<'tcx>>; . . impl<'tcx> PolyTraitRef<'tcx> { . pub fn self_ty(&self) -> Binder<'tcx, Ty<'tcx>> { . self.map_bound_ref(|tr| tr.self_ty()) . } . . pub fn def_id(&self) -> DefId { 25,920 ( 0.00%) self.skip_binder().def_id 8,640 ( 0.00%) } . 14,920 ( 0.00%) pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> { 29,840 ( 0.00%) self.map_bound(|trait_ref| ty::TraitPredicate { . trait_ref, . constness: ty::BoundConstness::NotConst, . polarity: ty::ImplPolarity::Positive, . }) 14,920 ( 0.00%) } . } . . /// An existential reference to a trait, where `Self` is erased. . /// For example, the trait object `Trait<'a, 'b, X, Y>` is: . /// . /// exists T. T: Trait<'a, 'b, X, Y> . /// . /// The substitutions don't include the erased `Self`, only trait . /// type and lifetime parameters (`[X, Y]` and `['a, 'b]` above). 986 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 1,775,258 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct ExistentialTraitRef<'tcx> { 21,614 ( 0.00%) pub def_id: DefId, 1,768,569 ( 0.00%) pub substs: SubstsRef<'tcx>, . } . . impl<'tcx> ExistentialTraitRef<'tcx> { 1,364 ( 0.00%) pub fn erase_self_ty( . tcx: TyCtxt<'tcx>, . trait_ref: ty::TraitRef<'tcx>, . ) -> ty::ExistentialTraitRef<'tcx> { . // Assert there is a Self. . trait_ref.substs.type_at(0); . . ty::ExistentialTraitRef { . def_id: trait_ref.def_id, . substs: tcx.intern_substs(&trait_ref.substs[1..]), . } 1,364 ( 0.00%) } . . /// Object types don't have a self type specified. Therefore, when . /// we convert the principal trait-ref into a normal trait-ref, . /// you must give *some* self type. A common choice is `mk_err()` . /// or some placeholder type. 242 ( 0.00%) pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::TraitRef<'tcx> { . // otherwise the escaping vars would be captured by the binder . // debug_assert!(!self_ty.has_escaping_bound_vars()); . 121 ( 0.00%) ty::TraitRef { def_id: self.def_id, substs: tcx.mk_substs_trait(self_ty, self.substs) } 605 ( 0.00%) } . } . . pub type PolyExistentialTraitRef<'tcx> = Binder<'tcx, ExistentialTraitRef<'tcx>>; . . impl<'tcx> PolyExistentialTraitRef<'tcx> { . pub fn def_id(&self) -> DefId { . self.skip_binder().def_id . } . . /// Object types don't have a self type specified. Therefore, when . /// we convert the principal trait-ref into a normal trait-ref, . /// you must give *some* self type. A common choice is `mk_err()` . /// or some placeholder type. 867 ( 0.00%) pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> { 1,399 ( 0.00%) self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty)) 1,156 ( 0.00%) } . } . 180,953 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] 225 ( 0.00%) #[derive(HashStable)] . pub enum BoundVariableKind { . Ty(BoundTyKind), . Region(BoundRegionKind), . Const, . } . . /// Binder is a binder for higher-ranked lifetimes or types. It is part of the . /// compiler's representation for things like `for<'a> Fn(&'a isize)` . /// (which would be represented by the type `PolyTraitRef == . /// Binder<'tcx, TraitRef>`). Note that when we instantiate, . /// erase, or otherwise "discharge" these bound vars, we change the . /// type from `Binder<'tcx, T>` to just `T` (see . /// e.g., `liberate_late_bound_regions`). . /// . /// `Decodable` and `Encodable` are implemented for `Binder` using the `impl_binder_encode_decode!` macro. 9,412,540 ( 0.02%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 3,625,326 ( 0.01%) pub struct Binder<'tcx, T>(T, &'tcx List); . . impl<'tcx, T> Binder<'tcx, T> . where . T: TypeFoldable<'tcx>, . { . /// Wraps `value` in a binder, asserting that `value` does not . /// contain any bound vars that would be bound by the . /// binder. This is commonly used to 'inject' a value T into a . /// different binding level. 75,185 ( 0.00%) pub fn dummy(value: T) -> Binder<'tcx, T> { 281,740 ( 0.00%) assert!(!value.has_escaping_bound_vars()); 692,563 ( 0.00%) Binder(value, ty::List::empty()) 73,982 ( 0.00%) } . . pub fn bind_with_vars(value: T, vars: &'tcx List) -> Binder<'tcx, T> { . if cfg!(debug_assertions) { . let mut validator = ValidateBoundVars::new(vars); . value.visit_with(&mut validator); . } 85,382 ( 0.00%) Binder(value, vars) . } . } . . impl<'tcx, T> Binder<'tcx, T> { . /// Skips the binder and returns the "bound" value. This is a . /// risky thing to do because it's easy to get confused about . /// De Bruijn indices and the like. It is usually better to . /// discharge the binder using `no_bound_vars` or -- line 1053 ---------------------------------------- -- line 1059 ---------------------------------------- . /// accounting. . /// . /// Some examples where `skip_binder` is reasonable: . /// . /// - extracting the `DefId` from a PolyTraitRef; . /// - comparing the self type of a PolyTraitRef to see if it is equal to . /// a type parameter `X`, since the type `X` does not reference any regions . pub fn skip_binder(self) -> T { 4,107,324 ( 0.01%) self.0 . } . . pub fn bound_vars(&self) -> &'tcx List { 4,552 ( 0.00%) self.1 . } . . pub fn as_ref(&self) -> Binder<'tcx, &T> { 53,902 ( 0.00%) Binder(&self.0, self.1) . } . . pub fn map_bound_ref_unchecked(&self, f: F) -> Binder<'tcx, U> . where . F: FnOnce(&T) -> U, . { . let value = f(&self.0); . Binder(value, self.1) -- line 1083 ---------------------------------------- -- line 1085 ---------------------------------------- . . pub fn map_bound_ref>(&self, f: F) -> Binder<'tcx, U> . where . F: FnOnce(&T) -> U, . { . self.as_ref().map_bound(f) . } . 2,216 ( 0.00%) pub fn map_bound>(self, f: F) -> Binder<'tcx, U> . where . F: FnOnce(T) -> U, . { 196,993 ( 0.00%) let value = f(self.0); . if cfg!(debug_assertions) { . let mut validator = ValidateBoundVars::new(self.1); . value.visit_with(&mut validator); . } 932,154 ( 0.00%) Binder(value, self.1) 2,327 ( 0.00%) } . . pub fn try_map_bound, E>(self, f: F) -> Result, E> . where . F: FnOnce(T) -> Result, . { . let value = f(self.0)?; . if cfg!(debug_assertions) { . let mut validator = ValidateBoundVars::new(self.1); . value.visit_with(&mut validator); . } 47,091 ( 0.00%) Ok(Binder(value, self.1)) . } . . /// Wraps a `value` in a binder, using the same bound variables as the . /// current `Binder`. This should not be used if the new value *changes* . /// the bound variables. Note: the (old or new) value itself does not . /// necessarily need to *name* all the bound variables. . /// . /// This currently doesn't do anything different than `bind`, because we -- line 1122 ---------------------------------------- -- line 1126 ---------------------------------------- . pub fn rebind(&self, value: U) -> Binder<'tcx, U> . where . U: TypeFoldable<'tcx>, . { . if cfg!(debug_assertions) { . let mut validator = ValidateBoundVars::new(self.bound_vars()); . value.visit_with(&mut validator); . } 118,878 ( 0.00%) Binder(value, self.1) . } . . /// Unwraps and returns the value within, but only if it contains . /// no bound vars at all. (In other words, if this binder -- . /// and indeed any enclosing binder -- doesn't bind anything at . /// all.) Otherwise, returns `None`. . /// . /// (One could imagine having a method that just unwraps a single -- line 1142 ---------------------------------------- -- line 1143 ---------------------------------------- . /// binder, but permits late-bound vars bound by enclosing . /// binders, but that would require adjusting the debruijn . /// indices, and given the shallow binding structure we often use, . /// would not be that useful.) . pub fn no_bound_vars(self) -> Option . where . T: TypeFoldable<'tcx>, . { 561,250 ( 0.00%) if self.0.has_escaping_bound_vars() { None } else { Some(self.skip_binder()) } 1,325 ( 0.00%) } . . /// Splits the contents into two things that share the same binder . /// level as the original, returning two distinct binders. . /// . /// `f` should consider bound regions at depth 1 to be free, and . /// anything it produces with bound regions at depth 1 will be . /// bound in the resulting return values. . pub fn split(self, f: F) -> (Binder<'tcx, U>, Binder<'tcx, V>) -- line 1160 ---------------------------------------- -- line 1170 ---------------------------------------- . pub fn transpose(self) -> Option> { . let bound_vars = self.1; . self.0.map(|v| Binder(v, bound_vars)) . } . } . . /// Represents the projection of an associated type. In explicit UFCS . /// form this would be written `>::N`. 6,864 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] 1,088,050 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct ProjectionTy<'tcx> { . /// The parameters of the associated item. 446,852 ( 0.00%) pub substs: SubstsRef<'tcx>, . . /// The `DefId` of the `TraitItem` for the associated type `N`. . /// . /// Note that this is not the `DefId` of the `TraitRef` containing this . /// associated type, which is in `tcx.associated_item(item_def_id).container`. 1,024,029 ( 0.00%) pub item_def_id: DefId, . } . . impl<'tcx> ProjectionTy<'tcx> { 98,735 ( 0.00%) pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId { 28,210 ( 0.00%) tcx.associated_item(self.item_def_id).container.id() 112,840 ( 0.00%) } . . /// Extracts the underlying trait reference and own substs from this projection. . /// For example, if this is a projection of `::Item<'a>`, . /// then this function would return a `T: Iterator` trait reference and `['a]` as the own substs 43,127 ( 0.00%) pub fn trait_ref_and_own_substs( . &self, . tcx: TyCtxt<'tcx>, . ) -> (ty::TraitRef<'tcx>, &'tcx [ty::GenericArg<'tcx>]) { 18,483 ( 0.00%) let def_id = tcx.associated_item(self.item_def_id).container.id(); . let trait_generics = tcx.generics_of(def_id); 30,805 ( 0.00%) ( . ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, trait_generics) }, . &self.substs[trait_generics.count()..], . ) 55,449 ( 0.00%) } . . /// Extracts the underlying trait reference from this projection. . /// For example, if this is a projection of `::Item`, . /// then this function would return a `T: Iterator` trait reference. . /// . /// WARNING: This will drop the substs for generic associated types . /// consider calling [Self::trait_ref_and_own_substs] to get those . /// as well. 126,009 ( 0.00%) pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> { 14,001 ( 0.00%) let def_id = self.trait_def_id(tcx); 14,001 ( 0.00%) ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, tcx.generics_of(def_id)) } 154,011 ( 0.00%) } . 27,144 ( 0.00%) pub fn self_ty(&self) -> Ty<'tcx> { 81,432 ( 0.00%) self.substs.type_at(0) 54,288 ( 0.00%) } . } . 682 ( 0.00%) #[derive(Copy, Clone, Debug, TypeFoldable)] . pub struct GenSig<'tcx> { . pub resume_ty: Ty<'tcx>, . pub yield_ty: Ty<'tcx>, . pub return_ty: Ty<'tcx>, . } . . pub type PolyGenSig<'tcx> = Binder<'tcx, GenSig<'tcx>>; . . /// Signature of a function type, which we have arbitrarily . /// decided to use to refer to the input/output types. . /// . /// - `inputs`: is the list of arguments and their modes. . /// - `output`: is the return type. . /// - `c_variadic`: indicates whether this is a C-variadic function. 164,284 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 105,183 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct FnSig<'tcx> { 12,320 ( 0.00%) pub inputs_and_output: &'tcx List>, 101,671 ( 0.00%) pub c_variadic: bool, 21,280 ( 0.00%) pub unsafety: hir::Unsafety, 86,016 ( 0.00%) pub abi: abi::Abi, . } . . impl<'tcx> FnSig<'tcx> { 71,084 ( 0.00%) pub fn inputs(&self) -> &'tcx [Ty<'tcx>] { 317,201 ( 0.00%) &self.inputs_and_output[..self.inputs_and_output.len() - 1] 142,168 ( 0.00%) } . 38,397 ( 0.00%) pub fn output(&self) -> Ty<'tcx> { 313,755 ( 0.00%) self.inputs_and_output[self.inputs_and_output.len() - 1] 76,794 ( 0.00%) } . . // Creates a minimal `FnSig` to be used when encountering a `TyKind::Error` in a fallible . // method. . fn fake() -> FnSig<'tcx> { . FnSig { . inputs_and_output: List::empty(), . c_variadic: false, . unsafety: hir::Unsafety::Normal, -- line 1267 ---------------------------------------- -- line 1270 ---------------------------------------- . } . } . . pub type PolyFnSig<'tcx> = Binder<'tcx, FnSig<'tcx>>; . . impl<'tcx> PolyFnSig<'tcx> { . #[inline] . pub fn inputs(&self) -> Binder<'tcx, &'tcx [Ty<'tcx>]> { 20,511 ( 0.00%) self.map_bound_ref_unchecked(|fn_sig| fn_sig.inputs()) . } . #[inline] . pub fn input(&self, index: usize) -> ty::Binder<'tcx, Ty<'tcx>> { 21,354 ( 0.00%) self.map_bound_ref(|fn_sig| fn_sig.inputs()[index]) . } . pub fn inputs_and_output(&self) -> ty::Binder<'tcx, &'tcx List>> { . self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output) 1,177 ( 0.00%) } . #[inline] . pub fn output(&self) -> ty::Binder<'tcx, Ty<'tcx>> { 15,100 ( 0.00%) self.map_bound_ref(|fn_sig| fn_sig.output()) . } . pub fn c_variadic(&self) -> bool { 2,354 ( 0.00%) self.skip_binder().c_variadic 1,177 ( 0.00%) } . pub fn unsafety(&self) -> hir::Unsafety { 8,602 ( 0.00%) self.skip_binder().unsafety 4,301 ( 0.00%) } . pub fn abi(&self) -> abi::Abi { 130,176 ( 0.00%) self.skip_binder().abi 32,544 ( 0.00%) } . } . . pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder<'tcx, FnSig<'tcx>>>; . 284 ( 0.00%) #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 2,048 ( 0.00%) #[derive(HashStable)] . pub struct ParamTy { 1,482 ( 0.00%) pub index: u32, . pub name: Symbol, . } . . impl<'tcx> ParamTy { 1,478 ( 0.00%) pub fn new(index: u32, name: Symbol) -> ParamTy { . ParamTy { index, name } 739 ( 0.00%) } . . pub fn for_def(def: &ty::GenericParamDef) -> ParamTy { 750 ( 0.00%) ParamTy::new(def.index, def.name) 375 ( 0.00%) } . . #[inline] . pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { . tcx.mk_ty_param(self.index, self.name) . } . } . . #[derive(Copy, Clone, Hash, TyEncodable, TyDecodable, Eq, PartialEq, Ord, PartialOrd)] 53 ( 0.00%) #[derive(HashStable)] . pub struct ParamConst { 342 ( 0.00%) pub index: u32, 342 ( 0.00%) pub name: Symbol, . } . . impl ParamConst { . pub fn new(index: u32, name: Symbol) -> ParamConst { . ParamConst { index, name } . } . . pub fn for_def(def: &ty::GenericParamDef) -> ParamConst { -- line 1338 ---------------------------------------- -- line 1440 ---------------------------------------- . /// the inference variable is supposed to satisfy the relation . /// *for every value of the placeholder region*. To ensure that doesn't . /// happen, you can use `leak_check`. This is more clearly explained . /// by the [rustc dev guide]. . /// . /// [1]: https://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/ . /// [2]: https://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/ . /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html 13,380,986 ( 0.03%) #[derive(Clone, PartialEq, Eq, Hash, Copy, TyEncodable, TyDecodable, PartialOrd, Ord)] 7,444 ( 0.00%) pub enum RegionKind { . /// Region bound in a type or fn declaration which will be . /// substituted 'early' -- that is, at the same time when type . /// parameters are substituted. . ReEarlyBound(EarlyBoundRegion), . . /// Region bound in a function scope, which will be substituted when the . /// function is called. 586,150 ( 0.00%) ReLateBound(ty::DebruijnIndex, BoundRegion), . . /// When checking a function body, the types of all arguments and so forth . /// that refer to bound region parameters are modified to refer to free . /// region parameters. . ReFree(FreeRegion), . . /// Static data that has an "infinite" lifetime. Top in the region lattice. . ReStatic, -- line 1465 ---------------------------------------- -- line 1478 ---------------------------------------- . /// regions visible from `U`, but not less than regions not visible . /// from `U`. . ReEmpty(ty::UniverseIndex), . . /// Erased region, used by trait selection, in MIR and during codegen. . ReErased, . } . 36,500 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, PartialOrd, Ord)] . pub struct EarlyBoundRegion { 6,796 ( 0.00%) pub def_id: DefId, 30,308 ( 0.00%) pub index: u32, 31,794 ( 0.00%) pub name: Symbol, . } . . /// A **`const`** **v**ariable **ID**. . #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] . pub struct ConstVid<'tcx> { 3,841 ( 0.00%) pub index: u32, 944 ( 0.00%) pub phantom: PhantomData<&'tcx ()>, . } . . rustc_index::newtype_index! { . /// A **region** (lifetime) **v**ariable **ID**. . pub struct RegionVid { . DEBUG_FORMAT = custom, . } . } -- line 1505 ---------------------------------------- -- line 1513 ---------------------------------------- . rustc_index::newtype_index! { . pub struct BoundVar { .. } . } . . #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] . #[derive(HashStable)] . pub struct BoundTy { . pub var: BoundVar, 8,371 ( 0.00%) pub kind: BoundTyKind, . } . 142,526 ( 0.00%) #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] . #[derive(HashStable)] . pub enum BoundTyKind { . Anon, . Param(Symbol), . } . . impl From for BoundTy { . fn from(var: BoundVar) -> Self { . BoundTy { var, kind: BoundTyKind::Anon } . } . } . . /// A `ProjectionPredicate` for an `ExistentialTraitRef`. 592 ( 0.00%) #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] 1,724,654 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct ExistentialProjection<'tcx> { 15,802 ( 0.00%) pub item_def_id: DefId, 1,725,756 ( 0.00%) pub substs: SubstsRef<'tcx>, 431,439 ( 0.00%) pub term: Term<'tcx>, . } . . pub type PolyExistentialProjection<'tcx> = Binder<'tcx, ExistentialProjection<'tcx>>; . . impl<'tcx> ExistentialProjection<'tcx> { . /// Extracts the underlying existential trait reference from this projection. . /// For example, if this is a projection of `exists T. ::Item == X`, . /// then this function would return an `exists T. T: Iterator` existential trait . /// reference. 33,327 ( 0.00%) pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::ExistentialTraitRef<'tcx> { 14,283 ( 0.00%) let def_id = tcx.associated_item(self.item_def_id).container.id(); 9,522 ( 0.00%) let subst_count = tcx.generics_of(def_id).count() - 1; 4,761 ( 0.00%) let substs = tcx.intern_substs(&self.substs[..subst_count]); . ty::ExistentialTraitRef { def_id, substs } 42,849 ( 0.00%) } . . pub fn with_self_ty( . &self, . tcx: TyCtxt<'tcx>, . self_ty: Ty<'tcx>, . ) -> ty::ProjectionPredicate<'tcx> { . // otherwise the escaping regions would be captured by the binders . debug_assert!(!self_ty.has_escaping_bound_vars()); -- line 1566 ---------------------------------------- -- line 1569 ---------------------------------------- . projection_ty: ty::ProjectionTy { . item_def_id: self.item_def_id, . substs: tcx.mk_substs_trait(self_ty, self.substs), . }, . term: self.term, . } . } . 50 ( 0.00%) pub fn erase_self_ty( . tcx: TyCtxt<'tcx>, . projection_predicate: ty::ProjectionPredicate<'tcx>, . ) -> Self { . // Assert there is a Self. 30 ( 0.00%) projection_predicate.projection_ty.substs.type_at(0); . 40 ( 0.00%) Self { 20 ( 0.00%) item_def_id: projection_predicate.projection_ty.item_def_id, . substs: tcx.intern_substs(&projection_predicate.projection_ty.substs[1..]), 10 ( 0.00%) term: projection_predicate.term, . } 70 ( 0.00%) } . } . . impl<'tcx> PolyExistentialProjection<'tcx> { 130 ( 0.00%) pub fn with_self_ty( . &self, . tcx: TyCtxt<'tcx>, . self_ty: Ty<'tcx>, . ) -> ty::PolyProjectionPredicate<'tcx> { 130 ( 0.00%) self.map_bound(|p| p.with_self_ty(tcx, self_ty)) 156 ( 0.00%) } . . pub fn item_def_id(&self) -> DefId { 52 ( 0.00%) self.skip_binder().item_def_id 26 ( 0.00%) } . } . . /// Region utilities . impl RegionKind { . /// Is this region named by the user? . pub fn has_name(&self) -> bool { . match *self { . RegionKind::ReEarlyBound(ebr) => ebr.has_name(), -- line 1611 ---------------------------------------- -- line 1616 ---------------------------------------- . RegionKind::RePlaceholder(placeholder) => placeholder.name.is_named(), . RegionKind::ReEmpty(_) => false, . RegionKind::ReErased => false, . } . } . . #[inline] . pub fn is_late_bound(&self) -> bool { 8,794 ( 0.00%) matches!(*self, ty::ReLateBound(..)) . } . . #[inline] . pub fn is_placeholder(&self) -> bool { 46 ( 0.00%) matches!(*self, ty::RePlaceholder(..)) . } . . #[inline] . pub fn bound_at_or_above_binder(&self, index: ty::DebruijnIndex) -> bool { 246,517 ( 0.00%) match *self { . ty::ReLateBound(debruijn, _) => debruijn >= index, . _ => false, . } . } . . pub fn type_flags(&self) -> TypeFlags { . let mut flags = TypeFlags::empty(); . 376,985 ( 0.00%) match *self { . ty::ReVar(..) => { . flags = flags | TypeFlags::HAS_FREE_REGIONS; . flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS; . flags = flags | TypeFlags::HAS_RE_INFER; . } . ty::RePlaceholder(..) => { . flags = flags | TypeFlags::HAS_FREE_REGIONS; . flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS; -- line 1651 ---------------------------------------- -- line 1669 ---------------------------------------- . ty::ReErased => { . flags = flags | TypeFlags::HAS_RE_ERASED; . } . } . . debug!("type_flags({:?}) = {:?}", self, flags); . . flags 23,856 ( 0.00%) } . . /// Given an early-bound or free region, returns the `DefId` where it was bound. . /// For example, consider the regions in this snippet of code: . /// . /// ``` . /// impl<'a> Foo { . /// ^^ -- early bound, declared on an impl . /// -- line 1685 ---------------------------------------- -- line 1713 ---------------------------------------- . . #[inline(always)] . pub fn flags(&self) -> TypeFlags { . self.flags . } . . #[inline] . pub fn is_unit(&self) -> bool { 7,912 ( 0.00%) match self.kind() { 1,945 ( 0.00%) Tuple(ref tys) => tys.is_empty(), . _ => false, . } . } . . #[inline] . pub fn is_never(&self) -> bool { 80,001 ( 0.00%) matches!(self.kind(), Never) . } . . #[inline] . pub fn is_primitive(&self) -> bool { . self.kind().is_primitive() . } . . #[inline] -- line 1737 ---------------------------------------- -- line 1741 ---------------------------------------- . . #[inline] . pub fn is_ref(&self) -> bool { . matches!(self.kind(), Ref(..)) . } . . #[inline] . pub fn is_ty_var(&self) -> bool { 130,443 ( 0.00%) matches!(self.kind(), Infer(TyVar(_))) . } . . #[inline] . pub fn ty_vid(&self) -> Option { 109,964 ( 0.00%) match self.kind() { 13,602 ( 0.00%) &Infer(TyVar(vid)) => Some(vid), . _ => None, . } . } . . #[inline] . pub fn is_ty_infer(&self) -> bool { 306 ( 0.00%) matches!(self.kind(), Infer(_)) . } . . #[inline] . pub fn is_phantom_data(&self) -> bool { 56 ( 0.00%) if let Adt(def, _) = self.kind() { def.is_phantom_data() } else { false } . } . . #[inline] . pub fn is_bool(&self) -> bool { 558 ( 0.00%) *self.kind() == Bool . } . . /// Returns `true` if this type is a `str`. . #[inline] . pub fn is_str(&self) -> bool { . *self.kind() == Str . } . . #[inline] . pub fn is_param(&self, index: u32) -> bool { 2,880 ( 0.00%) match self.kind() { . ty::Param(ref data) => data.index == index, . _ => false, . } . } . . #[inline] . pub fn is_slice(&self) -> bool { . match self.kind() { . RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => matches!(ty.kind(), Slice(_) | Str), . _ => false, . } . } . . #[inline] . pub fn is_array(&self) -> bool { 410 ( 0.00%) matches!(self.kind(), Array(..)) . } . . #[inline] . pub fn is_simd(&self) -> bool { 17 ( 0.00%) match self.kind() { 7 ( 0.00%) Adt(def, _) => def.repr.simd(), . _ => false, . } . } . 524 ( 0.00%) pub fn sequence_element_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { 1,048 ( 0.00%) match self.kind() { . Array(ty, _) | Slice(ty) => ty, . Str => tcx.mk_mach_uint(ty::UintTy::U8), . _ => bug!("`sequence_element_type` called on non-sequence value: {}", self), . } 524 ( 0.00%) } . 49 ( 0.00%) pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) { 14 ( 0.00%) match self.kind() { . Adt(def, substs) => { 14 ( 0.00%) assert!(def.repr.simd(), "`simd_size_and_type` called on non-SIMD type"); . let variant = def.non_enum_variant(); 28 ( 0.00%) let f0_ty = variant.fields[0].ty(tcx, substs); . 14 ( 0.00%) match f0_ty.kind() { . // If the first field is an array, we assume it is the only field and its . // elements are the SIMD components. . Array(f0_elem_ty, f0_len) => { . // FIXME(repr_simd): https://github.com/rust-lang/rust/pull/78863#discussion_r522784112 . // The way we evaluate the `N` in `[T; N]` here only works since we use . // `simd_size_and_type` post-monomorphization. It will probably start to ICE . // if we use it in generic code. See the `simd-array-trait` ui test. . (f0_len.eval_usize(tcx, ParamEnv::empty()) as u64, f0_elem_ty) . } . // Otherwise, the fields of this Adt are the SIMD components (and we assume they . // all have the same type). 14 ( 0.00%) _ => (variant.fields.len() as u64, f0_ty), . } . } . _ => bug!("`simd_size_and_type` called on invalid type"), . } 63 ( 0.00%) } . . #[inline] . pub fn is_region_ptr(&self) -> bool { 32 ( 0.00%) matches!(self.kind(), Ref(..)) . } . . #[inline] . pub fn is_mutable_ptr(&self) -> bool { 54 ( 0.00%) matches!( 36 ( 0.00%) self.kind(), . RawPtr(TypeAndMut { mutbl: hir::Mutability::Mut, .. }) . | Ref(_, _, hir::Mutability::Mut) . ) . } . . /// Get the mutability of the reference or `None` when not a reference . #[inline] . pub fn ref_mutability(&self) -> Option { -- line 1860 ---------------------------------------- -- line 1861 ---------------------------------------- . match self.kind() { . Ref(_, _, mutability) => Some(*mutability), . _ => None, . } . } . . #[inline] . pub fn is_unsafe_ptr(&self) -> bool { 18,172 ( 0.00%) matches!(self.kind(), RawPtr(_)) . } . . /// Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer). . #[inline] . pub fn is_any_ptr(&self) -> bool { 138 ( 0.00%) self.is_region_ptr() || self.is_unsafe_ptr() || self.is_fn_ptr() . } . . #[inline] . pub fn is_box(&self) -> bool { 120,028 ( 0.00%) match self.kind() { 27,945 ( 0.00%) Adt(def, _) => def.is_box(), . _ => false, . } . } . . /// Panics if called on any type other than `Box`. 2,906 ( 0.00%) pub fn boxed_ty(&self) -> Ty<'tcx> { 2,906 ( 0.00%) match self.kind() { 7,265 ( 0.00%) Adt(def, substs) if def.is_box() => substs.type_at(0), . _ => bug!("`boxed_ty` is called on non-box type {:?}", self), . } 2,906 ( 0.00%) } . . /// A scalar type is one that denotes an atomic datum, with no sub-components. . /// (A RawPtr is scalar because it represents a non-managed pointer, so its . /// contents are abstract to rustc.) . #[inline] . pub fn is_scalar(&self) -> bool { 2,039 ( 0.00%) matches!( 4,690 ( 0.00%) self.kind(), . Bool | Char . | Int(_) . | Float(_) . | Uint(_) . | FnDef(..) . | FnPtr(_) . | RawPtr(_) . | Infer(IntVar(_) | FloatVar(_)) . ) . } . . /// Returns `true` if this type is a floating point type. . #[inline] . pub fn is_floating_point(&self) -> bool { 10,827 ( 0.00%) matches!(self.kind(), Float(_) | Infer(FloatVar(_))) . } . . #[inline] . pub fn is_trait(&self) -> bool { 1,327 ( 0.00%) matches!(self.kind(), Dynamic(..)) . } . . #[inline] . pub fn is_enum(&self) -> bool { 4,770 ( 0.00%) matches!(self.kind(), Adt(adt_def, _) if adt_def.is_enum()) . } . . #[inline] . pub fn is_union(&self) -> bool { 23,034 ( 0.00%) matches!(self.kind(), Adt(adt_def, _) if adt_def.is_union()) . } . . #[inline] . pub fn is_closure(&self) -> bool { 4,498 ( 0.00%) matches!(self.kind(), Closure(..)) . } . . #[inline] . pub fn is_generator(&self) -> bool { 8,939 ( 0.00%) matches!(self.kind(), Generator(..)) . } . . #[inline] . pub fn is_integral(&self) -> bool { 20,385 ( 0.00%) matches!(self.kind(), Infer(IntVar(_)) | Int(_) | Uint(_)) . } . . #[inline] . pub fn is_fresh_ty(&self) -> bool { . matches!(self.kind(), Infer(FreshTy(_))) . } . . #[inline] . pub fn is_fresh(&self) -> bool { 18,232 ( 0.00%) matches!(self.kind(), Infer(FreshTy(_) | FreshIntTy(_) | FreshFloatTy(_))) . } . . #[inline] . pub fn is_char(&self) -> bool { . matches!(self.kind(), Char) . } . . #[inline] . pub fn is_numeric(&self) -> bool { . self.is_integral() || self.is_floating_point() . } . . #[inline] . pub fn is_signed(&self) -> bool { 2,528 ( 0.00%) matches!(self.kind(), Int(_)) . } . . #[inline] . pub fn is_ptr_sized_integral(&self) -> bool { 1,794 ( 0.00%) matches!(self.kind(), Int(ty::IntTy::Isize) | Uint(ty::UintTy::Usize)) . } . . #[inline] . pub fn has_concrete_skeleton(&self) -> bool { . !matches!(self.kind(), Param(_) | Infer(_) | Error(_)) . } . . /// Returns the type and mutability of `*ty`. . /// . /// The parameter `explicit` indicates if this is an *explicit* dereference. . /// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly. 32,451 ( 0.00%) pub fn builtin_deref(&self, explicit: bool) -> Option> { 220,128 ( 0.00%) match self.kind() { 5,180 ( 0.00%) Adt(def, _) if def.is_box() => { 2,400 ( 0.00%) Some(TypeAndMut { ty: self.boxed_ty(), mutbl: hir::Mutability::Not }) . } 109,914 ( 0.00%) Ref(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl: *mutbl }), 16,498 ( 0.00%) RawPtr(mt) if explicit => Some(*mt), . _ => None, . } 64,902 ( 0.00%) } . . /// Returns the type of `ty[i]`. . pub fn builtin_index(&self) -> Option> { 608 ( 0.00%) match self.kind() { . Array(ty, _) | Slice(ty) => Some(ty), . _ => None, . } 53 ( 0.00%) } . 348,288 ( 0.00%) pub fn fn_sig(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { 174,144 ( 0.00%) match self.kind() { 130,506 ( 0.00%) FnDef(def_id, substs) => tcx.fn_sig(*def_id).subst(tcx, substs), 170 ( 0.00%) FnPtr(f) => *f, . Error(_) => { . // ignore errors (#54954) . ty::Binder::dummy(FnSig::fake()) . } . Closure(..) => bug!( . "to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`", . ), . _ => bug!("Ty::fn_sig() called on non-fn type: {:?}", self), . } 391,824 ( 0.00%) } . . #[inline] . pub fn is_fn(&self) -> bool { 28,047 ( 0.00%) matches!(self.kind(), FnDef(..) | FnPtr(_)) . } . . #[inline] . pub fn is_fn_ptr(&self) -> bool { . matches!(self.kind(), FnPtr(_)) . } . . #[inline] . pub fn is_impl_trait(&self) -> bool { 15 ( 0.00%) matches!(self.kind(), Opaque(..)) . } . . #[inline] . pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> { 8,869 ( 0.00%) match self.kind() { . Adt(adt, _) => Some(adt), . _ => None, . } . } . . /// Iterates over tuple fields. . /// Panics when called on anything but a tuple. 1,076 ( 0.00%) pub fn tuple_fields(&self) -> impl DoubleEndedIterator> { 7,010 ( 0.00%) match self.kind() { 5,935 ( 0.00%) Tuple(substs) => substs.iter().map(|field| field.expect_ty()), . _ => bug!("tuple_fields called on non-tuple"), . } 2,152 ( 0.00%) } . . /// Get the `i`-th element of a tuple. . /// Panics when called on anything but a tuple. 186 ( 0.00%) pub fn tuple_element_ty(&self, i: usize) -> Option> { 372 ( 0.00%) match self.kind() { 372 ( 0.00%) Tuple(substs) => substs.iter().nth(i).map(|field| field.expect_ty()), . _ => bug!("tuple_fields called on non-tuple"), . } 372 ( 0.00%) } . . /// If the type contains variants, returns the valid range of variant indices. . // . // FIXME: This requires the optimized MIR in the case of generators. . #[inline] . pub fn variant_range(&self, tcx: TyCtxt<'tcx>) -> Option> { . match self.kind() { . TyKind::Adt(adt, _) => Some(adt.variant_range()), -- line 2068 ---------------------------------------- -- line 2073 ---------------------------------------- . } . } . . /// If the type contains variants, returns the variant for `variant_index`. . /// Panics if `variant_index` is out of range. . // . // FIXME: This requires the optimized MIR in the case of generators. . #[inline] 34,120 ( 0.00%) pub fn discriminant_for_variant( . &self, . tcx: TyCtxt<'tcx>, . variant_index: VariantIdx, . ) -> Option> { 27,844 ( 0.00%) match self.kind() { 7,700 ( 0.00%) TyKind::Adt(adt, _) if adt.variants.is_empty() => { . // This can actually happen during CTFE, see . // https://github.com/rust-lang/rust/issues/89765. . None . } 3,850 ( 0.00%) TyKind::Adt(adt, _) if adt.is_enum() => { . Some(adt.discriminant_for_variant(tcx, variant_index)) . } . TyKind::Generator(def_id, substs, _) => { 32 ( 0.00%) Some(substs.as_generator().discriminant_for_variant(*def_id, tcx, variant_index)) . } . _ => None, . } 27,296 ( 0.00%) } . . /// Returns the type of the discriminant of this type. 36,590 ( 0.00%) pub fn discriminant_ty(&'tcx self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { 18,295 ( 0.00%) match self.kind() { 28,906 ( 0.00%) ty::Adt(adt, _) if adt.is_enum() => adt.repr.discr_type().to_ty(tcx), . ty::Generator(_, substs, _) => substs.as_generator().discr_ty(tcx), . . ty::Param(_) | ty::Projection(_) | ty::Opaque(..) | ty::Infer(ty::TyVar(_)) => { . let assoc_items = tcx.associated_item_def_ids( . tcx.require_lang_item(hir::LangItem::DiscriminantKind, None), . ); . tcx.mk_projection(assoc_items[0], tcx.intern_substs(&[self.into()])) . } -- line 2113 ---------------------------------------- -- line 2127 ---------------------------------------- . | ty::FnDef(..) . | ty::FnPtr(..) . | ty::Dynamic(..) . | ty::Closure(..) . | ty::GeneratorWitness(..) . | ty::Never . | ty::Tuple(_) . | ty::Error(_) 41 ( 0.00%) | ty::Infer(IntVar(_) | FloatVar(_)) => tcx.types.u8, . . ty::Bound(..) . | ty::Placeholder(_) . | ty::Infer(FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { . bug!("`discriminant_ty` applied to unexpected type: {:?}", self) . } . } 29,272 ( 0.00%) } . . /// Returns the type of metadata for (potentially fat) pointers to this type. 360 ( 0.00%) pub fn ptr_metadata_ty( . &'tcx self, . tcx: TyCtxt<'tcx>, . normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>, . ) -> Ty<'tcx> { 360 ( 0.00%) let tail = tcx.struct_tail_with_normalize(self, normalize); 200 ( 0.00%) match tail.kind() { . // Sized types . ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) . | ty::Uint(_) . | ty::Int(_) . | ty::Bool . | ty::Float(_) . | ty::FnDef(..) . | ty::FnPtr(_) -- line 2160 ---------------------------------------- -- line 2170 ---------------------------------------- . | ty::Foreign(..) . // If returned by `struct_tail_without_normalization` this is a unit struct . // without any fields, or not a struct, and therefore is Sized. . | ty::Adt(..) . // If returned by `struct_tail_without_normalization` this is the empty tuple, . // a.k.a. unit type, which is Sized . | ty::Tuple(..) => tcx.types.unit, . 80 ( 0.00%) ty::Str | ty::Slice(_) => tcx.types.usize, . ty::Dynamic(..) => { . let dyn_metadata = tcx.lang_items().dyn_metadata().unwrap(); . tcx.type_of(dyn_metadata).subst(tcx, &[tail.into()]) . }, . . ty::Projection(_) . | ty::Param(_) . | ty::Opaque(..) . | ty::Infer(ty::TyVar(_)) . | ty::Bound(..) . | ty::Placeholder(..) . | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { . bug!("`ptr_metadata_ty` applied to unexpected type: {:?}", tail) . } . } 320 ( 0.00%) } . . /// When we create a closure, we record its kind (i.e., what trait . /// it implements) into its `ClosureSubsts` using a type . /// parameter. This is kind of a phantom type, except that the . /// most convenient thing for us to are the integral types. This . /// function converts such a special type into the closure . /// kind. To go the other way, use . /// `tcx.closure_kind_ty(closure_kind)`. . /// . /// Note that during type checking, we use an inference variable . /// to represent the closure kind, because it has not yet been . /// inferred. Once upvar inference (in `rustc_typeck/src/check/upvar.rs`) . /// is complete, that type variable will be unified. 3,450 ( 0.00%) pub fn to_opt_closure_kind(&self) -> Option { 6,900 ( 0.00%) match self.kind() { 6,900 ( 0.00%) Int(int_ty) => match int_ty { . ty::IntTy::I8 => Some(ty::ClosureKind::Fn), . ty::IntTy::I16 => Some(ty::ClosureKind::FnMut), . ty::IntTy::I32 => Some(ty::ClosureKind::FnOnce), . _ => bug!("cannot convert type `{:?}` to a closure kind", self), . }, . . // "Bound" types appear in canonical queries when the . // closure type is not yet known . Bound(..) | Infer(_) => None, . . Error(_) => Some(ty::ClosureKind::Fn), . . _ => bug!("cannot convert type `{:?}` to a closure kind", self), . } 3,450 ( 0.00%) } . . /// Fast path helper for testing if a type is `Sized`. . /// . /// Returning true means the type is known to be sized. Returning . /// `false` means nothing -- could be sized, might not be. . /// . /// Note that we could never rely on the fact that a type such as `[_]` is . /// trivially `!Sized` because we could be in a type environment with a . /// bound such as `[_]: Copy`. A function with such a bound obviously never . /// can be called, but that doesn't mean it shouldn't typecheck. This is why . /// this method doesn't return `Option`. 580,104 ( 0.00%) pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool { 386,736 ( 0.00%) match self.kind() { . ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) . | ty::Uint(_) . | ty::Int(_) . | ty::Bool . | ty::Float(_) . | ty::FnDef(..) . | ty::FnPtr(_) . | ty::RawPtr(..) -- line 2246 ---------------------------------------- -- line 2250 ---------------------------------------- . | ty::GeneratorWitness(..) . | ty::Array(..) . | ty::Closure(..) . | ty::Never . | ty::Error(_) => true, . . ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => false, . 6,724 ( 0.00%) ty::Tuple(tys) => tys.iter().all(|ty| ty.expect_ty().is_trivially_sized(tcx)), . 69,645 ( 0.00%) ty::Adt(def, _substs) => def.sized_constraint(tcx).is_empty(), . . ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false, . . ty::Infer(ty::TyVar(_)) => false, . . ty::Bound(..) . | ty::Placeholder(..) . | ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { . bug!("`is_trivially_sized` applied to unexpected type: {:?}", self) . } . } 580,104 ( 0.00%) } . } . . /// Extra information about why we ended up with a particular variance. . /// This is only used to add more information to error messages, and . /// has no effect on soundness. While choosing the 'wrong' `VarianceDiagInfo` . /// may lead to confusing notes in error messages, it will never cause . /// a miscompilation or unsoundness. . /// . /// When in doubt, use `VarianceDiagInfo::default()` 540 ( 0.00%) #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] . pub enum VarianceDiagInfo<'tcx> { . /// No additional information - this is the default. . /// We will not add any additional information to error messages. . #[default] . None, . /// We switched our variance because a generic argument occurs inside . /// the invariant generic argument of another type. . Invariant { -- line 2290 ---------------------------------------- -- line 2295 ---------------------------------------- . /// (e.g. `0` for `*mut T`, `1` for `MyStruct<'CovariantParam, 'InvariantParam>`) . param_index: u32, . }, . } . . impl<'tcx> VarianceDiagInfo<'tcx> { . /// Mirrors `Variance::xform` - used to 'combine' the existing . /// and new `VarianceDiagInfo`s when our variance changes. 119,486 ( 0.00%) pub fn xform(self, other: VarianceDiagInfo<'tcx>) -> VarianceDiagInfo<'tcx> { . // For now, just use the first `VarianceDiagInfo::Invariant` that we see 179,229 ( 0.00%) match self { . VarianceDiagInfo::None => other, . VarianceDiagInfo::Invariant { .. } => self, . } 59,743 ( 0.00%) } . } 76,929,042 ( 0.20%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/subst.rs -------------------------------------------------------------------------------- Ir -- line 22 ---------------------------------------- . . /// An entity in the Rust type system, which can be one of . /// several kinds (types, lifetimes, and consts). . /// To reduce memory usage, a `GenericArg` is an interned pointer, . /// with the lowest 2 bits being reserved for a tag to . /// indicate the type (`Ty`, `Region`, or `Const`) it points to. . #[derive(Copy, Clone, PartialEq, Eq, Hash)] . pub struct GenericArg<'tcx> { 2,099,633 ( 0.01%) ptr: NonZeroUsize, 5,437,210 ( 0.01%) marker: PhantomData<(Ty<'tcx>, ty::Region<'tcx>, &'tcx ty::Const<'tcx>)>, . } . . const TAG_MASK: usize = 0b11; . const TYPE_TAG: usize = 0b00; . const REGION_TAG: usize = 0b01; . const CONST_TAG: usize = 0b10; . 175,576 ( 0.00%) #[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord, HashStable)] . pub enum GenericArgKind<'tcx> { . Lifetime(ty::Region<'tcx>), . Type(Ty<'tcx>), . Const(&'tcx ty::Const<'tcx>), . } . . impl<'tcx> GenericArgKind<'tcx> { 41,099 ( 0.00%) fn pack(self) -> GenericArg<'tcx> { 41,099 ( 0.00%) let (tag, ptr) = match self { . GenericArgKind::Lifetime(lt) => { . // Ensure we can use the tag bits. . assert_eq!(mem::align_of_val(lt) & TAG_MASK, 0); . (REGION_TAG, lt as *const _ as usize) . } . GenericArgKind::Type(ty) => { . // Ensure we can use the tag bits. . assert_eq!(mem::align_of_val(ty) & TAG_MASK, 0); -- line 56 ---------------------------------------- -- line 58 ---------------------------------------- . } . GenericArgKind::Const(ct) => { . // Ensure we can use the tag bits. . assert_eq!(mem::align_of_val(ct) & TAG_MASK, 0); . (CONST_TAG, ct as *const _ as usize) . } . }; . 456,786 ( 0.00%) GenericArg { ptr: unsafe { NonZeroUsize::new_unchecked(ptr | tag) }, marker: PhantomData } 41,099 ( 0.00%) } . } . . impl<'tcx> fmt::Debug for GenericArg<'tcx> { . fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { . match self.unpack() { . GenericArgKind::Lifetime(lt) => lt.fmt(f), . GenericArgKind::Type(ty) => ty.fmt(f), . GenericArgKind::Const(ct) => ct.fmt(f), . } . } . } . . impl<'tcx> Ord for GenericArg<'tcx> { 822 ( 0.00%) fn cmp(&self, other: &GenericArg<'_>) -> Ordering { 548 ( 0.00%) self.unpack().cmp(&other.unpack()) . } . } . . impl<'tcx> PartialOrd for GenericArg<'tcx> { . fn partial_cmp(&self, other: &GenericArg<'_>) -> Option { . Some(self.cmp(&other)) . } . } . . impl<'tcx> From> for GenericArg<'tcx> { 309,426 ( 0.00%) fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> { . GenericArgKind::Lifetime(r).pack() 309,426 ( 0.00%) } . } . . impl<'tcx> From> for GenericArg<'tcx> { 4,870,401 ( 0.01%) fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> { . GenericArgKind::Type(ty).pack() 4,870,401 ( 0.01%) } . } . . impl<'tcx> From<&'tcx ty::Const<'tcx>> for GenericArg<'tcx> { 557 ( 0.00%) fn from(c: &'tcx ty::Const<'tcx>) -> GenericArg<'tcx> { . GenericArgKind::Const(c).pack() 557 ( 0.00%) } . } . . impl<'tcx> GenericArg<'tcx> { . #[inline] . pub fn unpack(self) -> GenericArgKind<'tcx> { . let ptr = self.ptr.get(); . unsafe { 33,527,224 ( 0.09%) match ptr & TAG_MASK { 262,237 ( 0.00%) REGION_TAG => GenericArgKind::Lifetime(&*((ptr & !TAG_MASK) as *const _)), 9,176,039 ( 0.02%) TYPE_TAG => GenericArgKind::Type(&*((ptr & !TAG_MASK) as *const _)), 3,183 ( 0.00%) CONST_TAG => GenericArgKind::Const(&*((ptr & !TAG_MASK) as *const _)), . _ => intrinsics::unreachable(), . } . } . } . . /// Unpack the `GenericArg` as a type when it is known certainly to be a type. . /// This is true in cases where `Substs` is used in places where the kinds are known . /// to be limited (e.g. in tuples, where the only parameters are type parameters). . pub fn expect_ty(self) -> Ty<'tcx> { . match self.unpack() { . GenericArgKind::Type(ty) => ty, . _ => bug!("expected a type, but found another kind"), . } 115,488 ( 0.00%) } . . /// Unpack the `GenericArg` as a const when it is known certainly to be a const. . pub fn expect_const(self) -> &'tcx ty::Const<'tcx> { . match self.unpack() { . GenericArgKind::Const(c) => c, . _ => bug!("expected a const, but found another kind"), . } . } -- line 140 ---------------------------------------- -- line 155 ---------------------------------------- . impl<'tcx> TypeFoldable<'tcx> for GenericArg<'tcx> { . fn try_super_fold_with>( . self, . folder: &mut F, . ) -> Result { . match self.unpack() { . GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into), . GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into), 21 ( 0.00%) GenericArgKind::Const(ct) => ct.try_fold_with(folder).map(Into::into), . } . } . . fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { . match self.unpack() { . GenericArgKind::Lifetime(lt) => lt.visit_with(visitor), . GenericArgKind::Type(ty) => ty.visit_with(visitor), . GenericArgKind::Const(ct) => ct.visit_with(visitor), . } . } . } . . impl<'tcx, E: TyEncoder<'tcx>> Encodable for GenericArg<'tcx> { . fn encode(&self, e: &mut E) -> Result<(), E::Error> { 22,875 ( 0.00%) self.unpack().encode(e) . } . } . . impl<'tcx, D: TyDecoder<'tcx>> Decodable for GenericArg<'tcx> { 205,495 ( 0.00%) fn decode(d: &mut D) -> GenericArg<'tcx> { 205,495 ( 0.00%) GenericArgKind::decode(d).pack() . } . } . . /// A substitution mapping generic parameters to new values. . pub type InternalSubsts<'tcx> = List>; . . pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>; . . impl<'a, 'tcx> InternalSubsts<'tcx> { . /// Interpret these substitutions as the substitutions of a closure type. . /// Closure substitutions have a particular structure controlled by the . /// compiler that encodes information like the signature and closure kind; . /// see `ty::ClosureSubsts` struct for more comments. 5,671 ( 0.00%) pub fn as_closure(&'a self) -> ClosureSubsts<'a> { . ClosureSubsts { substs: self } 5,671 ( 0.00%) } . . /// Interpret these substitutions as the substitutions of a generator type. . /// Generator substitutions have a particular structure controlled by the . /// compiler that encodes information like the signature and generator kind; . /// see `ty::GeneratorSubsts` struct for more comments. . pub fn as_generator(&'tcx self) -> GeneratorSubsts<'tcx> { . GeneratorSubsts { substs: self } . } -- line 208 ---------------------------------------- -- line 211 ---------------------------------------- . /// Inline const substitutions have a particular structure controlled by the . /// compiler that encodes information like the inferred type; . /// see `ty::InlineConstSubsts` struct for more comments. . pub fn as_inline_const(&'tcx self) -> InlineConstSubsts<'tcx> { . InlineConstSubsts { substs: self } . } . . /// Creates an `InternalSubsts` that maps each generic parameter to itself. 61,080 ( 0.00%) pub fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx> { 18,940 ( 0.00%) Self::for_item(tcx, def_id, |param, _| tcx.mk_param_from_def(param)) 54,972 ( 0.00%) } . . /// Creates an `InternalSubsts` for generic parameter definitions, . /// by calling closures to obtain each kind. . /// The closures get to observe the `InternalSubsts` as they're . /// being built, which can be used to correctly . /// substitute defaults of generic parameters. 383,879 ( 0.00%) pub fn for_item(tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx> . where . F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, . { . let defs = tcx.generics_of(def_id); . let count = defs.count(); . let mut substs = SmallVec::with_capacity(count); 148,620 ( 0.00%) Self::fill_item(&mut substs, tcx, defs, &mut mk_kind); 81,432 ( 0.00%) tcx.intern_substs(&substs) 386,865 ( 0.00%) } . . pub fn extend_to(&self, tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx> . where . F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, . { . Self::for_item(tcx, def_id, |param, substs| { . self.get(param.index as usize).cloned().unwrap_or_else(|| mk_kind(param, substs)) . }) . } . 600,065 ( 0.00%) pub fn fill_item( . substs: &mut SmallVec<[GenericArg<'tcx>; 8]>, . tcx: TyCtxt<'tcx>, . defs: &ty::Generics, . mk_kind: &mut F, . ) where . F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, . { 251,288 ( 0.00%) if let Some(def_id) = defs.parent { . let parent_defs = tcx.generics_of(def_id); 50,382 ( 0.00%) Self::fill_item(substs, tcx, parent_defs, mk_kind); . } . Self::fill_single(substs, defs, mk_kind) 474,048 ( 0.00%) } . 1,232 ( 0.00%) pub fn fill_single( . substs: &mut SmallVec<[GenericArg<'tcx>; 8]>, . defs: &ty::Generics, . mk_kind: &mut F, . ) where . F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, . { . substs.reserve(defs.params.len()); . for param in &defs.params { 61 ( 0.00%) let kind = mk_kind(param, substs); 329,862 ( 0.00%) assert_eq!(param.index as usize, substs.len()); . substs.push(kind); . } 1,232 ( 0.00%) } . . #[inline] . pub fn types(&'a self) -> impl DoubleEndedIterator> + 'a { . self.iter() . .filter_map(|k| if let GenericArgKind::Type(ty) = k.unpack() { Some(ty) } else { None }) . } . . #[inline] -- line 284 ---------------------------------------- -- line 301 ---------------------------------------- . ) -> impl DoubleEndedIterator> + 'a { . self.iter().filter_map(|k| match k.unpack() { . GenericArgKind::Lifetime(_) => None, . generic => Some(generic), . }) . } . . #[inline] 225 ( 0.00%) pub fn type_at(&self, i: usize) -> Ty<'tcx> { 775,419 ( 0.00%) if let GenericArgKind::Type(ty) = self[i].unpack() { . ty . } else { . bug!("expected type for param #{} in {:?}", i, self); . } 150 ( 0.00%) } . . #[inline] . pub fn region_at(&self, i: usize) -> ty::Region<'tcx> { . if let GenericArgKind::Lifetime(lt) = self[i].unpack() { . lt . } else { . bug!("expected region for param #{} in {:?}", i, self); . } -- line 323 ---------------------------------------- -- line 350 ---------------------------------------- . /// impl X for U { fn f() {} } . /// ``` . /// . /// * If `self` is `[Self, S, T]`: the identity substs of `f` in the trait. . /// * If `source_ancestor` is the def_id of the trait. . /// * If `target_substs` is `[U]`, the substs for the impl. . /// * Then we will return `[U, T]`, the subst for `f` in the impl that . /// are needed for it to match the trait. 42,931 ( 0.00%) pub fn rebase_onto( . &self, . tcx: TyCtxt<'tcx>, . source_ancestor: DefId, . target_substs: SubstsRef<'tcx>, . ) -> SubstsRef<'tcx> { . let defs = tcx.generics_of(source_ancestor); 12,266 ( 0.00%) tcx.mk_substs(target_substs.iter().chain(self.iter().skip(defs.params.len()))) 49,064 ( 0.00%) } . . pub fn truncate_to(&self, tcx: TyCtxt<'tcx>, generics: &ty::Generics) -> SubstsRef<'tcx> { . tcx.mk_substs(self.iter().take(generics.count())) . } . } . . impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> { 485,261 ( 0.00%) fn try_super_fold_with>( . self, . folder: &mut F, . ) -> Result { . // This code is hot enough that it's worth specializing for the most . // common length lists, to avoid the overhead of `SmallVec` creation. . // The match arms are in order of frequency. The 1, 2, and 0 cases are . // typically hit in 90--99.99% of cases. When folding doesn't change . // the substs, it's faster to reuse the existing substs rather than . // calling `intern_substs`. 18,545,142 ( 0.05%) match self.len() { . 1 => { 2,238,764 ( 0.01%) let param0 = self[0].try_fold_with(folder)?; 6,866,953 ( 0.02%) if param0 == self[0] { Ok(self) } else { Ok(folder.tcx().intern_substs(&[param0])) } . } . 2 => { 1,671,104 ( 0.00%) let param0 = self[0].try_fold_with(folder)?; 4,514,899 ( 0.01%) let param1 = self[1].try_fold_with(folder)?; 6,584,456 ( 0.02%) if param0 == self[0] && param1 == self[1] { . Ok(self) . } else { 1,853,140 ( 0.00%) Ok(folder.tcx().intern_substs(&[param0, param1])) . } . } . 0 => Ok(self), . _ => { . let params: SmallVec<[_; 8]> = 177,630 ( 0.00%) self.iter().map(|k| k.try_fold_with(folder)).collect::>()?; 10,654 ( 0.00%) if params[..] == self[..] { . Ok(self) . } else { 29,381 ( 0.00%) Ok(folder.tcx().intern_substs(¶ms)) . } . } . } 649,912 ( 0.00%) } . . fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { 1,064,778 ( 0.00%) self.iter().try_for_each(|t| t.visit_with(visitor)) . } . } . . /////////////////////////////////////////////////////////////////////////// . // Public trait `Subst` . // . // Just call `foo.subst(tcx, substs)` to perform a substitution across . // `foo`. Or use `foo.subst_spanned(tcx, substs, Some(span))` when -- line 420 ---------------------------------------- -- line 435 ---------------------------------------- . . impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { . fn subst_spanned( . self, . tcx: TyCtxt<'tcx>, . substs: &[GenericArg<'tcx>], . span: Option, . ) -> T { 3,836,653 ( 0.01%) let mut folder = SubstFolder { tcx, substs, span, binders_passed: 0 }; . self.fold_with(&mut folder) . } . } . . /////////////////////////////////////////////////////////////////////////// . // The actual substitution engine itself is a type folder. . . struct SubstFolder<'a, 'tcx> { -- line 451 ---------------------------------------- -- line 456 ---------------------------------------- . span: Option, . . /// Number of region binders we have passed through while doing the substitution . binders_passed: u32, . } . . impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { . fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { 609,793 ( 0.00%) self.tcx . } . . fn fold_binder>( . &mut self, . t: ty::Binder<'tcx, T>, . ) -> ty::Binder<'tcx, T> { 560,536 ( 0.00%) self.binders_passed += 1; 125,636 ( 0.00%) let t = t.super_fold_with(self); 560,536 ( 0.00%) self.binders_passed -= 1; . t . } . 733,782 ( 0.00%) fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { . // Note: This routine only handles regions that are bound on . // type declarations and other outer declarations, not those . // bound in *fn types*. Region substitution of the bound . // regions that appear in a function signature is done using . // the specialized routine `ty::replace_late_regions()`. 244,594 ( 0.00%) match *r { 114,422 ( 0.00%) ty::ReEarlyBound(data) => { 114,422 ( 0.00%) let rk = self.substs.get(data.index as usize).map(|k| k.unpack()); . match rk { 57,211 ( 0.00%) Some(GenericArgKind::Lifetime(lt)) => self.shift_region_through_binders(lt), . _ => { . let span = self.span.unwrap_or(DUMMY_SP); . let msg = format!( . "Region parameter out of range \ . when substituting in region {} (index={})", . data.name, data.index . ); . span_bug!(span, "{}", msg); . } . } . } . _ => r, . } 856,079 ( 0.00%) } . 3,457,065 ( 0.01%) fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { 1,152,355 ( 0.00%) if !t.needs_subst() { . return t; . } . 1,570,348 ( 0.00%) match *t.kind() { 2,321,880 ( 0.01%) ty::Param(p) => self.ty_for_param(p, t), 1,924,788 ( 0.00%) _ => t.super_fold_with(self), . } 4,157,785 ( 0.01%) } . 270,396 ( 0.00%) fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { 82,426 ( 0.00%) if let ty::ConstKind::Param(p) = c.val { . self.const_for_param(p, c) . } else { 338,346 ( 0.00%) c.super_fold_with(self) . } 8,272 ( 0.00%) } . . #[inline] . fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> { . c.super_fold_with(self) . } . } . . impl<'a, 'tcx> SubstFolder<'a, 'tcx> { . fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> { . // Look up the type in the substitutions. It really should be in there. 928,752 ( 0.00%) let opt_ty = self.substs.get(p.index as usize).map(|k| k.unpack()); . let ty = match opt_ty { . Some(GenericArgKind::Type(ty)) => ty, . Some(kind) => { . let span = self.span.unwrap_or(DUMMY_SP); . span_bug!( . span, . "expected type for `{:?}` ({:?}/{}) but found {:?} \ . when substituting, substs={:?}", -- line 539 ---------------------------------------- -- line 562 ---------------------------------------- . } . . fn const_for_param( . &self, . p: ParamConst, . source_ct: &'tcx ty::Const<'tcx>, . ) -> &'tcx ty::Const<'tcx> { . // Look up the const in the substitutions. It really should be in there. 2,068 ( 0.00%) let opt_ct = self.substs.get(p.index as usize).map(|k| k.unpack()); . let ct = match opt_ct { . Some(GenericArgKind::Const(ct)) => ct, . Some(kind) => { . let span = self.span.unwrap_or(DUMMY_SP); . span_bug!( . span, . "expected const for `{:?}` ({:?}/{}) but found {:?} \ . when substituting substs={:?}", -- line 578 ---------------------------------------- -- line 645 ---------------------------------------- . fn shift_vars_through_binders>(&self, val: T) -> T { . debug!( . "shift_vars(val={:?}, binders_passed={:?}, has_escaping_bound_vars={:?})", . val, . self.binders_passed, . val.has_escaping_bound_vars() . ); . 1,606,982 ( 0.00%) if self.binders_passed == 0 || !val.has_escaping_bound_vars() { . return val; . } . . let result = ty::fold::shift_vars(self.tcx(), val, self.binders_passed); . debug!("shift_vars: shifted result = {:?}", result); . . result . } . . fn shift_region_through_binders(&self, region: ty::Region<'tcx>) -> ty::Region<'tcx> { 139,210 ( 0.00%) if self.binders_passed == 0 || !region.has_escaping_bound_vars() { . return region; . } . ty::fold::shift_region(self.tcx, region, self.binders_passed) . } . } . . /// Stores the user-given substs to reach some fully qualified path . /// (e.g., `::Item` or `::Item`). . #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] 14,951 ( 0.00%) #[derive(HashStable, TypeFoldable, Lift)] . pub struct UserSubsts<'tcx> { . /// The substitutions for the item as given by the user. . pub substs: SubstsRef<'tcx>, . . /// The self type, in the case of a `::Item` path (when applied . /// to an inherent impl). See `UserSelfTy` below. 5,494 ( 0.00%) pub user_self_ty: Option>, . } . . /// Specifies the user-given self type. In the case of a path that . /// refers to a member in an inherent impl, this self type is . /// sometimes needed to constrain the type parameters on the impl. For . /// example, in this code: . /// . /// ``` -- line 689 ---------------------------------------- -- line 696 ---------------------------------------- . /// self type `Foo`. Then we can instantiate the parameters of . /// the impl (with the substs from `UserSubsts`) and apply those to . /// the self type, giving `Foo`. Finally, we unify that with . /// the self type here, which contains `?A` to be `&'static u32` . #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] . #[derive(HashStable, TypeFoldable, Lift)] . pub struct UserSelfTy<'tcx> { . pub impl_def_id: DefId, 2,370 ( 0.00%) pub self_ty: Ty<'tcx>, . } 16,654,856 ( 0.04%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/fold.rs -------------------------------------------------------------------------------- Ir -- line 46 ---------------------------------------- . /// . /// To implement this conveniently, use the derive macro located in `rustc_macros`. . pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { . /// Consumers may find this more convenient to use with infallible folders than . /// [`try_super_fold_with`][`TypeFoldable::try_super_fold_with`], to which the . /// provided default definition delegates. Implementors **should not** override . /// this provided default definition, to ensure that the two methods are coherent . /// (provide a definition of `try_super_fold_with` instead). 37,840,758 ( 0.10%) fn super_fold_with>(self, folder: &mut F) -> Self { 6,010,225 ( 0.02%) self.try_super_fold_with(folder).into_ok() 38,649,330 ( 0.10%) } . /// Consumers may find this more convenient to use with infallible folders than . /// [`try_fold_with`][`TypeFoldable::try_fold_with`], to which the provided . /// default definition delegates. Implementors **should not** override this . /// provided default definition, to ensure that the two methods are coherent . /// (provide a definition of `try_fold_with` instead). 779,942 ( 0.00%) fn fold_with>(self, folder: &mut F) -> Self { 254,160 ( 0.00%) self.try_fold_with(folder).into_ok() 717,408 ( 0.00%) } . . fn try_super_fold_with>( . self, . folder: &mut F, . ) -> Result; . 43,532,593 ( 0.11%) fn try_fold_with>(self, folder: &mut F) -> Result { 9,595,966 ( 0.02%) self.try_super_fold_with(folder) 46,633,055 ( 0.12%) } . . fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow; 2,068,463 ( 0.01%) fn visit_with>(&self, visitor: &mut V) -> ControlFlow { 1,418,445 ( 0.00%) self.super_visit_with(visitor) 1,318,676 ( 0.00%) } . . /// Returns `true` if `self` has any late-bound regions that are either . /// bound by `binder` or bound by some binder outside of `binder`. . /// If `binder` is `ty::INNERMOST`, this indicates whether . /// there are any late-bound regions that appear free. . fn has_vars_bound_at_or_above(&self, binder: ty::DebruijnIndex) -> bool { 796,512 ( 0.00%) self.visit_with(&mut HasEscapingVarsVisitor { outer_index: binder }).is_break() . } . . /// Returns `true` if this `self` has any regions that escape `binder` (and . /// hence are not bound by it). . fn has_vars_bound_above(&self, binder: ty::DebruijnIndex) -> bool { 279 ( 0.00%) self.has_vars_bound_at_or_above(binder.shifted_in(1)) . } . 2,000,535 ( 0.01%) fn has_escaping_bound_vars(&self) -> bool { 323,221 ( 0.00%) self.has_vars_bound_at_or_above(ty::INNERMOST) 2,008,789 ( 0.01%) } . 247,774 ( 0.00%) #[instrument(level = "trace")] . fn has_type_flags(&self, flags: TypeFlags) -> bool { 417,107 ( 0.00%) self.visit_with(&mut HasTypeFlagsVisitor { flags }).break_value() == Some(FoundFlags) . } . fn has_projections(&self) -> bool { 16,394 ( 0.00%) self.has_type_flags(TypeFlags::HAS_PROJECTION) . } . fn has_opaque_types(&self) -> bool { . self.has_type_flags(TypeFlags::HAS_TY_OPAQUE) . } 66,728 ( 0.00%) fn references_error(&self) -> bool { . self.has_type_flags(TypeFlags::HAS_ERROR) 66,728 ( 0.00%) } . fn has_param_types_or_consts(&self) -> bool { 6,429 ( 0.00%) self.has_type_flags(TypeFlags::HAS_TY_PARAM | TypeFlags::HAS_CT_PARAM) . } . fn has_infer_regions(&self) -> bool { . self.has_type_flags(TypeFlags::HAS_RE_INFER) . } . fn has_infer_types(&self) -> bool { . self.has_type_flags(TypeFlags::HAS_TY_INFER) . } . fn has_infer_types_or_consts(&self) -> bool { 418,668 ( 0.00%) self.has_type_flags(TypeFlags::HAS_TY_INFER | TypeFlags::HAS_CT_INFER) . } 213,529 ( 0.00%) fn needs_infer(&self) -> bool { 277,376 ( 0.00%) self.has_type_flags(TypeFlags::NEEDS_INFER) 217,214 ( 0.00%) } . fn has_placeholders(&self) -> bool { . self.has_type_flags( . TypeFlags::HAS_RE_PLACEHOLDER . | TypeFlags::HAS_TY_PLACEHOLDER . | TypeFlags::HAS_CT_PLACEHOLDER, . ) . } . fn needs_subst(&self) -> bool { 30 ( 0.00%) self.has_type_flags(TypeFlags::NEEDS_SUBST) . } . /// "Free" regions in this context means that it has any region . /// that is not (a) erased or (b) late-bound. . fn has_free_regions(&self) -> bool { . self.has_type_flags(TypeFlags::HAS_FREE_REGIONS) . } . . fn has_erased_regions(&self) -> bool { -- line 142 ---------------------------------------- -- line 146 ---------------------------------------- . /// True if there are any un-erased free regions. . fn has_erasable_regions(&self) -> bool { . self.has_type_flags(TypeFlags::HAS_FREE_REGIONS) . } . . /// Indicates whether this value references only 'global' . /// generic parameters that are the same regardless of what fn we are . /// in. This is used for caching. 15 ( 0.00%) fn is_global(&self) -> bool { 143,735 ( 0.00%) !self.has_type_flags(TypeFlags::HAS_FREE_LOCAL_NAMES) 18 ( 0.00%) } . . /// True if there are any late-bound regions . fn has_late_bound_regions(&self) -> bool { . self.has_type_flags(TypeFlags::HAS_RE_LATE_BOUND) . } . . /// Indicates whether this value still has parameters/placeholders/inference variables . /// which could be replaced later, in a way that would change the results of `impl` . /// specialization. 25 ( 0.00%) fn still_further_specializable(&self) -> bool { . self.has_type_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE) 30 ( 0.00%) } . } . . impl<'tcx> TypeFoldable<'tcx> for hir::Constness { . fn try_super_fold_with>(self, _: &mut F) -> Result { . Ok(self) . } . fn super_visit_with>(&self, _: &mut V) -> ControlFlow { . ControlFlow::CONTINUE -- line 176 ---------------------------------------- -- line 194 ---------------------------------------- . . fn tcx<'a>(&'a self) -> TyCtxt<'tcx>; . . fn fold_binder(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T> . where . T: TypeFoldable<'tcx>, . Self: TypeFolder<'tcx, Error = !>, . { 4,407,371 ( 0.01%) t.super_fold_with(self) . } . . fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> . where . Self: TypeFolder<'tcx, Error = !>, . { 345,279 ( 0.00%) t.super_fold_with(self) . } . . fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> . where . Self: TypeFolder<'tcx, Error = !>, . { . r.super_fold_with(self) . } . . fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> . where . Self: TypeFolder<'tcx, Error = !>, . { 23,915 ( 0.00%) c.super_fold_with(self) . } . . fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> . where . Self: TypeFolder<'tcx, Error = !>, . { 48,154 ( 0.00%) p.super_fold_with(self) . } . . fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> . where . Self: TypeFolder<'tcx, Error = !>, . { . bug!("most type folders should not be folding MIR datastructures: {:?}", c) . } -- line 238 ---------------------------------------- -- line 247 ---------------------------------------- . /// A blanket implementation of this trait (that defers to the relevant . /// method of [`TypeFolder`]) is provided for all infallible folders in . /// order to ensure the two APIs are coherent. . pub trait FallibleTypeFolder<'tcx>: TypeFolder<'tcx> { . fn try_fold_binder(&mut self, t: Binder<'tcx, T>) -> Result, Self::Error> . where . T: TypeFoldable<'tcx>, . { 115,786 ( 0.00%) t.try_super_fold_with(self) . } . . fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result, Self::Error> { . t.try_super_fold_with(self) . } . . fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result, Self::Error> { . r.try_super_fold_with(self) -- line 263 ---------------------------------------- -- line 269 ---------------------------------------- . ) -> Result<&'tcx ty::Const<'tcx>, Self::Error> { . c.try_super_fold_with(self) . } . . fn try_fold_predicate( . &mut self, . p: ty::Predicate<'tcx>, . ) -> Result, Self::Error> { 33,105 ( 0.00%) p.try_super_fold_with(self) . } . . fn try_fold_mir_const( . &mut self, . c: mir::ConstantKind<'tcx>, . ) -> Result, Self::Error> { . bug!("most type folders should not be folding MIR datastructures: {:?}", c) . } -- line 285 ---------------------------------------- -- line 286 ---------------------------------------- . } . . // Blanket implementation of fallible trait for infallible folders . // delegates to infallible methods to prevent incoherence . impl<'tcx, F> FallibleTypeFolder<'tcx> for F . where . F: TypeFolder<'tcx, Error = !>, . { 539,958 ( 0.00%) fn try_fold_binder(&mut self, t: Binder<'tcx, T>) -> Result, Self::Error> . where . T: TypeFoldable<'tcx>, . { 1,069,549 ( 0.00%) Ok(self.fold_binder(t)) 753,433 ( 0.00%) } . 1,146,132 ( 0.00%) fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result, Self::Error> { 14,693,214 ( 0.04%) Ok(self.fold_ty(t)) 705,720 ( 0.00%) } . 41,384 ( 0.00%) fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result, Self::Error> { 2,465,217 ( 0.01%) Ok(self.fold_region(r)) 41,384 ( 0.00%) } . 11,210 ( 0.00%) fn try_fold_const( . &mut self, . c: &'tcx ty::Const<'tcx>, . ) -> Result<&'tcx ty::Const<'tcx>, Self::Error> { 1,054,424 ( 0.00%) Ok(self.fold_const(c)) 10,160 ( 0.00%) } . . fn try_fold_predicate( . &mut self, . p: ty::Predicate<'tcx>, . ) -> Result, Self::Error> { . Ok(self.fold_predicate(p)) . } . 25,496 ( 0.00%) fn try_fold_mir_const( . &mut self, . c: mir::ConstantKind<'tcx>, . ) -> Result, Self::Error> { 51,345 ( 0.00%) Ok(self.fold_mir_const(c)) 25,496 ( 0.00%) } . } . . pub trait TypeVisitor<'tcx>: Sized { . type BreakTy = !; . . fn visit_binder>( . &mut self, . t: &Binder<'tcx, T>, . ) -> ControlFlow { 45,937 ( 0.00%) t.super_visit_with(self) . } . . fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { 17,361 ( 0.00%) t.super_visit_with(self) . } . . fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { . r.super_visit_with(self) . } . 636 ( 0.00%) fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow { 3 ( 0.00%) c.super_visit_with(self) 556 ( 0.00%) } . . fn visit_unevaluated_const(&mut self, uv: ty::Unevaluated<'tcx>) -> ControlFlow { . uv.super_visit_with(self) . } . . fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow { . p.super_visit_with(self) . } -- line 359 ---------------------------------------- -- line 376 ---------------------------------------- . . impl<'tcx, F, G, H> TypeFolder<'tcx> for BottomUpFolder<'tcx, F, G, H> . where . F: FnMut(Ty<'tcx>) -> Ty<'tcx>, . G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, . H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>, . { . fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { 222 ( 0.00%) self.tcx . } . . fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { 9,311 ( 0.00%) let t = ty.super_fold_with(self); . (self.ty_op)(t) . } . . fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { . let r = r.super_fold_with(self); . (self.lt_op)(r) . } . . fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { 32 ( 0.00%) let ct = ct.super_fold_with(self); . (self.ct_op)(ct) . } . } . . /////////////////////////////////////////////////////////////////////////// . // Region folder . . impl<'tcx> TyCtxt<'tcx> { -- line 406 ---------------------------------------- -- line 415 ---------------------------------------- . ) -> T . where . T: TypeFoldable<'tcx>, . { . value.fold_with(&mut RegionFolder::new(self, skipped_regions, &mut f)) . } . . /// Invoke `callback` on every region appearing free in `value`. 12,901 ( 0.00%) pub fn for_each_free_region( . self, . value: &impl TypeFoldable<'tcx>, . mut callback: impl FnMut(ty::Region<'tcx>), . ) { . self.any_free_region_meets(value, |r| { 60,823 ( 0.00%) callback(r); . false . }); 11,244 ( 0.00%) } . . /// Returns `true` if `callback` returns true for every region appearing free in `value`. . pub fn all_free_regions_meet( . self, . value: &impl TypeFoldable<'tcx>, . mut callback: impl FnMut(ty::Region<'tcx>) -> bool, . ) -> bool { 11,169 ( 0.00%) !self.any_free_region_meets(value, |r| !callback(r)) . } . . /// Returns `true` if `callback` returns true for some region appearing free in `value`. . pub fn any_free_region_meets( . self, . value: &impl TypeFoldable<'tcx>, . callback: impl FnMut(ty::Region<'tcx>) -> bool, . ) -> bool { -- line 448 ---------------------------------------- -- line 473 ---------------------------------------- . F: FnMut(ty::Region<'tcx>) -> bool, . { . type BreakTy = (); . . fn visit_binder>( . &mut self, . t: &Binder<'tcx, T>, . ) -> ControlFlow { 8,913 ( 0.00%) self.outer_index.shift_in(1); 10,188 ( 0.00%) let result = t.as_ref().skip_binder().visit_with(self); 7,641 ( 0.00%) self.outer_index.shift_out(1); . result . } . 54,200 ( 0.00%) fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { 92,168 ( 0.00%) match *r { 434 ( 0.00%) ty::ReLateBound(debruijn, _) if debruijn < self.outer_index => { . ControlFlow::CONTINUE . } . _ => { . if (self.callback)(r) { . ControlFlow::BREAK . } else { . ControlFlow::CONTINUE . } . } . } 75,880 ( 0.00%) } . . fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { . // We're only interested in types involving regions 73,363 ( 0.00%) if ty.flags().intersects(TypeFlags::HAS_FREE_REGIONS) { 87,308 ( 0.00%) ty.super_visit_with(self) . } else { . ControlFlow::CONTINUE . } . } . } . 136,478 ( 0.00%) value.visit_with(&mut RegionVisitor { outer_index: ty::INNERMOST, callback }).is_break() . } . } . . /// Folds over the substructure of a type, visiting its component . /// types and all regions that occur *free* within it. . /// . /// That is, `Ty` can contain function or method types that bind . /// regions at the call site (`ReLateBound`), and occurrences of -- line 520 ---------------------------------------- -- line 540 ---------------------------------------- . . impl<'a, 'tcx> RegionFolder<'a, 'tcx> { . #[inline] . pub fn new( . tcx: TyCtxt<'tcx>, . skipped_regions: &'a mut bool, . fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>, . ) -> RegionFolder<'a, 'tcx> { 472,138 ( 0.00%) RegionFolder { tcx, skipped_regions, current_index: ty::INNERMOST, fold_region_fn } . } . } . . impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { . fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { 161,188 ( 0.00%) self.tcx 161,188 ( 0.00%) } . . fn fold_binder>( . &mut self, . t: ty::Binder<'tcx, T>, . ) -> ty::Binder<'tcx, T> { 19,978 ( 0.00%) self.current_index.shift_in(1); 52,042 ( 0.00%) let t = t.super_fold_with(self); 17,367 ( 0.00%) self.current_index.shift_out(1); . t . } . 5,752 ( 0.00%) #[instrument(skip(self), level = "debug")] . fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { 81,894 ( 0.00%) match *r { 5,752 ( 0.00%) ty::ReLateBound(debruijn, _) if debruijn < self.current_index => { . debug!(?self.current_index, "skipped bound region"); 5,752 ( 0.00%) *self.skipped_regions = true; . r . } . _ => { . debug!(?self.current_index, "folding free region"); 228,426 ( 0.00%) (self.fold_region_fn)(r, self.current_index) . } . } . } . } . . /////////////////////////////////////////////////////////////////////////// . // Bound vars replacer . -- line 585 ---------------------------------------- -- line 592 ---------------------------------------- . current_index: ty::DebruijnIndex, . . fld_r: Option<&'a mut (dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx> + 'a)>, . fld_t: Option<&'a mut (dyn FnMut(ty::BoundTy) -> Ty<'tcx> + 'a)>, . fld_c: Option<&'a mut (dyn FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx> + 'a)>, . } . . impl<'a, 'tcx> BoundVarReplacer<'a, 'tcx> { 172,694 ( 0.00%) fn new( . tcx: TyCtxt<'tcx>, . fld_r: Option<&'a mut (dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx> + 'a)>, . fld_t: Option<&'a mut (dyn FnMut(ty::BoundTy) -> Ty<'tcx> + 'a)>, . fld_c: Option<&'a mut (dyn FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx> + 'a)>, . ) -> Self { 648,678 ( 0.00%) BoundVarReplacer { tcx, current_index: ty::INNERMOST, fld_r, fld_t, fld_c } 86,347 ( 0.00%) } . } . . impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> { . fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { 435,327 ( 0.00%) self.tcx 137,335 ( 0.00%) } . . fn fold_binder>( . &mut self, . t: ty::Binder<'tcx, T>, . ) -> ty::Binder<'tcx, T> { 534,183 ( 0.00%) self.current_index.shift_in(1); 879,888 ( 0.00%) let t = t.super_fold_with(self); 509,882 ( 0.00%) self.current_index.shift_out(1); . t . } . 1,001,805 ( 0.00%) fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { 903,856 ( 0.00%) match *t.kind() { 14,903 ( 0.00%) ty::Bound(debruijn, bound_ty) if debruijn == self.current_index => { 2,983 ( 0.00%) if let Some(fld_t) = self.fld_t.as_mut() { . let ty = fld_t(bound_ty); 2,983 ( 0.00%) return ty::fold::shift_vars(self.tcx, &ty, self.current_index.as_u32()); . } . } 897,890 ( 0.00%) _ if t.has_vars_bound_at_or_above(self.current_index) => { 1,279,041 ( 0.00%) return t.super_fold_with(self); . } . _ => {} . } . t 847,134 ( 0.00%) } . 339,412 ( 0.00%) fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { 321,318 ( 0.00%) match *r { 303,144 ( 0.00%) ty::ReLateBound(debruijn, br) if debruijn == self.current_index => { 151,402 ( 0.00%) if let Some(fld_r) = self.fld_r.as_mut() { . let region = fld_r(br); 313,652 ( 0.00%) return if let ty::ReLateBound(debruijn1, br) = *region { . // If the callback returns a late-bound region, . // that region should always use the INNERMOST . // debruijn index. Then we adjust it to the . // correct depth. 5,424 ( 0.00%) assert_eq!(debruijn1, ty::INNERMOST); 53,685 ( 0.00%) self.tcx.mk_region(ty::ReLateBound(debruijn, br)) . } else { . region . }; . } . } . _ => {} . } . r 339,412 ( 0.00%) } . . fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { 390 ( 0.00%) match *ct { . ty::Const { val: ty::ConstKind::Bound(debruijn, bound_const), ty } . if debruijn == self.current_index => . { . if let Some(fld_c) = self.fld_c.as_mut() { . let ct = fld_c(bound_const, ty); . return ty::fold::shift_vars(self.tcx, &ct, self.current_index.as_u32()); . } . } 139 ( 0.00%) _ if ct.has_vars_bound_at_or_above(self.current_index) => { . return ct.super_fold_with(self); . } . _ => {} . } . ct . } . } . -- line 681 ---------------------------------------- -- line 697 ---------------------------------------- . mut fld_r: F, . ) -> (T, BTreeMap>) . where . F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>, . T: TypeFoldable<'tcx>, . { . let mut region_map = BTreeMap::new(); . let mut real_fld_r = 494,673 ( 0.00%) |br: ty::BoundRegion| *region_map.entry(br).or_insert_with(|| fld_r(br)); 28,772 ( 0.00%) let value = value.skip_binder(); 105,720 ( 0.00%) let value = if !value.has_escaping_bound_vars() { 180,000 ( 0.00%) value . } else { 42,684 ( 0.00%) let mut replacer = BoundVarReplacer::new(self, Some(&mut real_fld_r), None, None); 5,951 ( 0.00%) value.fold_with(&mut replacer) . }; 443,407 ( 0.00%) (value, region_map) . } . . /// Replaces all escaping bound vars. The `fld_r` closure replaces escaping . /// bound regions; the `fld_t` closure replaces escaping bound types and the `fld_c` . /// closure replaces escaping bound consts. 629,327 ( 0.00%) pub fn replace_escaping_bound_vars( . self, . value: T, . mut fld_r: F, . mut fld_t: G, . mut fld_c: H, . ) -> T . where . F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>, . G: FnMut(ty::BoundTy) -> Ty<'tcx>, . H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>, . T: TypeFoldable<'tcx>, . { 116,172 ( 0.00%) if !value.has_escaping_bound_vars() { 186,420 ( 0.00%) value . } else { . let mut replacer = 975,051 ( 0.00%) BoundVarReplacer::new(self, Some(&mut fld_r), Some(&mut fld_t), Some(&mut fld_c)); 58,243 ( 0.00%) value.fold_with(&mut replacer) . } 432,962 ( 0.00%) } . . /// Replaces all types or regions bound by the given `Binder`. The `fld_r` . /// closure replaces bound regions while the `fld_t` closure replaces bound . /// types. 1,824,716 ( 0.00%) pub fn replace_bound_vars( . self, . value: Binder<'tcx, T>, . mut fld_r: F, . fld_t: G, . fld_c: H, . ) -> (T, BTreeMap>) . where . F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>, . G: FnMut(ty::BoundTy) -> Ty<'tcx>, . H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>, . T: TypeFoldable<'tcx>, . { . let mut region_map = BTreeMap::new(); 321,718 ( 0.00%) let real_fld_r = |br: ty::BoundRegion| *region_map.entry(br).or_insert_with(|| fld_r(br)); 1,638,305 ( 0.00%) let value = self.replace_escaping_bound_vars(value.skip_binder(), real_fld_r, fld_t, fld_c); 1,425,050 ( 0.00%) (value, region_map) 1,366,153 ( 0.00%) } . . /// Replaces any late-bound regions bound in `value` with . /// free variants attached to `all_outlive_scope`. 40,832 ( 0.00%) pub fn liberate_late_bound_regions( . self, . all_outlive_scope: DefId, . value: ty::Binder<'tcx, T>, . ) -> T . where . T: TypeFoldable<'tcx>, . { . self.replace_late_bound_regions(value, |br| { 58,084 ( 0.00%) self.mk_region(ty::ReFree(ty::FreeRegion { 8,936 ( 0.00%) scope: all_outlive_scope, . bound_region: br.kind, . })) . }) . .0 22,272 ( 0.00%) } . . pub fn shift_bound_var_indices(self, bound_vars: usize, value: T) -> T . where . T: TypeFoldable<'tcx>, . { . self.replace_escaping_bound_vars( 64,275 ( 0.00%) value, . |r| { . self.mk_region(ty::ReLateBound( . ty::INNERMOST, . ty::BoundRegion { . var: ty::BoundVar::from_usize(r.var.as_usize() + bound_vars), . kind: r.kind, . }, . )) -- line 795 ---------------------------------------- -- line 843 ---------------------------------------- . fn collect_late_bound_regions( . self, . value: &Binder<'tcx, T>, . just_constraint: bool, . ) -> FxHashSet . where . T: TypeFoldable<'tcx>, . { 7,220 ( 0.00%) let mut collector = LateBoundRegionsCollector::new(just_constraint); . let result = value.as_ref().skip_binder().visit_with(&mut collector); . assert!(result.is_continue()); // should never have stopped early 12,576 ( 0.00%) collector.regions . } . . /// Replaces any late-bound regions bound in `value` with `'erased`. Useful in codegen but also . /// method lookup and a few other places where precise region relationships are not required. 2,429 ( 0.00%) pub fn erase_late_bound_regions(self, value: Binder<'tcx, T>) -> T . where . T: TypeFoldable<'tcx>, . { 23,472 ( 0.00%) self.replace_late_bound_regions(value, |_| self.lifetimes.re_erased).0 2,082 ( 0.00%) } . . /// Rewrite any late-bound regions so that they are anonymous. Region numbers are . /// assigned starting at 0 and increasing monotonically in the order traversed . /// by the fold operation. . /// . /// The chief purpose of this function is to canonicalize regions so that two . /// `FnSig`s or `TraitRef`s which are equivalent up to region naming will become . /// structurally identical. For example, `for<'a, 'b> fn(&'a isize, &'b isize)` and . /// `for<'a, 'b> fn(&'b isize, &'a isize)` will become identical after anonymization. 235,734 ( 0.00%) pub fn anonymize_late_bound_regions(self, sig: Binder<'tcx, T>) -> Binder<'tcx, T> . where . T: TypeFoldable<'tcx>, . { 172,580 ( 0.00%) let mut counter = 0; 18,705 ( 0.00%) let inner = self . .replace_late_bound_regions(sig, |_| { . let br = ty::BoundRegion { 9,672 ( 0.00%) var: ty::BoundVar::from_u32(counter), . kind: ty::BrAnon(counter), . }; 38,688 ( 0.00%) let r = self.mk_region(ty::ReLateBound(ty::INNERMOST, br)); 24,180 ( 0.00%) counter += 1; . r . }) . .0; 34,516 ( 0.00%) let bound_vars = self.mk_bound_variable_kinds( 103,548 ( 0.00%) (0..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i))), . ); 184,254 ( 0.00%) Binder::bind_with_vars(inner, bound_vars) 203,979 ( 0.00%) } . } . . pub struct ValidateBoundVars<'tcx> { . bound_vars: &'tcx ty::List, . binder_index: ty::DebruijnIndex, . // We may encounter the same variable at different levels of binding, so . // this can't just be `Ty` . visited: SsoHashSet<(ty::DebruijnIndex, Ty<'tcx>)>, -- line 902 ---------------------------------------- -- line 1004 ---------------------------------------- . tcx: TyCtxt<'tcx>, . current_index: ty::DebruijnIndex, . amount: u32, . } . . impl<'tcx> Shifter<'tcx> { . pub fn new(tcx: TyCtxt<'tcx>, amount: u32) -> Self { . Shifter { tcx, current_index: ty::INNERMOST, amount } 6,644 ( 0.00%) } . } . . impl<'tcx> TypeFolder<'tcx> for Shifter<'tcx> { . fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { 2,361 ( 0.00%) self.tcx . } . . fn fold_binder>( . &mut self, . t: ty::Binder<'tcx, T>, . ) -> ty::Binder<'tcx, T> { 1,620 ( 0.00%) self.current_index.shift_in(1); 6,708 ( 0.00%) let t = t.super_fold_with(self); 1,602 ( 0.00%) self.current_index.shift_out(1); . t . } . . fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { 806 ( 0.00%) match *r { . ty::ReLateBound(debruijn, br) => { 1,612 ( 0.00%) if self.amount == 0 || debruijn < self.current_index { . r . } else { 367 ( 0.00%) let debruijn = debruijn.shifted_in(self.amount); . let shifted = ty::ReLateBound(debruijn, br); 3,670 ( 0.00%) self.tcx.mk_region(shifted) . } . } . _ => r, . } . } . . fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { 12,140 ( 0.00%) match *ty.kind() { . ty::Bound(debruijn, bound_ty) => { . if self.amount == 0 || debruijn < self.current_index { . ty . } else { . let debruijn = debruijn.shifted_in(self.amount); . self.tcx.mk_ty(ty::Bound(debruijn, bound_ty)) . } . } . 18,534 ( 0.00%) _ => ty.super_fold_with(self), . } . } . . fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { . if let ty::Const { val: ty::ConstKind::Bound(debruijn, bound_ct), ty } = *ct { . if self.amount == 0 || debruijn < self.current_index { . ct . } else { -- line 1064 ---------------------------------------- -- line 1073 ---------------------------------------- . . pub fn shift_region<'tcx>( . tcx: TyCtxt<'tcx>, . region: ty::Region<'tcx>, . amount: u32, . ) -> ty::Region<'tcx> { . match region { . ty::ReLateBound(debruijn, br) if amount > 0 => { 3,848 ( 0.00%) tcx.mk_region(ty::ReLateBound(debruijn.shifted_in(amount), *br)) . } . _ => region, . } . } . . pub fn shift_vars<'tcx, T>(tcx: TyCtxt<'tcx>, value: T, amount: u32) -> T . where . T: TypeFoldable<'tcx>, . { . debug!("shift_vars(value={:?}, amount={})", value, amount); . 6,692 ( 0.00%) value.fold_with(&mut Shifter::new(tcx, amount)) . } . . #[derive(Debug, PartialEq, Eq, Copy, Clone)] . struct FoundEscapingVars; . . /// An "escaping var" is a bound var whose binder is not part of `t`. A bound var can be a . /// bound region or a bound type. . /// -- line 1101 ---------------------------------------- -- line 1128 ---------------------------------------- . . impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor { . type BreakTy = FoundEscapingVars; . . fn visit_binder>( . &mut self, . t: &Binder<'tcx, T>, . ) -> ControlFlow { 56,631 ( 0.00%) self.outer_index.shift_in(1); . let result = t.super_visit_with(self); 74,395 ( 0.00%) self.outer_index.shift_out(1); . result . } . . #[inline] . fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { . // If the outer-exclusive-binder is *strictly greater* than . // `outer_index`, that means that `t` contains some content . // bound at `outer_index` or above (because -- line 1146 ---------------------------------------- -- line 1160 ---------------------------------------- . // visited. . if r.bound_at_or_above_binder(self.outer_index) { . ControlFlow::Break(FoundEscapingVars) . } else { . ControlFlow::CONTINUE . } . } . 1,964 ( 0.00%) fn visit_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> ControlFlow { . // we don't have a `visit_infer_const` callback, so we have to . // hook in here to catch this case (annoying...), but . // otherwise we do want to remember to visit the rest of the . // const, as it has types/regions embedded in a lot of other . // places. 3,419 ( 0.00%) match ct.val { . ty::ConstKind::Bound(debruijn, _) if debruijn >= self.outer_index => { . ControlFlow::Break(FoundEscapingVars) . } 93 ( 0.00%) _ => ct.super_visit_with(self), . } 1,964 ( 0.00%) } . . #[inline] . fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow { . if predicate.inner.outer_exclusive_binder > self.outer_index { . ControlFlow::Break(FoundEscapingVars) . } else { . ControlFlow::CONTINUE . } -- line 1188 ---------------------------------------- -- line 1210 ---------------------------------------- . #[instrument(level = "trace")] . fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow { . debug!( . "HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}", . t, . t.flags(), . self.flags . ); 1,509,322 ( 0.00%) if t.flags().intersects(self.flags) { . ControlFlow::Break(FoundFlags) . } else { . ControlFlow::CONTINUE . } . } . . #[inline] . #[instrument(skip(self), level = "trace")] . fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { 47,057 ( 0.00%) let flags = r.type_flags(); . trace!(r.flags=?flags); 16 ( 0.00%) if flags.intersects(self.flags) { . ControlFlow::Break(FoundFlags) . } else { . ControlFlow::CONTINUE . } . } . . #[inline] . #[instrument(level = "trace")] . fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow { 174,814 ( 0.00%) let flags = FlagComputation::for_const(c); . trace!(r.flags=?flags); 10,422 ( 0.00%) if flags.intersects(self.flags) { . ControlFlow::Break(FoundFlags) . } else { . ControlFlow::CONTINUE . } . } . . #[inline] . #[instrument(level = "trace")] . fn visit_unevaluated_const(&mut self, uv: ty::Unevaluated<'tcx>) -> ControlFlow { 27,228 ( 0.00%) let flags = FlagComputation::for_unevaluated_const(uv); . trace!(r.flags=?flags); . if flags.intersects(self.flags) { . ControlFlow::Break(FoundFlags) . } else { . ControlFlow::CONTINUE . } . } . -- line 1260 ---------------------------------------- -- line 1285 ---------------------------------------- . /// them constraints `'a == 'b`. But if you have `<&'a u32 as . /// Trait>::Foo` and `<&'b u32 as Trait>::Foo`, normalizing those . /// types may mean that `'a` and `'b` don't appear in the results, . /// so they are not considered *constrained*. . just_constrained: bool, . } . . impl LateBoundRegionsCollector { 3,144 ( 0.00%) fn new(just_constrained: bool) -> Self { 22,008 ( 0.00%) LateBoundRegionsCollector { . current_index: ty::INNERMOST, . regions: Default::default(), . just_constrained, . } 3,144 ( 0.00%) } . } . . impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector { . fn visit_binder>( . &mut self, . t: &Binder<'tcx, T>, . ) -> ControlFlow { 3,141 ( 0.00%) self.current_index.shift_in(1); 3,141 ( 0.00%) let result = t.super_visit_with(self); 3,141 ( 0.00%) self.current_index.shift_out(1); . result . } . 12,222 ( 0.00%) fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { . // if we are only looking for "constrained" region, we have to . // ignore the inputs to a projection, as they may not appear . // in the normalized form 20,752 ( 0.00%) if self.just_constrained { 25,847 ( 0.00%) if let ty::Projection(..) | ty::Opaque(..) = t.kind() { . return ControlFlow::CONTINUE; . } . } . 26,403 ( 0.00%) t.super_visit_with(self) 8,158 ( 0.00%) } . . fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow { . // if we are only looking for "constrained" region, we have to . // ignore the inputs of an unevaluated const, as they may not appear . // in the normalized form 10 ( 0.00%) if self.just_constrained { 6 ( 0.00%) if let ty::ConstKind::Unevaluated(..) = c.val { . return ControlFlow::CONTINUE; . } . } . . c.super_visit_with(self) . } . . fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { 8,059 ( 0.00%) if let ty::ReLateBound(debruijn, br) = *r { 1,385 ( 0.00%) if debruijn == self.current_index { . self.regions.insert(br.kind); . } . } . ControlFlow::CONTINUE . } . } 819,337 ( 0.00%) -------------------------------------------------------------------------------- The following files chosen for auto-annotation could not be found: -------------------------------------------------------------------------------- ./malloc/malloc.c ./stdlib/msort.c ./string/../sysdeps/x86_64/multiarch/memchr-avx2.S ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S ./string/../sysdeps/x86_64/multiarch/strcmp-avx2.S ./string/../sysdeps/x86_64/multiarch/strlen-avx2.S /tmp/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/../../../../gcc-5.5.0/libstdc++-v3/libsupc++/new_op.cc -------------------------------------------------------------------------------- Ir -------------------------------------------------------------------------------- 1,187,948,509 ( 3.08%) events annotated