-------------------------------------------------------------------------------- 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 reqwest --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg feature="__tls" --cfg feature="default" --cfg feature="default-tls" --cfg feature="hyper-tls" --cfg feature="native-tls-crate" --cfg feature="tokio-native-tls" -C metadata=11f51ab1147efeb1 -C extra-filename=-11f51ab1147efeb1 --out-dir /usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps -L dependency=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps --extern base64=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libbase64-f3252bdf04487ce5.rmeta --extern bytes=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libbytes-364de0d175a5b11a.rmeta --extern encoding_rs=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libencoding_rs-58a342f182c70875.rmeta --extern futures_core=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libfutures_core-bd3f11407a39088c.rmeta --extern futures_util=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libfutures_util-d7789b10dc7144bd.rmeta --extern h2=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libh2-68a95acd93b8b72c.rmeta --extern http=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libhttp-448493be3d51bac4.rmeta --extern http_body=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libhttp_body-a08de7fc819878e9.rmeta --extern hyper=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libhyper-9c18dcf426defbc8.rlib --extern hyper_tls=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libhyper_tls-e64dee999a70cbcb.rmeta --extern ipnet=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libipnet-49d144b93a6ff5f1.rmeta --extern lazy_static=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/liblazy_static-34247ca5ec35351b.rmeta --extern log=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/liblog-714d106490a098c8.rmeta --extern mime=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libmime-503cc4438b1bca6c.rmeta --extern native_tls_crate=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libnative_tls-82b121ace9c61156.rmeta --extern percent_encoding=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libpercent_encoding-fb8b11180d27e7db.rmeta --extern pin_project_lite=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libpin_project_lite-2b266d11d47dd760.rmeta --extern serde=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libserde-0684c4ca37b59827.rmeta --extern serde_urlencoded=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libserde_urlencoded-f47ec522af4e2f91.rmeta --extern tokio=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libtokio-e077adc3e9826ebb.rmeta --extern tokio_native_tls=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/libtokio_native_tls-f5693b0cef4f7c65.rmeta --extern url=/usr/home/liquid/tmp/.tmpju1Iva/target/debug/deps/liburl-1c7034e7e59b2bb8.rmeta -L native=/usr/home/liquid/.linuxbrew/Cellar/openssl@1.1/1.1.1m/lib -Adeprecated -Aunknown-lints -Zincremental-verify-ich Data file: results/cgout-w-profiling-reqwest-0.11.9-Debug-Full Events recorded: Ir Events shown: Ir Event sort order: Ir Thresholds: 0.1 Include dirs: User annotated: Auto-annotation: on -------------------------------------------------------------------------------- Ir -------------------------------------------------------------------------------- 31,974,798,757 (100.0%) PROGRAM TOTALS -------------------------------------------------------------------------------- Ir file:function -------------------------------------------------------------------------------- 1,721,327,662 ( 5.38%) ???:llvm::FPPassManager::runOnFunction(llvm::Function&) 998,724,457 ( 3.12%) ???:llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) 775,408,119 ( 2.43%) ./malloc/malloc.c:_int_malloc 728,351,224 ( 2.28%) ./malloc/malloc.c:_int_free 469,329,141 ( 1.47%) ???:llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const 446,466,623 ( 1.40%) ./malloc/malloc.c:malloc 437,781,684 ( 1.37%) ???:(anonymous namespace)::Verifier::visitInstruction(llvm::Instruction&) 416,640,924 ( 1.30%) ???:(anonymous namespace)::Verifier::visitMDNode(llvm::MDNode const&, (anonymous namespace)::Verifier::AreDebugLocsAllowed) 376,584,389 ( 1.18%) ???:llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) 365,158,162 ( 1.14%) ???:llvm::raw_svector_ostream::write_impl(char const*, unsigned long) 357,180,222 ( 1.12%) ???:llvm::PMDataManager::verifyPreservedAnalysis(llvm::Pass*) 356,742,950 ( 1.12%) ???:(anonymous namespace)::RegAllocFast::allocateBasicBlock(llvm::MachineBasicBlock&) 348,845,320 ( 1.09%) ???:llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) 280,169,139 ( 0.88%) ???:llvm::MCExpr::evaluateAsRelocatableImpl(llvm::MCValue&, llvm::MCAssembler const*, llvm::MCAsmLayout const*, llvm::MCFixup const*, llvm::DenseMap, llvm::detail::DenseMapPair > const*, bool) const 256,777,750 ( 0.80%) ???:llvm::StringMapImpl::LookupBucketFor(llvm::StringRef) 219,319,620 ( 0.69%) ???:llvm::MCAsmLayout::getSymbolOffset(llvm::MCSymbol const&) const 212,818,653 ( 0.67%) ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_erms 211,509,084 ( 0.66%) ???:llvm::ScheduleDAGSDNodes::BuildSchedUnits() 210,916,134 ( 0.66%) ./malloc/malloc.c:free 189,747,710 ( 0.59%) ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms 188,745,384 ( 0.59%) ???:(anonymous namespace)::VarLocBasedLDV::process(llvm::MachineInstr&, (anonymous namespace)::VarLocBasedLDV::OpenRangesSet&, (anonymous namespace)::VarLocBasedLDV::VarLocMap&, llvm::SmallVector<(anonymous namespace)::VarLocBasedLDV::TransferDebugPair, 4u>&) 181,099,136 ( 0.57%) ???:llvm::TargetLoweringBase::getTypeConversion(llvm::LLVMContext&, llvm::EVT) const 175,441,996 ( 0.55%) ???:llvm::FoldingSetNodeID::AddInteger(unsigned int) 162,811,464 ( 0.51%) ???:llvm::MCObjectStreamer::emitBytes(llvm::StringRef) 158,686,460 ( 0.50%) ???:llvm::MCAsmLayout::getFragmentOffset(llvm::MCFragment const*) const 146,712,524 ( 0.46%) ???:llvm::TargetRegisterInfo::shouldRealignStack(llvm::MachineFunction const&) const 145,344,489 ( 0.45%) ???:(anonymous namespace)::Verifier::visitCallBase(llvm::CallBase&) 145,141,856 ( 0.45%) ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_sse2_unaligned_erms 143,283,818 ( 0.45%) ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:__memcmp_avx2_movbe 142,640,624 ( 0.45%) ???:llvm::TargetRegisterInfo::checkAllSuperRegsMarked(llvm::BitVector const&, llvm::ArrayRef) const 142,514,274 ( 0.45%) ???:llvm::coro::declaresIntrinsics(llvm::Module const&, std::initializer_list) 140,155,776 ( 0.44%) ???:(anonymous namespace)::TwoAddressInstructionPass::runOnMachineFunction(llvm::MachineFunction&) 136,002,090 ( 0.43%) ???:llvm::SelectionDAG::MorphNodeTo(llvm::SDNode*, unsigned int, llvm::SDVTList, llvm::ArrayRef) 134,712,728 ( 0.42%) ???:multikeySort(llvm::MutableArrayRef*>, int) 134,353,149 ( 0.42%) ???:llvm::InstrEmitter::EmitMachineNode(llvm::SDNode*, bool, bool, llvm::DenseMap, llvm::detail::DenseMapPair >&) 130,695,384 ( 0.41%) ???:llvm::SmallSet >::insert(llvm::Register const&) 129,230,592 ( 0.40%) ./string/../sysdeps/x86_64/multiarch/strcmp-avx2.S:__strncmp_avx2 127,536,861 ( 0.40%) ???:(anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) [clone .llvm.8386621111310650999] 127,421,520 ( 0.40%) ???:llvm::DAGTypeLegalizer::run() 126,184,622 ( 0.39%) ???:(anonymous namespace)::Verifier::verify(llvm::Function const&) [clone .llvm.4153962086227604281] 124,776,151 ( 0.39%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::CalculateFromScratch(llvm::DominatorTreeBase&, llvm::DomTreeBuilder::SemiNCAInfo >::BatchUpdateInfo*) 124,197,777 ( 0.39%) ???:(anonymous namespace)::X86MCCodeEmitter::emitPrefixImpl(unsigned int&, llvm::MCInst const&, llvm::MCSubtargetInfo const&, llvm::raw_ostream&) const 120,105,461 ( 0.38%) ???:llvm::MetadataTracking::track(void*, llvm::Metadata&, llvm::PointerUnion) 118,503,305 ( 0.37%) ???:(anonymous namespace)::Verifier::verifyFunctionAttrs(llvm::FunctionType*, llvm::AttributeList, llvm::Value const*, bool) 118,391,931 ( 0.37%) ???:llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, void*&, llvm::FoldingSetBase::FoldingSetInfo const&) 114,210,838 ( 0.36%) ???:llvm::MCContext::getOrCreateSymbol(llvm::Twine const&) 112,107,418 ( 0.35%) ???:llvm::SelectionDAG::getConstant(llvm::ConstantInt const&, llvm::SDLoc const&, llvm::EVT, bool, bool) 109,187,216 ( 0.34%) ???:(anonymous namespace)::VarLocBasedLDV::ExtendRanges(llvm::MachineFunction&, llvm::TargetPassConfig*) [clone .llvm.4451506318407214204] 108,961,331 ( 0.34%) ???:llvm::SelectionDAG::Legalize() 108,887,489 ( 0.34%) ???:(anonymous namespace)::ELFObjectWriter::recordRelocation(llvm::MCAssembler&, llvm::MCAsmLayout const&, llvm::MCFragment const*, llvm::MCFixup const&, llvm::MCValue, unsigned long&) [clone .llvm.14145361893594770252] 105,968,993 ( 0.33%) ???:llvm::MDString::get(llvm::LLVMContext&, llvm::StringRef) 104,241,158 ( 0.33%) ./malloc/malloc.c:malloc_consolidate 103,535,360 ( 0.32%) ???:llvm::calculateDbgEntityHistory(llvm::MachineFunction const*, llvm::TargetRegisterInfo const*, llvm::DbgValueHistoryMap&, llvm::DbgLabelInstrMap&) 100,813,592 ( 0.32%) ???:(anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) 95,350,246 ( 0.30%) ???:(anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) 92,389,551 ( 0.29%) ???:(anonymous namespace)::ScheduleDAGRRList::Schedule() [clone .llvm.6953762222372402862] 88,166,181 ( 0.28%) ./malloc/malloc.c:unlink_chunk.constprop.0 87,294,911 ( 0.27%) ???:llvm::MDNode::MDNode(llvm::LLVMContext&, unsigned int, llvm::Metadata::StorageType, llvm::ArrayRef, llvm::ArrayRef) 81,444,097 ( 0.25%) ???:(anonymous namespace)::X86MCInstLower::Lower(llvm::MachineInstr const*, llvm::MCInst&) const 81,136,188 ( 0.25%) ./stdlib/msort.c:msort_with_tmp.part.0 75,988,387 ( 0.24%) ???:llvm::X86FrameLowering::hasFP(llvm::MachineFunction const&) const 75,343,294 ( 0.24%) ???:(anonymous namespace)::Verifier::visitFunction(llvm::Function const&)::$_3::operator()(llvm::Instruction const&, llvm::MDNode const*) const 74,683,787 ( 0.23%) ???:llvm::FunctionLoweringInfo::set(llvm::Function const&, llvm::MachineFunction&, llvm::SelectionDAG*) 73,916,838 ( 0.23%) ???:llvm::FoldingSet::NodeEquals(llvm::FoldingSetBase const*, llvm::FoldingSetBase::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) 72,992,574 ( 0.23%) ???:(anonymous namespace)::X86MCCodeEmitter::encodeInstruction(llvm::MCInst const&, llvm::raw_ostream&, llvm::SmallVectorImpl&, llvm::MCSubtargetInfo const&) const 72,071,844 ( 0.23%) ???:llvm::MachineFunction::CreateMachineInstr(llvm::MCInstrDesc const&, llvm::DebugLoc const&, bool) 71,547,424 ( 0.22%) ???:llvm::MCAssembler::layout(llvm::MCAsmLayout&) 71,404,234 ( 0.22%) ???:llvm::ScheduleDAGSDNodes::AddSchedEdges() 70,822,353 ( 0.22%) ???:llvm::PMDataManager::removeNotPreservedAnalysis(llvm::Pass*) 70,234,798 ( 0.22%) ???:llvm::DwarfDebug::beginInstruction(llvm::MachineInstr const*) 69,924,767 ( 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}> 69,489,643 ( 0.22%) ???:(anonymous namespace)::ELFWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout const&) 68,241,040 ( 0.21%) ???:llvm::SmallPtrSetImplBase::insert_imp_big(void const*) 66,900,869 ( 0.21%) ???:llvm::AttributeSetNode::get(llvm::LLVMContext&, llvm::AttrBuilder const&) 66,647,356 ( 0.21%) ???:llvm::raw_ostream::write(char const*, unsigned long) 65,272,104 ( 0.20%) ???:llvm::SelectionDAG::AssignTopologicalOrder() 62,272,866 ( 0.19%) ???:(anonymous namespace)::CFIInstrInserter::runOnMachineFunction(llvm::MachineFunction&) 62,040,131 ( 0.19%) ???:llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) 61,989,398 ( 0.19%) ???:llvm::DataLayout::getAlignment(llvm::Type*, bool) const 61,813,693 ( 0.19%) ???:llvm::Twine::printOneChild(llvm::raw_ostream&, llvm::Twine::Child, llvm::Twine::NodeKind) const 60,708,813 ( 0.19%) /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) 60,389,797 ( 0.19%) ???:llvm::SelectionDAG::getRegister(unsigned int, llvm::EVT) 59,803,430 ( 0.19%) ???:(anonymous namespace)::RegAllocFast::markRegUsedInInstr(unsigned short) 59,196,457 ( 0.19%) ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_unaligned_erms 57,016,774 ( 0.18%) ???:llvm::MCELFStreamer::emitLabel(llvm::MCSymbol*, llvm::SMLoc) 55,631,712 ( 0.17%) ???:llvm::hashing::detail::hash_combine_recursive_helper::combine(unsigned long, char*, char*) 55,506,391 ( 0.17%) ???:char* llvm::hashing::detail::hash_combine_recursive_helper::combine_data(unsigned long&, char*, char*, llvm::Metadata*) 55,453,919 ( 0.17%) ???:llvm::LLVMContextImpl::~LLVMContextImpl() 55,189,976 ( 0.17%) ???:llvm::X86TargetMachine::getTargetTransformInfo(llvm::Function const&) 54,715,684 ( 0.17%) ???:(anonymous namespace)::X86AsmBackend::applyFixup(llvm::MCAssembler const&, llvm::MCFixup const&, llvm::MCValue const&, llvm::MutableArrayRef, unsigned long, bool, llvm::MCSubtargetInfo const*) const 54,664,859 ( 0.17%) ???:llvm::DomTreeBuilder::SemiNCAInfo >::runSemiNCA(llvm::DominatorTreeBase&, unsigned int) 54,586,569 ( 0.17%) ???:llvm::FoldingSet::NodeEquals(llvm::FoldingSetBase const*, llvm::FoldingSetBase::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) 54,522,287 ( 0.17%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/slice/mod.rs:::lookup_source_file_idx 54,435,010 ( 0.17%) ???:llvm::AsmPrinter::emitFunctionBody() 53,930,496 ( 0.17%) ???:(anonymous namespace)::X86MCCodeEmitter::emitMemModRMByte(llvm::MCInst const&, unsigned int, unsigned int, unsigned long, bool, unsigned long, llvm::raw_ostream&, llvm::SmallVectorImpl&, llvm::MCSubtargetInfo const&, bool) const 53,200,092 ( 0.17%) ???:(anonymous namespace)::VarLocBasedLDV::collectIDsForRegs(llvm::SmallSet >&, llvm::SmallSet > const&, llvm::CoalescingBitVector const&, (anonymous namespace)::VarLocBasedLDV::VarLocMap const&) 53,141,840 ( 0.17%) ???:llvm::MachineFunctionPass::runOnFunction(llvm::Function&) 53,116,001 ( 0.17%) ???:llvm::MCELFStreamer::emitInstToData(llvm::MCInst const&, llvm::MCSubtargetInfo const&) 53,089,441 ( 0.17%) ???:llvm::InlineFunction(llvm::CallBase&, llvm::InlineFunctionInfo&, llvm::AAResults*, bool, llvm::Function*) 52,413,666 ( 0.16%) ???:llvm::BumpPtrAllocatorImpl::Allocate(unsigned long, llvm::Align) 52,034,879 ( 0.16%) ???:llvm::MCStreamer::emitULEB128IntValue(unsigned long, unsigned int) 51,620,514 ( 0.16%) ???:llvm::DIEAbbrev::Profile(llvm::FoldingSetNodeID&) const 50,289,706 ( 0.16%) ???:llvm::X86RegisterInfo::eliminateFrameIndex(llvm::MachineInstrBundleIterator, int, unsigned int, llvm::RegScavenger*) const 50,104,133 ( 0.16%) ???:llvm::MCDwarfLineAddr::Encode(llvm::MCContext&, llvm::MCDwarfLineTableParams, long, unsigned long, llvm::raw_ostream&) 49,344,111 ( 0.15%) ???:llvm::MCObjectStreamer::emitInstruction(llvm::MCInst const&, llvm::MCSubtargetInfo const&) 49,171,847 ( 0.15%) ???:llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::SDVTList, llvm::ArrayRef) 48,909,040 ( 0.15%) ???:??? 48,820,517 ( 0.15%) ???:llvm::ScheduleDAGSDNodes::EmitSchedule(llvm::MachineInstrBundleIterator&) 48,683,892 ( 0.15%) ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:memcpy@GLIBC_2.2.5 45,104,276 ( 0.14%) ???:llvm::CoalescingBitVector::find(unsigned long) const 44,681,406 ( 0.14%) ???:llvm::MDNodeKeyImpl::MDNodeKeyImpl(llvm::DICompositeType const*) 44,431,349 ( 0.14%) ???:llvm::MCObjectStreamer::emitValueImpl(llvm::MCExpr const*, unsigned int, llvm::SMLoc) 43,652,898 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/str/lossy.rs:::next 42,794,907 ( 0.13%) ???:llvm::MCAssembler::layoutSectionOnce(llvm::MCAsmLayout&, llvm::MCSection&) 42,507,772 ( 0.13%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/rustc_entry.rs:>>::rustc_entry 41,917,202 ( 0.13%) ???:llvm::DILocation::getImpl(llvm::LLVMContext&, unsigned int, unsigned int, llvm::Metadata*, llvm::Metadata*, bool, llvm::Metadata::StorageType, bool) 41,536,342 ( 0.13%) ./malloc/malloc.c:realloc 41,435,234 ( 0.13%) ???:llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const 41,095,621 ( 0.13%) ???:llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) 41,077,328 ( 0.13%) ???:llvm::LazyCallGraph::Node::populateSlow() 40,983,541 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/fmt/mod.rs:core::fmt::write 40,813,937 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/slice/mod.rs:::line_begin_pos 40,813,937 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/slice/mod.rs:::lookup_line 40,790,105 ( 0.13%) ???:(anonymous namespace)::RegAllocFast::setPhysReg(llvm::MachineInstr&, llvm::MachineOperand&, unsigned short) 40,208,429 ( 0.13%) ???:(anonymous namespace)::PruningFunctionCloner::CloneBlock(llvm::BasicBlock const*, llvm::ilist_iterator, false, true>, std::vector >&) 40,098,335 ( 0.13%) ???:llvm::Function::dropAllReferences() 40,089,395 ( 0.13%) ???:llvm::InstrEmitter::EmitCopyFromReg(llvm::SDNode*, unsigned int, bool, bool, llvm::Register, llvm::DenseMap, llvm::detail::DenseMapPair >&) 39,677,542 ( 0.12%) ???:llvm::SelectionDAG::clear() 39,104,793 ( 0.12%) ???:llvm::X86FrameLowering::getFrameIndexReference(llvm::MachineFunction const&, int, llvm::Register&) const 38,970,161 ( 0.12%) ???:llvm::MDTuple::getImpl(llvm::LLVMContext&, llvm::ArrayRef, llvm::Metadata::StorageType, bool) 38,474,893 ( 0.12%) ???:llvm::DIEValueList::addValue(llvm::BumpPtrAllocatorImpl&, llvm::DIEValue const&) 38,422,085 ( 0.12%) ???:llvm::Module::getOrInsertFunction(llvm::StringRef, llvm::FunctionType*) 38,219,639 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/sty.rs:::eq 38,002,617 ( 0.12%) ???:(anonymous namespace)::X86AsmBackend::getFixupKindInfo(llvm::MCFixupKind) const 37,806,176 ( 0.12%) ???:llvm::X86RegisterInfo::getReservedRegs(llvm::MachineFunction const&) const 37,201,896 ( 0.12%) ???:(anonymous namespace)::RegAllocFast::allocVirtReg(llvm::MachineInstr&, (anonymous namespace)::RegAllocFast::LiveReg&, llvm::Register, bool) 37,192,545 ( 0.12%) ???:llvm::MDString* llvm::DINode::getOperandAs(unsigned int) const 36,969,673 ( 0.12%) ???:llvm::MDNode::dropAllReferences() 36,962,595 ( 0.12%) ???:llvm::SelectionDAG::computeKnownBits(llvm::SDValue, llvm::APInt const&, unsigned int) const 36,954,295 ( 0.12%) ???:llvm::TargetLoweringBase::ArgListEntry::setAttributes(llvm::CallBase const*, unsigned int) 36,853,077 ( 0.12%) ???:(anonymous namespace)::VectorLegalizer::LegalizeOp(llvm::SDValue) [clone .llvm.3993696295502019106] 36,204,791 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs:rustc_codegen_ssa::debuginfo::type_names::push_item_name 35,875,146 ( 0.11%) ???:(anonymous namespace)::RegAllocFast::freePhysReg(unsigned short) 35,611,096 ( 0.11%) ???:(anonymous namespace)::X86AsmBackend::emitInstructionBegin(llvm::MCObjectStreamer&, llvm::MCInst const&) 35,591,453 ( 0.11%) ???:(anonymous namespace)::RemoveRedundantDebugValues::runOnMachineFunction(llvm::MachineFunction&) 35,112,074 ( 0.11%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>>::rustc_entry 35,106,504 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/subst.rs:::fold_ty 35,028,827 ( 0.11%) ???:(anonymous namespace)::RegAllocFast::isRegUsedInInstr(unsigned short, bool) const 34,908,297 ( 0.11%) ???:llvm::X86TargetMachine::getSubtargetImpl(llvm::Function const&) const 34,410,161 ( 0.11%) ???:bool llvm::DenseMapBase, llvm::detail::DenseSetPair >, llvm::DILocation*, llvm::detail::DenseSetEmpty, llvm::MDNodeInfo, llvm::detail::DenseSetPair >::LookupBucketFor(llvm::DILocation* const&, llvm::detail::DenseSetPair const*&) const 34,207,070 ( 0.11%) ./nptl/pthread_rwlock_common.c:pthread_rwlock_unlock 33,718,863 ( 0.11%) ???:llvm::LexicalScopes::extractLexicalScopes(llvm::SmallVectorImpl >&, llvm::DenseMap, llvm::detail::DenseMapPair >&) 33,124,694 ( 0.10%) ???:llvm::MCAssembler::writeSectionData(llvm::raw_ostream&, llvm::MCSection const*, llvm::MCAsmLayout const&) const 33,070,140 ( 0.10%) ???:llvm::MetadataTracking::untrack(void*, llvm::Metadata&) 33,054,370 ( 0.10%) ???:(anonymous namespace)::X86AsmBackend::emitInstructionEnd(llvm::MCObjectStreamer&, llvm::MCInst const&) 32,856,410 ( 0.10%) ???:llvm::MachineInstr::AddRegOperandsToUseLists(llvm::MachineRegisterInfo&) 32,697,676 ( 0.10%) ???:llvm::SmallDenseMap, llvm::detail::DenseSetPair >::grow(unsigned int) 32,617,049 ( 0.10%) ???:llvm::MCSymbolRefExpr::create(llvm::MCSymbol const*, llvm::MCSymbolRefExpr::VariantKind, llvm::MCContext&, llvm::SMLoc) 32,600,764 ( 0.10%) ???:llvm::SelectionDAG::RemoveDeadNodes() 32,580,660 ( 0.10%) ???:llvm::CallBase::getArgOperand(unsigned int) const -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/library/core/src/fmt/mod.rs -------------------------------------------------------------------------------- Ir -- line 177 ---------------------------------------- . /// f.write_fmt(format_args!("{}", s)) . /// } . /// . /// let mut buf = String::new(); . /// writer(&mut buf, "world").unwrap(); . /// assert_eq!(&buf, "world"); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] 30 ( 0.00%) fn write_fmt(mut self: &mut Self, args: Arguments<'_>) -> Result { 9,392,457 ( 0.03%) write(&mut self, args) 30 ( 0.00%) } . } . . #[stable(feature = "fmt_write_blanket_impl", since = "1.4.0")] . impl Write for &mut W { 5,892,113 ( 0.02%) fn write_str(&mut self, s: &str) -> Result { 3,401,577 ( 0.01%) (**self).write_str(s) 6,170,047 ( 0.02%) } . 5,379 ( 0.00%) fn write_char(&mut self, c: char) -> Result { 2,581 ( 0.00%) (**self).write_char(c) 8,001 ( 0.00%) } . . fn write_fmt(&mut self, args: Arguments<'_>) -> Result { . (**self).write_fmt(args) . } . } . . /// Configuration for formatting. . /// -- line 206 ---------------------------------------- -- line 228 ---------------------------------------- . /// . /// This can be used as a micro-optimization in cases where a full `Arguments` . /// structure (as created by `format_args!`) is not necessary; `Arguments` . /// is a little more expensive to use in simple formatting scenarios. . /// . /// Currently not intended for use outside of the standard library. . #[unstable(feature = "fmt_internals", reason = "internal to standard library", issue = "none")] . #[doc(hidden)] 276,140 ( 0.00%) pub fn new(buf: &'a mut (dyn Write + 'a)) -> Formatter<'a> { 6,923,082 ( 0.02%) Formatter { . flags: 0, . fill: ' ', . align: rt::v1::Alignment::Unknown, . width: None, . precision: None, . buf, . } 138,070 ( 0.00%) } . } . . // NB. Argument is essentially an optimized partially applied formatting function, . // equivalent to `exists T.(&T, fn(&T, &mut Formatter<'_>) -> Result`. . . extern "C" { . type Opaque; . } -- line 253 ---------------------------------------- -- line 357 ---------------------------------------- . #[doc(hidden)] . #[inline] . #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "none")] . #[rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none")] . pub const fn new_v1(pieces: &'a [&'static str], args: &'a [ArgumentV1<'a>]) -> Arguments<'a> { . if pieces.len() < args.len() || pieces.len() > args.len() + 1 { . panic!("invalid args"); . } 2,114,324 ( 0.01%) Arguments { pieces, fmt: None, args } . } . . /// This function is used to specify nonstandard formatting parameters. . /// . /// An `UnsafeArg` is required because the following invariants must be held . /// in order for this function to be safe: . /// 1. The `pieces` slice must be at least as long as `fmt`. . /// 2. Every [`rt::v1::Argument::position`] value within `fmt` must be a -- line 373 ---------------------------------------- -- line 379 ---------------------------------------- . #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "none")] . #[rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none")] . pub const fn new_v1_formatted( . pieces: &'a [&'static str], . args: &'a [ArgumentV1<'a>], . fmt: &'a [rt::v1::Argument], . _unsafe_arg: UnsafeArg, . ) -> Arguments<'a> { 471,814 ( 0.00%) Arguments { pieces, fmt: Some(fmt), args } . } . . /// Estimates the length of the formatted text. . /// . /// This is intended to be used for setting initial `String` capacity . /// when using `format!`. Note: this is neither the lower nor upper bound. . #[doc(hidden)] . #[inline] . #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "none")] . pub fn estimated_capacity(&self) -> usize { . let pieces_length: usize = self.pieces.iter().map(|x| x.len()).sum(); . 135,060 ( 0.00%) if self.args.is_empty() { . pieces_length 540,240 ( 0.00%) } else if !self.pieces.is_empty() && self.pieces[0].is_empty() && pieces_length < 16 { . // If the format string starts with an argument, . // don't preallocate anything, unless length . // of pieces is significant. . 0 . } else { . // There are some arguments, so any additional push . // will reallocate the string. To avoid that, . // we're "pre-doubling" the capacity here. -- line 410 ---------------------------------------- -- line 1146 ---------------------------------------- . /// let mut output = String::new(); . /// write!(&mut output, "Hello {}!", "world") . /// .expect("Error occurred while trying to write in String"); . /// assert_eq!(output, "Hello world!"); . /// ``` . /// . /// [`write!`]: crate::write! . #[stable(feature = "rust1", since = "1.0.0")] 9,141,993 ( 0.03%) pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result { . let mut formatter = Formatter::new(output); . let mut idx = 0; . 3,047,331 ( 0.01%) match args.fmt { . None => { . // We can use default formatting parameters for all arguments. 989,499 ( 0.00%) for (i, arg) in args.args.iter().enumerate() { . // SAFETY: args.args and args.pieces come from the same Arguments, . // which guarantees the indexes are always within bounds. . let piece = unsafe { args.pieces.get_unchecked(i) }; 1,544,346 ( 0.00%) if !piece.is_empty() { 1,584,210 ( 0.00%) formatter.buf.write_str(*piece)?; . } 3,860,865 ( 0.01%) (arg.formatter)(arg.value, &mut formatter)?; . idx += 1; . } . } . Some(fmt) => { . // Every spec has a corresponding argument that is preceded by . // a string piece. . for (i, arg) in fmt.iter().enumerate() { . // SAFETY: fmt and args.pieces come from the same Arguments, . // which guarantees the indexes are always within bounds. . let piece = unsafe { args.pieces.get_unchecked(i) }; 52,752 ( 0.00%) if !piece.is_empty() { 81,444 ( 0.00%) formatter.buf.write_str(*piece)?; . } . // SAFETY: arg and args.args come from the same Arguments, . // which guarantees the indexes are always within bounds. 79,128 ( 0.00%) unsafe { run(&mut formatter, arg, args.args) }?; . idx += 1; . } . } . } . . // There can be only one trailing string piece left. 1,015,777 ( 0.00%) if let Some(piece) = args.pieces.get(idx) { 3,637,095 ( 0.01%) formatter.buf.write_str(*piece)?; . } . . Ok(()) 8,126,216 ( 0.03%) } . . unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV1<'_>]) -> Result { 52,752 ( 0.00%) fmt.fill = arg.format.fill; 52,752 ( 0.00%) fmt.align = arg.format.align; 52,752 ( 0.00%) fmt.flags = arg.format.flags; . // SAFETY: arg and args come from the same Arguments, . // which guarantees the indexes are always within bounds. . unsafe { 105,504 ( 0.00%) fmt.width = getcount(args, &arg.format.width); 105,504 ( 0.00%) fmt.precision = getcount(args, &arg.format.precision); . } . . // Extract the correct argument . debug_assert!(arg.position < args.len()); . // SAFETY: arg and args come from the same Arguments, . // which guarantees its index is always within bounds. 26,376 ( 0.00%) let value = unsafe { args.get_unchecked(arg.position) }; . . // Then actually do some printing 79,128 ( 0.00%) (value.formatter)(value.value, fmt) . } . . unsafe fn getcount(args: &[ArgumentV1<'_>], cnt: &rt::v1::Count) -> Option { 158,452 ( 0.00%) match *cnt { . rt::v1::Count::Is(n) => Some(n), . rt::v1::Count::Implied => None, . rt::v1::Count::Param(i) => { . debug_assert!(i < args.len()); . // SAFETY: cnt and args come from the same Arguments, . // which guarantees this index is always within bounds. . unsafe { args.get_unchecked(i).as_usize() } . } -- line 1228 ---------------------------------------- -- line 1312 ---------------------------------------- . /// . /// assert_eq!(&format!("{}", Foo::new(2)), "2"); . /// assert_eq!(&format!("{}", Foo::new(-1)), "-1"); . /// assert_eq!(&format!("{}", Foo::new(0)), "0"); . /// assert_eq!(&format!("{:#}", Foo::new(-1)), "-Foo 1"); . /// assert_eq!(&format!("{:0>#8}", Foo::new(-1)), "00-Foo 1"); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] 3,767,808 ( 0.01%) pub fn pad_integral(&mut self, is_nonnegative: bool, prefix: &str, buf: &str) -> Result { . let mut width = buf.len(); . . let mut sign = None; 627,968 ( 0.00%) if !is_nonnegative { . sign = Some('-'); . width += 1; 313,984 ( 0.00%) } else if self.sign_plus() { . sign = Some('+'); 313,984 ( 0.00%) width += 1; . } . 313,984 ( 0.00%) let prefix = if self.alternate() { . width += prefix.chars().count(); . Some(prefix) . } else { . None . }; . . // Writes the sign if it exists, and then the prefix if it was requested . #[inline(never)] 1,883,904 ( 0.01%) fn write_prefix(f: &mut Formatter<'_>, sign: Option, prefix: Option<&str>) -> Result { 627,968 ( 0.00%) if let Some(c) = sign { . f.buf.write_char(c)?; . } 627,968 ( 0.00%) if let Some(prefix) = prefix { f.buf.write_str(prefix) } else { Ok(()) } 1,255,936 ( 0.00%) } . . // The `width` field is more of a `min-width` parameter at this point. 627,968 ( 0.00%) match self.width { . // If there's no minimum length requirements then we can just . // write the bytes. . None => { 2,013,942 ( 0.01%) write_prefix(self, sign, prefix)?; 1,438,530 ( 0.00%) self.buf.write_str(buf) . } . // Check if we're over the minimum width, if so then we can also . // just write the bytes. 78,834 ( 0.00%) Some(min) if width >= min => { 196,776 ( 0.00%) write_prefix(self, sign, prefix)?; 73,791 ( 0.00%) self.buf.write_str(buf) . } . // The sign and prefix goes before the padding if the fill character . // is zero 1,681 ( 0.00%) Some(min) if self.sign_aware_zero_pad() => { . let old_fill = crate::mem::replace(&mut self.fill, '0'); . let old_align = crate::mem::replace(&mut self.align, rt::v1::Alignment::Right); 11,767 ( 0.00%) write_prefix(self, sign, prefix)?; 8,405 ( 0.00%) let post_padding = self.padding(min - width, rt::v1::Alignment::Right)?; 11,767 ( 0.00%) self.buf.write_str(buf)?; . post_padding.write(self)?; 3,362 ( 0.00%) self.fill = old_fill; 5,043 ( 0.00%) self.align = old_align; . Ok(()) . } . // Otherwise, the sign and prefix goes after the padding . Some(min) => { . let post_padding = self.padding(min - width, rt::v1::Alignment::Right)?; . write_prefix(self, sign, prefix)?; . self.buf.write_str(buf)?; . post_padding.write(self) . } . } 15,129 ( 0.00%) } . . /// This function takes a string slice and emits it to the internal buffer . /// after applying the relevant formatting flags specified. The flags . /// recognized for generic strings are: . /// . /// * width - the minimum width of what to emit . /// * fill/align - what to emit and where to emit it if the string . /// provided needs to be padded -- line 1391 ---------------------------------------- -- line 1406 ---------------------------------------- . /// formatter.pad("Foo") . /// } . /// } . /// . /// assert_eq!(&format!("{:<4}", Foo), "Foo "); . /// assert_eq!(&format!("{:0>4}", Foo), "0Foo"); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] 3,589,668 ( 0.01%) pub fn pad(&mut self, s: &str) -> Result { . // Make sure there's a fast path up front 1,196,556 ( 0.00%) if self.width.is_none() && self.precision.is_none() { . return self.buf.write_str(s); . } . // The `precision` field can be interpreted as a `max-width` for the . // string being formatted. . let s = if let Some(max) = self.precision { . // If our string is longer that the precision, then we must have . // truncation. However other flags like `fill`, `width` and `align` . // must act as always. -- line 1424 ---------------------------------------- -- line 1461 ---------------------------------------- . /// Write the pre-padding and return the unwritten post-padding. Callers are . /// responsible for ensuring post-padding is written after the thing that is . /// being padded. . pub(crate) fn padding( . &mut self, . padding: usize, . default: rt::v1::Alignment, . ) -> result::Result { 3,362 ( 0.00%) let align = match self.align { . rt::v1::Alignment::Unknown => default, . _ => self.align, . }; . 6,724 ( 0.00%) let (pre_pad, post_pad) = match align { . rt::v1::Alignment::Left => (0, padding), . rt::v1::Alignment::Right | rt::v1::Alignment::Unknown => (padding, 0), . rt::v1::Alignment::Center => (padding / 2, (padding + 1) / 2), . }; . 5,043 ( 0.00%) for _ in 0..pre_pad { 8,610 ( 0.00%) self.buf.write_char(self.fill)?; . } . . Ok(PostPadding::new(self.fill, post_pad)) . } . . /// Takes the formatted parts and applies the padding. . /// Assumes that the caller already has rendered the parts with required precision, . /// so that `self.precision` can be ignored. -- line 1489 ---------------------------------------- -- line 1591 ---------------------------------------- . /// } . /// } . /// . /// assert_eq!(&format!("{}", Foo), "Foo"); . /// assert_eq!(&format!("{:0>8}", Foo), "Foo"); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn write_str(&mut self, data: &str) -> Result { 4,222,615 ( 0.01%) self.buf.write_str(data) . } . . /// Writes some formatted information into this instance. . /// . /// # Examples . /// . /// ``` . /// use std::fmt; -- line 1607 ---------------------------------------- -- line 1613 ---------------------------------------- . /// formatter.write_fmt(format_args!("Foo {}", self.0)) . /// } . /// } . /// . /// assert_eq!(&format!("{}", Foo(-1)), "Foo -1"); . /// assert_eq!(&format!("{:0>8}", Foo(2)), "Foo 2"); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] 120,289 ( 0.00%) pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result { 1,443,468 ( 0.00%) write(self.buf, fmt) 240,578 ( 0.00%) } . . /// Flags for formatting . #[must_use] . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_deprecated( . since = "1.24.0", . reason = "use the `sign_plus`, `sign_minus`, `alternate`, \ . or `sign_aware_zero_pad` methods instead" -- line 1631 ---------------------------------------- -- line 1793 ---------------------------------------- . /// } . /// . /// assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)"); . /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)"); . /// ``` . #[must_use] . #[stable(feature = "fmt_flags", since = "1.5.0")] . pub fn sign_plus(&self) -> bool { 941,952 ( 0.00%) self.flags & (1 << FlagV1::SignPlus as u32) != 0 . } . . /// Determines if the `-` flag was specified. . /// . /// # Examples . /// . /// ``` . /// use std::fmt; -- line 1809 ---------------------------------------- -- line 1850 ---------------------------------------- . /// } . /// . /// assert_eq!(&format!("{:#}", Foo(23)), "Foo(23)"); . /// assert_eq!(&format!("{}", Foo(23)), "23"); . /// ``` . #[must_use] . #[stable(feature = "fmt_flags", since = "1.5.0")] . pub fn alternate(&self) -> bool { 313,984 ( 0.00%) self.flags & (1 << FlagV1::Alternate as u32) != 0 . } . . /// Determines if the `0` flag was specified. . /// . /// # Examples . /// . /// ``` . /// use std::fmt; -- line 1866 ---------------------------------------- -- line 1876 ---------------------------------------- . /// } . /// } . /// . /// assert_eq!(&format!("{:04}", Foo(23)), "23"); . /// ``` . #[must_use] . #[stable(feature = "fmt_flags", since = "1.5.0")] . pub fn sign_aware_zero_pad(&self) -> bool { 1,681 ( 0.00%) self.flags & (1 << FlagV1::SignAwareZeroPad as u32) != 0 . } . . // FIXME: Decide what public API we want for these two flags. . // https://github.com/rust-lang/rust/issues/48584 . fn debug_lower_hex(&self) -> bool { . self.flags & (1 << FlagV1::DebugLowerHex as u32) != 0 . } . -- line 1892 ---------------------------------------- -- line 2076 ---------------------------------------- . . #[stable(since = "1.2.0", feature = "formatter_write")] . impl Write for Formatter<'_> { . fn write_str(&mut self, s: &str) -> Result { . self.buf.write_str(s) . } . . fn write_char(&mut self, c: char) -> Result { 5,744 ( 0.00%) self.buf.write_char(c) . } . . fn write_fmt(&mut self, args: Arguments<'_>) -> Result { . write(self.buf, args) . } . } . . #[stable(feature = "rust1", since = "1.0.0")] -- line 2092 ---------------------------------------- -- line 2098 ---------------------------------------- . . // Implementations of the core formatting traits . . macro_rules! fmt_refs { . ($($tr:ident),*) => { . $( . #[stable(feature = "rust1", since = "1.0.0")] . impl $tr for &T { 379,322 ( 0.00%) fn fmt(&self, f: &mut Formatter<'_>) -> Result { $tr::fmt(&**self, f) } . } . #[stable(feature = "rust1", since = "1.0.0")] . impl $tr for &mut T { 3,000 ( 0.00%) fn fmt(&self, f: &mut Formatter<'_>) -> Result { $tr::fmt(&**self, f) } . } . )* . } . } . . fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp } . . #[unstable(feature = "never_type", issue = "35121")] -- line 2118 ---------------------------------------- -- line 2134 ---------------------------------------- . #[inline] . fn fmt(&self, f: &mut Formatter<'_>) -> Result { . Display::fmt(self, f) . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Display for bool { 2 ( 0.00%) fn fmt(&self, f: &mut Formatter<'_>) -> Result { 4 ( 0.00%) Display::fmt(if *self { "true" } else { "false" }, f) . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Debug for str { . fn fmt(&self, f: &mut Formatter<'_>) -> Result { . f.write_char('"')?; . let mut from = 0; -- line 2151 ---------------------------------------- -- line 2166 ---------------------------------------- . } . f.write_str(&self[from..])?; . f.write_char('"') . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Display for str { 1,196,541 ( 0.00%) fn fmt(&self, f: &mut Formatter<'_>) -> Result { 797,714 ( 0.00%) f.pad(self) . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Debug for char { . fn fmt(&self, f: &mut Formatter<'_>) -> Result { . f.write_char('\'')?; . for c in self.escape_debug_ext(EscapeDebugExtArgs { -- line 2183 ---------------------------------------- -- line 2188 ---------------------------------------- . f.write_char(c)? . } . f.write_char('\'') . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Display for char { 19 ( 0.00%) fn fmt(&self, f: &mut Formatter<'_>) -> Result { 38 ( 0.00%) if f.width.is_none() && f.precision.is_none() { 19 ( 0.00%) f.write_char(*self) . } else { . f.pad(self.encode_utf8(&mut [0; 4])) . } . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Pointer for *const T { -- line 2206 ---------------------------------------- 11,983,081 ( 0.04%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/library/core/src/slice/mod.rs -------------------------------------------------------------------------------- Ir -- line 141 ---------------------------------------- . /// ``` . /// let a = [1, 2, 3]; . /// assert!(!a.is_empty()); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_slice_is_empty", since = "1.39.0")] . #[inline] . pub const fn is_empty(&self) -> bool { 2,874,013 ( 0.01%) self.len() == 0 . } . . /// Returns the first element of the slice, or `None` if it is empty. . /// . /// # Examples . /// . /// ``` . /// let v = [10, 40, 30]; -- line 157 ---------------------------------------- -- line 159 ---------------------------------------- . /// . /// let w: &[i32] = &[]; . /// assert_eq!(None, w.first()); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")] . #[inline] . pub const fn first(&self) -> Option<&T> { 5,783 ( 0.00%) if let [first, ..] = self { Some(first) } else { None } . } . . /// Returns a mutable pointer to the first element of the slice, or `None` if it is empty. . /// . /// # Examples . /// . /// ``` . /// let x = &mut [0, 1, 2]; -- line 175 ---------------------------------------- -- line 178 ---------------------------------------- . /// *first = 5; . /// } . /// assert_eq!(x, &[5, 1, 2]); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")] . #[inline] . pub const fn first_mut(&mut self) -> Option<&mut T> { 1,864 ( 0.00%) if let [first, ..] = self { Some(first) } else { None } . } . . /// Returns the first and all the rest of the elements of the slice, or `None` if it is empty. . /// . /// # Examples . /// . /// ``` . /// let x = &[0, 1, 2]; -- line 194 ---------------------------------------- -- line 197 ---------------------------------------- . /// assert_eq!(first, &0); . /// assert_eq!(elements, &[1, 2]); . /// } . /// ``` . #[stable(feature = "slice_splits", since = "1.5.0")] . #[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")] . #[inline] . pub const fn split_first(&self) -> Option<(&T, &[T])> { 78 ( 0.00%) if let [first, tail @ ..] = self { Some((first, tail)) } else { None } . } . . /// Returns the first and all the rest of the elements of the slice, or `None` if it is empty. . /// . /// # Examples . /// . /// ``` . /// let x = &mut [0, 1, 2]; -- line 213 ---------------------------------------- -- line 237 ---------------------------------------- . /// assert_eq!(last, &2); . /// assert_eq!(elements, &[0, 1]); . /// } . /// ``` . #[stable(feature = "slice_splits", since = "1.5.0")] . #[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")] . #[inline] . pub const fn split_last(&self) -> Option<(&T, &[T])> { 31,250 ( 0.00%) if let [init @ .., last] = self { Some((last, init)) } else { None } . } . . /// Returns the last and all the rest of the elements of the slice, or `None` if it is empty. . /// . /// # Examples . /// . /// ``` . /// let x = &mut [0, 1, 2]; -- line 253 ---------------------------------------- -- line 276 ---------------------------------------- . /// . /// let w: &[i32] = &[]; . /// assert_eq!(None, w.last()); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")] . #[inline] . pub const fn last(&self) -> Option<&T> { 422,237 ( 0.00%) if let [.., last] = self { Some(last) } else { None } . } . . /// Returns a mutable pointer to the last item in the slice. . /// . /// # Examples . /// . /// ``` . /// let x = &mut [0, 1, 2]; -- line 292 ---------------------------------------- -- line 295 ---------------------------------------- . /// *last = 10; . /// } . /// assert_eq!(x, &[0, 1, 10]); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")] . #[inline] . pub const fn last_mut(&mut self) -> Option<&mut T> { 1,926,970 ( 0.01%) if let [.., last] = self { Some(last) } else { None } . } . . /// Returns a reference to an element or subslice depending on the type of . /// index. . /// . /// - If given a position, returns a reference to the element at that . /// position or `None` if out of bounds. . /// - If given a range, returns the subslice corresponding to that range, -- line 311 ---------------------------------------- -- line 448 ---------------------------------------- . /// } . /// ``` . /// . /// [`as_mut_ptr`]: slice::as_mut_ptr . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_slice_as_ptr", since = "1.32.0")] . #[inline] . pub const fn as_ptr(&self) -> *const T { 4,116,665 ( 0.01%) self as *const [T] as *const T . } . . /// Returns an unsafe mutable pointer to the slice's buffer. . /// . /// The caller must ensure that the slice outlives the pointer this . /// function returns, or else it will end up pointing to garbage. . /// . /// Modifying the container referenced by this slice may cause its buffer -- line 464 ---------------------------------------- -- line 476 ---------------------------------------- . /// } . /// } . /// assert_eq!(x, &[3, 4, 6]); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")] . #[inline] . pub const fn as_mut_ptr(&mut self) -> *mut T { 19 ( 0.00%) self as *mut [T] as *mut T . } . . /// Returns the two raw pointers spanning the slice. . /// . /// The returned range is half-open, which means that the end pointer . /// points *one past* the last element of the slice. This way, an empty . /// slice is represented by two equal pointers, and the difference between . /// the two pointers represents the size of the slice. -- line 492 ---------------------------------------- -- line 582 ---------------------------------------- . /// v.swap(2, 4); . /// assert!(v == ["a", "b", "e", "d", "c"]); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_unstable(feature = "const_swap", issue = "83163")] . #[inline] . #[track_caller] . pub const fn swap(&mut self, a: usize, b: usize) { 68,732 ( 0.00%) let _ = &self[a]; 200,971 ( 0.00%) let _ = &self[b]; . . // SAFETY: we just checked that both `a` and `b` are in bounds . unsafe { self.swap_unchecked(a, b) } . } . . /// Swaps two elements in the slice, without doing bounds checking. . /// . /// For a safe alternative see [`swap`]. -- line 599 ---------------------------------------- -- line 677 ---------------------------------------- . . // Because this function is first compiled in isolation, . // this check tells LLVM that the indexing below is . // in-bounds. Then after inlining -- once the actual . // lengths of the slices are known -- it's removed. . let (a, b) = (&mut a[..n], &mut b[..n]); . . for i in 0..n { 58,990 ( 0.00%) mem::swap(&mut a[i], &mut b[n - 1 - i]); . } . } . } . . /// Returns an iterator over the slice. . /// . /// # Examples . /// -- line 693 ---------------------------------------- -- line 1499 ---------------------------------------- . /// assert_eq!(left, [1, 2, 3, 4, 5, 6]); . /// assert_eq!(right, []); . /// } . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[inline] . #[track_caller] . pub fn split_at(&self, mid: usize) -> (&[T], &[T]) { 384 ( 0.00%) assert!(mid <= self.len()); . // SAFETY: `[ptr; mid]` and `[mid; len]` are inside `self`, which . // fulfills the requirements of `from_raw_parts_mut`. . unsafe { self.split_at_unchecked(mid) } . } . . /// Divides one mutable slice into two at an index. . /// . /// The first will contain all indices from `[0, mid)` (excluding -- line 1515 ---------------------------------------- -- line 1530 ---------------------------------------- . /// left[1] = 2; . /// right[1] = 4; . /// assert_eq!(v, [1, 2, 3, 4, 5, 6]); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[inline] . #[track_caller] . pub fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) { 55,282 ( 0.00%) assert!(mid <= self.len()); . // SAFETY: `[ptr; mid]` and `[mid; len]` are inside `self`, which . // fulfills the requirements of `from_raw_parts_mut`. . unsafe { self.split_at_mut_unchecked(mid) } . } . . /// Divides one slice into two at an index, without doing bounds checking. . /// . /// The first will contain all indices from `[0, mid)` (excluding -- line 1546 ---------------------------------------- -- line 1628 ---------------------------------------- . pub unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) { . let len = self.len(); . let ptr = self.as_mut_ptr(); . . // SAFETY: Caller has to check that `0 <= mid <= self.len()`. . // . // `[ptr; mid]` and `[mid; len]` are not overlapping, so returning a mutable reference . // is fine. 9,796 ( 0.00%) unsafe { (from_raw_parts_mut(ptr, mid), from_raw_parts_mut(ptr.add(mid), len - mid)) } . } . . /// Divides one slice into an array and a remainder slice at an index. . /// . /// The array will contain all indices from `[0, N)` (excluding . /// the index `N` itself) and the slice will contain all . /// indices from `[N, len)` (excluding the index `len` itself). . /// -- line 1644 ---------------------------------------- -- line 2113 ---------------------------------------- . /// assert!(!v.iter().any(|e| e == "hi")); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[inline] . pub fn contains(&self, x: &T) -> bool . where . T: PartialEq, . { 722 ( 0.00%) cmp::SliceContains::slice_contains(x, self) . } . . /// Returns `true` if `needle` is a prefix of the slice. . /// . /// # Examples . /// . /// ``` . /// let v = [10, 40, 30]; -- line 2129 ---------------------------------------- -- line 2142 ---------------------------------------- . /// assert!(v.starts_with(&[])); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn starts_with(&self, needle: &[T]) -> bool . where . T: PartialEq, . { . let n = needle.len(); 207,709 ( 0.00%) self.len() >= n && needle == &self[..n] . } . . /// Returns `true` if `needle` is a suffix of the slice. . /// . /// # Examples . /// . /// ``` . /// let v = [10, 40, 30]; -- line 2158 ---------------------------------------- -- line 2171 ---------------------------------------- . /// assert!(v.ends_with(&[])); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn ends_with(&self, needle: &[T]) -> bool . where . T: PartialEq, . { . let (m, n) = (self.len(), needle.len()); 1,217,348 ( 0.00%) m >= n && needle == &self[m - n..] . } . . /// Returns a subslice with the prefix removed. . /// . /// If the slice starts with `prefix`, returns the subslice after the prefix, wrapped in `Some`. . /// If `prefix` is empty, simply returns the original slice. . /// . /// If the slice does not start with `prefix`, returns `None`. -- line 2187 ---------------------------------------- -- line 2293 ---------------------------------------- . /// s.insert(idx, num); . /// assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn binary_search(&self, x: &T) -> Result . where . T: Ord, . { 3 ( 0.00%) self.binary_search_by(|p| p.cmp(x)) . } . . /// Binary searches this sorted slice with a comparator function. . /// . /// The comparator function should implement an order consistent . /// with the sort order of the underlying slice, returning an . /// order code that indicates whether its argument is `Less`, . /// `Equal` or `Greater` the desired target. -- line 2309 ---------------------------------------- -- line 2345 ---------------------------------------- . #[inline] . pub fn binary_search_by<'a, F>(&'a self, mut f: F) -> Result . where . F: FnMut(&'a T) -> Ordering, . { . let mut size = self.len(); . let mut left = 0; . let mut right = size; 23,010,421 ( 0.07%) while left < right { 40,303,099 ( 0.13%) let mid = left + size / 2; . . // SAFETY: the call is made safe by the following invariants: . // - `mid >= 0` . // - `mid < size`: `mid` is limited by `[left; right)` bound. 4,605,023 ( 0.01%) let cmp = f(unsafe { self.get_unchecked(mid) }); . . // The reason why we use if/else control flow rather than match . // is because match reorders comparison operations, which is perf sensitive. . // This is x86 asm for u8: https://rust.godbolt.org/z/8Y8Pra. 10,285,949 ( 0.03%) if cmp == Less { 23,572,201 ( 0.07%) left = mid + 1; 5,313,824 ( 0.02%) } else if cmp == Greater { . right = mid; . } else { . // SAFETY: same as the `get_unchecked` above . unsafe { crate::intrinsics::assume(mid < self.len()) }; . return Ok(mid); . } . 30,571,616 ( 0.10%) size = right - left; . } . Err(left) . } . . /// Binary searches this sorted slice with a key extraction function. . /// . /// Assumes that the slice is sorted by the key, for instance with . /// [`sort_by_key`] using the same key extraction function. -- line 2382 ---------------------------------------- -- line 3203 ---------------------------------------- . #[track_caller] . fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! { . panic!( . "source slice length ({}) does not match destination slice length ({})", . src_len, dst_len, . ); . } . 230,046 ( 0.00%) if self.len() != src.len() { . len_mismatch_fail(self.len(), src.len()); . } . . // SAFETY: `self` is valid for `self.len()` elements by definition, and `src` was . // checked to have the same length. The slices cannot overlap because . // mutable references are exclusive. . unsafe { . ptr::copy_nonoverlapping(src.as_ptr(), self.as_mut_ptr(), self.len()); -- line 3219 ---------------------------------------- -- line 3380 ---------------------------------------- . } . a << k . } . let gcd: usize = gcd(mem::size_of::(), mem::size_of::()); . let ts: usize = mem::size_of::() / gcd; . let us: usize = mem::size_of::() / gcd; . . // Armed with this knowledge, we can find how many `U`s we can fit! 6 ( 0.00%) let us_len = self.len() / ts * us; . // And how many `T`s will be in the trailing slice! 34,830 ( 0.00%) let ts_len = self.len() % ts; . (us_len, ts_len) . } . . /// Transmute the slice to a slice of another type, ensuring alignment of the types is . /// maintained. . /// . /// This method splits the slice into three distinct slices: prefix, correctly aligned middle . /// slice of a new type, and the suffix slice. The method may make the middle slice the greatest -- line 3398 ---------------------------------------- -- line 3429 ---------------------------------------- . return (self, &[], &[]); . } . . // First, find at what point do we split between the first and 2nd slice. Easy with . // ptr.align_offset. . let ptr = self.as_ptr(); . // SAFETY: See the `align_to_mut` method for the detailed safety comment. . let offset = unsafe { crate::ptr::align_offset(ptr, mem::align_of::()) }; 34,830 ( 0.00%) if offset > self.len() { . (self, &[], &[]) . } else { . let (left, rest) = self.split_at(offset); . let (us_len, ts_len) = rest.align_to_offsets::(); . // SAFETY: now `rest` is definitely aligned, so `from_raw_parts` below is okay, . // since the caller guarantees that we can transmute `T` to `U` safely. . unsafe { . ( . left, . from_raw_parts(rest.as_ptr() as *const U, us_len), 34,836 ( 0.00%) from_raw_parts(rest.as_ptr().add(rest.len() - ts_len), ts_len), . ) . } . } . } . . /// Transmute the slice to a slice of another type, ensuring alignment of the types is . /// maintained. . /// -- line 3456 ---------------------------------------- -- line 3731 ---------------------------------------- . /// let v = [1, 2, 3, 3, 5, 6, 7]; . /// let i = v.partition_point(|&x| x < 5); . /// . /// assert_eq!(i, 4); . /// assert!(v[..i].iter().all(|&x| x < 5)); . /// assert!(v[i..].iter().all(|&x| !(x < 5))); . /// ``` . #[stable(feature = "partition_point", since = "1.52.0")] 17 ( 0.00%) pub fn partition_point

(&self, mut pred: P) -> usize . where . P: FnMut(&T) -> bool, . { . self.binary_search_by(|x| if pred(x) { Less } else { Greater }).unwrap_or_else(|i| i) 34 ( 0.00%) } . . /// Removes the subslice corresponding to the given range . /// and returns a reference to it. . /// . /// Returns `None` and does not modify the slice if the given . /// range is out of bounds. . /// . /// Note that this method only accepts one-sided ranges such as -- line 3752 ---------------------------------------- 15,907,819 ( 0.05%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/rustc_entry.rs -------------------------------------------------------------------------------- Ir -- line 26 ---------------------------------------- . /// } . /// . /// assert_eq!(letters[&'s'], 2); . /// assert_eq!(letters[&'t'], 3); . /// assert_eq!(letters[&'u'], 1); . /// assert_eq!(letters.get(&'y'), None); . /// ``` . #[cfg_attr(feature = "inline-more", inline)] 25,979,920 ( 0.08%) pub fn rustc_entry(&mut self, key: K) -> RustcEntry<'_, K, V, A> { . let hash = make_insert_hash(&self.hash_builder, &key); 2,463 ( 0.00%) if let Some(elem) = self.table.find(hash, |q| q.0.eq(&key)) { 5,145,840 ( 0.02%) RustcEntry::Occupied(RustcOccupiedEntry { 1,817,271 ( 0.01%) key: Some(key), . elem, . table: &mut self.table, . }) . } else { . // Ideally we would put this in VacantEntry::insert, but Entry is not . // generic over the BuildHasher and adding a generic parameter would be . // a breaking change. . self.reserve(1); . 1,729,257 ( 0.01%) RustcEntry::Vacant(RustcVacantEntry { . hash, 851,670 ( 0.00%) key, . table: &mut self.table, . }) . } 22,222,567 ( 0.07%) } . } . . /// A view into a single entry in a map, which may either be vacant or occupied. . /// . /// This `enum` is constructed from the [`entry`] method on [`HashMap`]. . /// . /// [`HashMap`]: struct.HashMap.html . /// [`entry`]: struct.HashMap.html#method.rustc_entry -- line 62 ---------------------------------------- -- line 405 ---------------------------------------- . /// if let RustcEntry::Occupied(o) = map.rustc_entry("poneyland") { . /// *o.into_mut() += 10; . /// } . /// . /// assert_eq!(map["poneyland"], 22); . /// ``` . #[cfg_attr(feature = "inline-more", inline)] . pub fn into_mut(self) -> &'a mut V { 1,938,505 ( 0.01%) unsafe { &mut self.elem.as_mut().1 } . } . . /// Sets the value of the entry, and returns the entry's old value. . /// . /// # Examples . /// . /// ``` . /// use hashbrown::HashMap; -- line 421 ---------------------------------------- -- line 568 ---------------------------------------- . /// let mut map: HashMap<&str, u32> = HashMap::new(); . /// . /// if let RustcEntry::Vacant(o) = map.rustc_entry("poneyland") { . /// o.insert(37); . /// } . /// assert_eq!(map["poneyland"], 37); . /// ``` . #[cfg_attr(feature = "inline-more", inline)] 22,724 ( 0.00%) pub fn insert(self, value: V) -> &'a mut V { . unsafe { 188,063 ( 0.00%) let bucket = self.table.insert_no_grow(self.hash, (self.key, value)); 55,767 ( 0.00%) &mut bucket.as_mut().1 . } 28,732 ( 0.00%) } . . /// Sets the value of the entry with the RustcVacantEntry's key, . /// and returns a RustcOccupiedEntry. . /// . /// # Examples . /// . /// ``` . /// use hashbrown::HashMap; -- line 589 ---------------------------------------- 9,375,344 ( 0.03%) -------------------------------------------------------------------------------- -- 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 { 8,519,542 ( 0.03%) 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)); 497,735 ( 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::()); 146,504,882 ( 0.46%) 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,576,260 ( 0.00%) self.stride += Group::WIDTH; 1,576,260 ( 0.00%) self.pos += self.stride; 1,292,840 ( 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. 344,326 ( 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. 547,710 ( 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. 375,726 ( 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 { 970,881 ( 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. 472,247 ( 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 = 599,560 ( 0.00%) size.checked_mul(buckets)?.checked_add(ctrl_align - 1)? & !(ctrl_align - 1); 883,897 ( 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 { 1,762 ( 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 { 12,207 ( 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 { 220 ( 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 { 30,865 ( 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")] 47,919 ( 0.00%) pub unsafe fn erase_no_drop(&mut self, item: &Bucket) { 47,919 ( 0.00%) let index = self.bucket_index(item); . self.table.erase(index); 95,838 ( 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. 20,400 ( 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 { 75,438 ( 0.00%) self.erase_no_drop(&item); 252 ( 0.00%) item.read() . } . . /// Finds and removes an element from the table, returning it. . #[cfg_attr(feature = "inline-more", inline)] 2,022,394 ( 0.01%) pub fn remove_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option { . // Avoid `Option::map` because it bloats LLVM IR. 10,002 ( 0.00%) match self.find(hash, eq) { 9,318 ( 0.00%) Some(bucket) => Some(unsafe { self.remove(bucket) }), 177,465 ( 0.00%) None => None, . } 2,708,604 ( 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) { 40,506 ( 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,213,529 ( 0.00%) if additional > self.table.growth_left { . // Avoid `Result::unwrap_or_else` because it bloats LLVM IR. 567,676 ( 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,384,903 ( 0.00%) 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 . }, . ) . } 848,840 ( 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)] 12,121,124 ( 0.04%) 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. 12,985 ( 0.00%) let old_ctrl = *self.table.ctrl(index); 8,350,041 ( 0.03%) 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); 2 ( 0.00%) bucket.write(value); . bucket . } 8,996,946 ( 0.03%) } . . /// 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,189,576 ( 0.01%) pub fn insert_entry(&mut self, hash: u64, value: T, hasher: impl Fn(&T) -> u64) -> &mut T { 1,567 ( 0.00%) unsafe { self.insert(hash, value, hasher).as_mut() } 1,642,182 ( 0.01%) } . . /// 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"))] 5,232 ( 0.00%) pub unsafe fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket { 1,475,087 ( 0.00%) let (index, old_ctrl) = self.table.prepare_insert_slot(hash); 35,342 ( 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,001,476 ( 0.01%) self.table.growth_left -= special_is_empty(old_ctrl) as usize; . . bucket.write(value); 2,306,933 ( 0.01%) self.table.items += 1; . bucket 10,435 ( 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] 434,738 ( 0.00%) pub fn find(&self, hash: u64, mut eq: impl FnMut(&T) -> bool) -> Option> { 63,111 ( 0.00%) let result = self.table.find_inner(hash, &mut |index| unsafe { 220,553 ( 0.00%) eq(self.bucket(index).as_ref()) 15,260 ( 0.00%) }); . . // Avoid `Option::map` because it bloats LLVM IR. . match result { 7,592 ( 0.00%) Some(index) => Some(unsafe { self.bucket(index) }), . None => None, . } 496,726 ( 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. 137,420 ( 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] 76,765 ( 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. 215,420 ( 0.00%) match self.find(hash, eq) { . Some(bucket) => Some(unsafe { bucket.as_mut() }), . None => None, . } 88,148 ( 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 { 2,998,213 ( 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 { 7 ( 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()), 173,156 ( 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(); 8,592 ( 0.00%) let allocation = self.into_allocation(); 6,444 ( 0.00%) RawIntoIter { 10,740 ( 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)> { 3,888 ( 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(( 783 ( 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 { 1,562,084 ( 0.00%) 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)] 985,318 ( 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()); . } . 258,264 ( 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)); 544,350 ( 0.00%) Ok(Self { . ctrl, 262,932 ( 0.00%) bucket_mask: buckets - 1, . items: 0, . growth_left: bucket_mask_to_capacity(buckets - 1), . alloc, . }) 717,362 ( 0.00%) } . . #[inline] 83,047 ( 0.00%) fn fallible_with_capacity( . alloc: A, . table_layout: TableLayout, . capacity: usize, . fallibility: Fallibility, . ) -> Result { 21,070 ( 0.00%) if capacity == 0 { 21,465 ( 0.00%) Ok(Self::new_in(alloc)) . } else { . unsafe { . let buckets = . capacity_to_buckets(capacity).ok_or_else(|| fallibility.capacity_overflow())?; . 445,762 ( 0.00%) let result = Self::new_uninitialized(alloc, table_layout, buckets, fallibility)?; . result.ctrl(0).write_bytes(EMPTY, result.num_ctrl_bytes()); . 36,962 ( 0.00%) Ok(result) . } . } 83,047 ( 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] 492,526 ( 0.00%) unsafe fn prepare_insert_slot(&self, hash: u64) -> (usize, u8) { . let index = self.find_insert_slot(hash); 492,526 ( 0.00%) let old_ctrl = *self.ctrl(index); . self.set_ctrl_h2(index, hash); . (index, old_ctrl) 985,052 ( 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)); 5,589,422 ( 0.02%) if let Some(bit) = group.match_empty_or_deleted().lowest_set_bit() { 16,085,861 ( 0.05%) 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). 7,448,304 ( 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); . 467,868 ( 0.00%) loop { . let group = unsafe { Group::load(self.ctrl(probe_seq.pos)) }; . 17,403,164 ( 0.05%) for bit in group.match_byte(h2_hash) { 37,269,162 ( 0.12%) let index = (probe_seq.pos + bit) & self.bucket_mask; . 25,898,117 ( 0.08%) if likely(eq(index)) { . return Some(index); . } . } . 4,490,310 ( 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. 6 ( 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. 6 ( 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(); 21,290,600 ( 0.07%) 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 { 112,064,960 ( 0.35%) 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) { 10,490,569 ( 0.03%) self.growth_left -= special_is_empty(old_ctrl) as usize; . self.set_ctrl_h2(index, hash); 8,349,088 ( 0.03%) 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; 63 ( 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] | . // --------------------------------------------- 15,766,128 ( 0.05%) let index2 = ((index.wrapping_sub(Group::WIDTH)) & self.bucket_mask) + Group::WIDTH; . 5,246,332 ( 0.02%) *self.ctrl(index) = ctrl; 5,247,250 ( 0.02%) *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 { 654,756 ( 0.00%) self.bucket_mask + 1 . } . . #[inline] . fn num_ctrl_bytes(&self) -> usize { 528,849 ( 0.00%) self.bucket_mask + 1 + Group::WIDTH . } . . #[inline] . fn is_empty_singleton(&self) -> bool { 2,931,730 ( 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. 8,148 ( 0.00%) let mut new_table = RawTableInner::fallible_with_capacity( . self.alloc.clone(), . table_layout, . capacity, . fallibility, . )?; 373,385 ( 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_| { 168,716 ( 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. 337,438 ( 0.00%) let new_items = match self.items.checked_add(additional) { . Some(new_items) => new_items, . None => return Err(fallibility.capacity_overflow()), . }; 337,436 ( 0.00%) let full_capacity = bucket_mask_to_capacity(self.bucket_mask); 725,308 ( 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); 4 ( 0.00%) Ok(()) . } else { . // Otherwise, conservatively resize to at least the next size up . // to avoid churning deletes into frequent rehashes. . self.resize_inner( 168,716 ( 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> { 20,140 ( 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() { 3,158,510 ( 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); . 168,716 ( 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() { 128 ( 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. 21 ( 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; . } . } . } . 6 ( 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( 104,865 ( 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) { 16,829 ( 0.00%) if !self.is_empty_singleton() { . unsafe { . self.ctrl(0).write_bytes(EMPTY, self.num_ctrl_bytes()); . } . } 21,503 ( 0.00%) self.items = 0; 17,302 ( 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))); 405,726 ( 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,622,904 ( 0.01%) let ctrl = if empty_before.leading_zeros() + empty_after.trailing_zeros() >= Group::WIDTH { . DELETED . } else { 1,955,425 ( 0.01%) self.growth_left += 1; . EMPTY . }; . self.set_ctrl(index, ctrl); 1,622,904 ( 0.01%) self.items -= 1; . } . } . . impl Clone for RawTable { 32,568 ( 0.00%) fn clone(&self) -> Self { 4,153 ( 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) . } . } 36,639 ( 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; 88 ( 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)] 1,657,450 ( 0.01%) fn drop(&mut self) { 1,248,836 ( 0.00%) if !self.table.is_empty_singleton() { . unsafe { . self.drop_elements(); . self.free_buckets(); . } . } 1,741,186 ( 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)] 8,592 ( 0.00%) fn into_iter(self) -> RawIntoIter { . unsafe { . let iter = self.iter(); . self.into_iter_from(iter) . } 10,740 ( 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 { 801,129 ( 0.00%) if let Some(index) = self.current_group.lowest_set_bit() { 119,155 ( 0.00%) self.current_group = self.current_group.remove_lowest_bit(); 191,052 ( 0.00%) return Some(self.data.next_n(index)); . } . 434,165 ( 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). 21,742 ( 0.00%) self.current_group = Group::load_aligned(self.next_ctrl).match_full(); 17,128 ( 0.00%) self.data = self.data.next_n(Group::WIDTH); 47,066 ( 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) { 2,795 ( 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)] 111,086 ( 0.00%) fn next(&mut self) -> Option> { 401,248 ( 0.00%) if let Some(b) = self.iter.next() { 1,214,560 ( 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 . } 222,172 ( 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)] 3,884 ( 0.00%) fn drop(&mut self) { . unsafe { . // Drop all remaining elements . self.iter.drop_elements(); . . // Free the table 18,417 ( 0.00%) if let Some((ptr, layout)) = self.allocation { . self.alloc.deallocate(ptr, layout); . } . } 424 ( 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)] 13,337 ( 0.00%) fn next(&mut self) -> Option { 1,158 ( 0.00%) unsafe { Some(self.iter.next()?.read()) } 38,813 ( 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)] 2,952 ( 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. 369 ( 0.00%) self.orig_table . .as_ptr() . .copy_from_nonoverlapping(&*self.table, 1); . } 2,952 ( 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 ---------------------------------------- 52,527,917 ( 0.16%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/library/core/src/str/lossy.rs -------------------------------------------------------------------------------- Ir -- line 8 ---------------------------------------- . /// Lossy UTF-8 string. . #[unstable(feature = "str_internals", issue = "none")] . pub struct Utf8Lossy { . bytes: [u8], . } . . impl Utf8Lossy { . #[must_use] 145,492 ( 0.00%) pub fn from_bytes(bytes: &[u8]) -> &Utf8Lossy { . // SAFETY: Both use the same memory layout, and UTF-8 correctness isn't required. . unsafe { mem::transmute(bytes) } 72,746 ( 0.00%) } . 145,486 ( 0.00%) pub fn chunks(&self) -> Utf8LossyChunksIter<'_> { . Utf8LossyChunksIter { source: &self.bytes } 72,743 ( 0.00%) } . } . . /// Iterator over lossy UTF-8 string . #[must_use = "iterators are lazy and do nothing unless consumed"] . #[unstable(feature = "str_internals", issue = "none")] . #[allow(missing_debug_implementations)] . pub struct Utf8LossyChunksIter<'a> { . source: &'a [u8], -- line 31 ---------------------------------------- -- line 40 ---------------------------------------- . /// Single broken char, empty if none. . /// Empty iff iterator item is last. . pub broken: &'a [u8], . } . . impl<'a> Iterator for Utf8LossyChunksIter<'a> { . type Item = Utf8LossyChunk<'a>; . 218,238 ( 0.00%) fn next(&mut self) -> Option> { 145,492 ( 0.00%) if self.source.is_empty() { . return None; . } . . const TAG_CONT_U8: u8 = 128; . fn safe_get(xs: &[u8], i: usize) -> u8 { . *xs.get(i).unwrap_or(&0) . } . . let mut i = 0; . let mut valid_up_to = 0; 12,014,996 ( 0.04%) while i < self.source.len() { . // SAFETY: `i < self.source.len()` per previous line. . // For some reason the following are both significantly slower: . // while let Some(&byte) = self.source.get(i) { . // while let Some(byte) = self.source.get(i).copied() { 6,007,498 ( 0.02%) let byte = unsafe { *self.source.get_unchecked(i) }; 6,007,498 ( 0.02%) i += 1; . 12,014,996 ( 0.04%) if byte < 128 { . // This could be a `1 => ...` case in the match below, but for . // the common case of all-ASCII inputs, we bypass loading the . // sizeable UTF8_CHAR_WIDTH table into cache. . } else { . let w = utf8_char_width(byte); . . match w { . 2 => { -- line 76 ---------------------------------------- -- line 121 ---------------------------------------- . // via `i += 1` and in between every single one of those increments, `i` . // is compared against `self.source.len()`. That happens either . // literally by `i < self.source.len()` in the while-loop's condition, . // or indirectly by `safe_get(self.source, i) & 192 != TAG_CONT_U8`. The . // loop is terminated as soon as the latest `i += 1` has made `i` no . // longer less than `self.source.len()`, which means it'll be at most . // equal to `self.source.len()`. . let (inspected, remaining) = unsafe { self.source.split_at_unchecked(i) }; 145,492 ( 0.00%) self.source = remaining; . . // SAFETY: `valid_up_to <= i` because it is only ever assigned via . // `valid_up_to = i` and `i` only increases. . let (valid, broken) = unsafe { inspected.split_at_unchecked(valid_up_to) }; . 363,730 ( 0.00%) Some(Utf8LossyChunk { . // SAFETY: All bytes up to `valid_up_to` are valid UTF-8. . valid: unsafe { from_utf8_unchecked(valid) }, . broken, . }) 363,730 ( 0.00%) } . } . . impl fmt::Display for Utf8Lossy { 24 ( 0.00%) fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { . // If we're the empty string then our iterator won't actually yield . // anything, so perform the formatting manually 3 ( 0.00%) if self.bytes.is_empty() { . return "".fmt(f); . } . 33 ( 0.00%) for Utf8LossyChunk { valid, broken } in self.chunks() { . // If we successfully decoded the whole chunk as a valid string then . // we can return a direct formatting of the string which will also . // respect various formatting flags if possible. 6 ( 0.00%) if valid.len() == self.bytes.len() { 3 ( 0.00%) assert!(broken.is_empty()); . return valid.fmt(f); . } . . f.write_str(valid)?; . if !broken.is_empty() { . f.write_char(char::REPLACEMENT_CHARACTER)?; . } . } . Ok(()) 27 ( 0.00%) } . } . . impl fmt::Debug for Utf8Lossy { . fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { . f.write_char('"')?; . . for Utf8LossyChunk { valid, broken } in self.chunks() { . // Valid part. -- line 174 ---------------------------------------- 6,371,237 ( 0.02%) -------------------------------------------------------------------------------- -- 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)] 303 ( 0.00%) #[derive(HashStable, TypeFoldable, Lift)] . pub struct TypeAndMut<'tcx> { 48,448 ( 0.00%) pub ty: Ty<'tcx>, 242,240 ( 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 { 27,952 ( 0.00%) pub scope: DefId, 45,491 ( 0.00%) pub bound_region: BoundRegionKind, . } . 997,369 ( 0.00%) #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)] 1,403 ( 0.00%) #[derive(HashStable)] . pub enum BoundRegionKind { . /// An anonymous region parameter for a given fn (&T) 108,220 ( 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,084 ( 0.00%) BrNamed(DefId, Symbol), . . /// Anonymous region for the implicit env pointer parameter . /// to a closure . BrEnv, . } . 2,455 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, PartialOrd, Ord)] . #[derive(HashStable)] . pub struct BoundRegion { 201,567 ( 0.00%) pub var: BoundVar, 164,667 ( 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. 43,079,896 ( 0.13%) #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable, Debug)] 1,771,369 ( 0.01%) #[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. 7,496,762 ( 0.02%) 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]`. 27,190 ( 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,584,891 ( 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`. 160,295 ( 0.00%) 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`. 229,724 ( 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. 2,636 ( 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. 36 ( 0.00%) pub fn new( . tcx: TyCtxt<'tcx>, . parts: ClosureSubstsParts<'tcx, Ty<'tcx>>, . ) -> ClosureSubsts<'tcx> { . ClosureSubsts { . substs: tcx.mk_substs( 72 ( 0.00%) parts.parent_substs.iter().copied().chain( 144 ( 0.00%) [parts.closure_kind_ty, parts.closure_sig_as_fn_ptr_ty, parts.tupled_upvars_ty] . .iter() . .map(|&ty| ty.into()), . ), . ), . } 72 ( 0.00%) } . . /// Divides the closure substs into their respective components. . /// The ordering assumed here must match that used by `ClosureSubsts::new` above. 11,336 ( 0.00%) fn split(self) -> ClosureSubstsParts<'tcx, GenericArg<'tcx>> { . match self.substs[..] { 55,772 ( 0.00%) [ 15,990 ( 0.00%) ref parent_substs @ .., 17,012 ( 0.00%) closure_kind_ty, 5,444 ( 0.00%) closure_sig_as_fn_ptr_ty, 16,770 ( 0.00%) tupled_upvars_ty, 45,344 ( 0.00%) ] => ClosureSubstsParts { . parent_substs, . closure_kind_ty, . closure_sig_as_fn_ptr_ty, . tupled_upvars_ty, . }, . _ => bug!("closure substs missing synthetics"), . } 34,008 ( 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] 10,956 ( 0.00%) pub fn upvar_tys(self) -> impl Iterator> + 'tcx { 9,514 ( 0.00%) match self.tupled_upvars_ty().kind() { . TyKind::Error(_) => None, 5,088 ( 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() 7,304 ( 0.00%) } . . /// Returns the tuple type representing the upvars for this closure. . #[inline] . pub fn tupled_upvars_ty(self) -> Ty<'tcx> { 63,902 ( 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)`. 2,276 ( 0.00%) pub fn kind_ty(self) -> Ty<'tcx> { . self.split().closure_kind_ty.expect_ty() 4,552 ( 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`. . pub fn sig_as_fn_ptr_ty(self) -> Ty<'tcx> { . self.split().closure_sig_as_fn_ptr_ty.expect_ty() . } . . /// 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()`. 8 ( 0.00%) pub fn kind(self) -> ty::ClosureKind { 558 ( 0.00%) self.kind_ty().to_opt_closure_kind().unwrap() 16 ( 0.00%) } . . /// Extracts the signature from the closure. 3,117 ( 0.00%) pub fn sig(self) -> ty::PolyFnSig<'tcx> { . let ty = self.sig_as_fn_ptr_ty(); 6,234 ( 0.00%) match ty.kind() { 12,468 ( 0.00%) ty::FnPtr(sig) => *sig, . _ => bug!("closure_sig_as_fn_ptr_ty is not a fn-ptr: {:?}", ty.kind()), . } 9,351 ( 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. 2,887 ( 0.00%) fn split(self) -> GeneratorSubstsParts<'tcx, GenericArg<'tcx>> { . match self.substs[..] { 26,374 ( 0.00%) [ref parent_substs @ .., resume_ty, yield_ty, return_ty, witness, tupled_upvars_ty] => { 14,435 ( 0.00%) GeneratorSubstsParts { . parent_substs, . resume_ty, . yield_ty, . return_ty, . witness, . tupled_upvars_ty, . } . } . _ => bug!("generator substs missing synthetics"), . } 8,661 ( 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. 220 ( 0.00%) pub fn witness(self) -> Ty<'tcx> { . self.split().witness.expect_ty() 440 ( 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] 294 ( 0.00%) pub fn upvar_tys(self) -> impl Iterator> + 'tcx { 4,161 ( 0.00%) match self.tupled_upvars_ty().kind() { . TyKind::Error(_) => None, 2,620 ( 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() 196 ( 0.00%) } . . /// Returns the tuple type representing the upvars for this generator. . #[inline] . pub fn tupled_upvars_ty(self) -> Ty<'tcx> { 10,386 ( 0.00%) self.split().tupled_upvars_ty.expect_ty() . } . . /// Returns the type representing the resume type of the generator. 24 ( 0.00%) pub fn resume_ty(self) -> Ty<'tcx> { . self.split().resume_ty.expect_ty() 48 ( 0.00%) } . . /// Returns the type representing the yield type of the generator. 15 ( 0.00%) pub fn yield_ty(self) -> Ty<'tcx> { . self.split().yield_ty.expect_ty() 30 ( 0.00%) } . . /// Returns the type representing the return type of the generator. 15 ( 0.00%) pub fn return_ty(self) -> Ty<'tcx> { . self.split().return_ty.expect_ty() 30 ( 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. 2,636 ( 0.00%) pub fn poly_sig(self) -> PolyGenSig<'tcx> { 693 ( 0.00%) ty::Binder::dummy(self.sig()) 2,636 ( 0.00%) } . . /// Returns the "generator signature", which consists of its resume, yield . /// and return types. 702 ( 0.00%) pub fn sig(self) -> GenSig<'tcx> { 2,106 ( 0.00%) ty::GenSig { . resume_ty: self.resume_ty(), . yield_ty: self.yield_ty(), . return_ty: self.return_ty(), . } 2,106 ( 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 2,898 ( 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. 160 ( 0.00%) assert!(self.variant_range(def_id, tcx).contains(&variant_index)); 320 ( 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`. 4,197 ( 0.00%) pub fn variant_name(v: VariantIdx) -> Cow<'static, str> { 6,678 ( 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), 3,787 ( 0.00%) _ => Cow::from(format!("Suspend{}", v.as_usize() - 3)), . } 5,596 ( 0.00%) } . . /// The type of the state discriminant used in the generator type. . #[inline] . pub fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { 488 ( 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>> { 15,732 ( 0.00%) let layout = tcx.generator_layout(def_id).unwrap(); . layout.variant_fields.iter().map(move |variant| { 35,136 ( 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] 7,458 ( 0.00%) pub fn prefix_tys(self) -> impl Iterator> { . self.upvar_tys() 5,084 ( 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 { 124 ( 0.00%) let tupled_tys = match self { 124 ( 0.00%) UpvarSubsts::Closure(substs) => substs.as_closure().tupled_upvars_ty(), 45 ( 0.00%) UpvarSubsts::Generator(substs) => substs.as_generator().tupled_upvars_ty(), . }; . 276 ( 0.00%) match tupled_tys.kind() { . TyKind::Error(_) => None, 231 ( 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> { 214 ( 0.00%) match self { 169 ( 0.00%) UpvarSubsts::Closure(substs) => substs.as_closure().tupled_upvars_ty(), 73 ( 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() . } . } . 738,918 ( 0.00%) #[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, TyEncodable, TyDecodable)] 267,856 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub enum ExistentialPredicate<'tcx> { . /// E.g., `Iterator`. . Trait(ExistentialTraitRef<'tcx>), . /// E.g., `Iterator::Item = T`. . Projection(ExistentialProjection<'tcx>), . /// E.g., `Send`. 36,305 ( 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. 193,960 ( 0.00%) pub fn stable_cmp(&self, tcx: TyCtxt<'tcx>, other: &Self) -> Ordering { . use self::ExistentialPredicate::*; 287,620 ( 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, . } 232,752 ( 0.00%) } . } . . impl<'tcx> Binder<'tcx, ExistentialPredicate<'tcx>> { 11,565 ( 0.00%) pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> { . use crate::ty::ToPredicate; 9,153 ( 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) => { 58 ( 0.00%) self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx) . } . ExistentialPredicate::AutoTrait(did) => { 1,872 ( 0.00%) let trait_ref = self.rebind(ty::TraitRef { . def_id: did, . substs: tcx.mk_substs_trait(self_ty, &[]), . }); . trait_ref.without_const().to_predicate(tcx) . } . } 10,280 ( 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. 5,260 ( 0.00%) pub fn principal(&self) -> Option>> { 30,821 ( 0.00%) self[0] 10,231 ( 0.00%) .map_bound(|this| match this { . ExistentialPredicate::Trait(tr) => Some(tr), . _ => None, 21,040 ( 0.00%) }) . .transpose() 15,780 ( 0.00%) } . 741 ( 0.00%) pub fn principal_def_id(&self) -> Option { . self.principal().map(|trait_ref| trait_ref.skip_binder().def_id) 1,482 ( 0.00%) } . . #[inline] . pub fn projection_bounds<'a>( . &'a self, . ) -> impl Iterator>> + 'a { . self.iter().filter_map(|predicate| { 750 ( 0.00%) predicate 46,520 ( 0.00%) .map_bound(|pred| match pred { 3,737 ( 0.00%) ExistentialPredicate::Projection(projection) => Some(projection), . _ => None, . }) . .transpose() . }) . } . . #[inline] . pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { 179 ( 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,183 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 1,523,481 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct TraitRef<'tcx> { 89,196 ( 0.00%) pub def_id: DefId, 1,431,157 ( 0.00%) pub substs: SubstsRef<'tcx>, . } . . impl<'tcx> TraitRef<'tcx> { 1,478 ( 0.00%) pub fn new(def_id: DefId, substs: SubstsRef<'tcx>) -> TraitRef<'tcx> { . TraitRef { def_id, substs } 5,912 ( 0.00%) } . . /// Returns a `TraitRef` of the form `P0: Foo` where `Pi` . /// are the parameters defined on trait. 3,492 ( 0.00%) pub fn identity(tcx: TyCtxt<'tcx>, def_id: DefId) -> Binder<'tcx, TraitRef<'tcx>> { 1,552 ( 0.00%) ty::Binder::dummy(TraitRef { . def_id, 2,328 ( 0.00%) substs: InternalSubsts::identity_for_item(tcx, def_id), . }) 3,104 ( 0.00%) } . . #[inline] 6 ( 0.00%) pub fn self_ty(&self) -> Ty<'tcx> { . self.substs.type_at(0) 4 ( 0.00%) } . 26,328 ( 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); . 3,291 ( 0.00%) ty::TraitRef { def_id: trait_id, substs: tcx.intern_substs(&substs[..defs.params.len()]) } 36,201 ( 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 { 9,609 ( 0.00%) self.skip_binder().def_id 3,203 ( 0.00%) } . 10,793 ( 0.00%) pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> { 21,586 ( 0.00%) self.map_bound(|trait_ref| ty::TraitPredicate { . trait_ref, . constness: ty::BoundConstness::NotConst, . polarity: ty::ImplPolarity::Positive, . }) 10,793 ( 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). 4,653 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 64,700 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct ExistentialTraitRef<'tcx> { 15,486 ( 0.00%) pub def_id: DefId, 92,497 ( 0.00%) pub substs: SubstsRef<'tcx>, . } . . impl<'tcx> ExistentialTraitRef<'tcx> { 2,752 ( 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..]), . } 2,752 ( 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. 620 ( 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()); . 310 ( 0.00%) ty::TraitRef { def_id: self.def_id, substs: tcx.mk_substs_trait(self_ty, self.substs) } 1,550 ( 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. 2,238 ( 0.00%) pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> { 3,126 ( 0.00%) self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty)) 2,984 ( 0.00%) } . } . 298,162 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] 1,521 ( 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. 423,912 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 1,048,193 ( 0.00%) 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. 32,951 ( 0.00%) pub fn dummy(value: T) -> Binder<'tcx, T> { 101,556 ( 0.00%) assert!(!value.has_escaping_bound_vars()); 274,668 ( 0.00%) Binder(value, ty::List::empty()) 32,750 ( 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); . } 92,582 ( 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 { 2,340,164 ( 0.01%) self.0 . } . . pub fn bound_vars(&self) -> &'tcx List { 4,779 ( 0.00%) self.1 . } . . pub fn as_ref(&self) -> Binder<'tcx, &T> { 12,777 ( 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) . } . 3,643 ( 0.00%) pub fn map_bound>(self, f: F) -> Binder<'tcx, U> . where . F: FnOnce(T) -> U, . { 195,993 ( 0.00%) let value = f(self.0); . if cfg!(debug_assertions) { . let mut validator = ValidateBoundVars::new(self.1); . value.visit_with(&mut validator); . } 454,264 ( 0.00%) Binder(value, self.1) 4,230 ( 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); . } 59,808 ( 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); . } 51,287 ( 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>, . { 260,083 ( 0.00%) if self.0.has_escaping_bound_vars() { None } else { Some(self.skip_binder()) } 570 ( 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`. 3,719 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] 173,551 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct ProjectionTy<'tcx> { . /// The parameters of the associated item. 126,332 ( 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`. 147,188 ( 0.00%) pub item_def_id: DefId, . } . . impl<'tcx> ProjectionTy<'tcx> { 57,036 ( 0.00%) pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId { 16,296 ( 0.00%) tcx.associated_item(self.item_def_id).container.id() 65,184 ( 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 6,671 ( 0.00%) pub fn trait_ref_and_own_substs( . &self, . tcx: TyCtxt<'tcx>, . ) -> (ty::TraitRef<'tcx>, &'tcx [ty::GenericArg<'tcx>]) { 2,859 ( 0.00%) let def_id = tcx.associated_item(self.item_def_id).container.id(); . let trait_generics = tcx.generics_of(def_id); 4,765 ( 0.00%) ( . ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, trait_generics) }, . &self.substs[trait_generics.count()..], . ) 8,577 ( 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. 72,855 ( 0.00%) pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> { 8,095 ( 0.00%) let def_id = self.trait_def_id(tcx); 8,095 ( 0.00%) ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, tcx.generics_of(def_id)) } 89,045 ( 0.00%) } . 17,077 ( 0.00%) pub fn self_ty(&self) -> Ty<'tcx> { 51,231 ( 0.00%) self.substs.type_at(0) 34,154 ( 0.00%) } . } . 2,922 ( 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. 204,035 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 175,812 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct FnSig<'tcx> { 21,888 ( 0.00%) pub inputs_and_output: &'tcx List>, 189,413 ( 0.00%) pub c_variadic: bool, 46,218 ( 0.00%) pub unsafety: hir::Unsafety, 124,134 ( 0.00%) pub abi: abi::Abi, . } . . impl<'tcx> FnSig<'tcx> { 106,393 ( 0.00%) pub fn inputs(&self) -> &'tcx [Ty<'tcx>] { 484,323 ( 0.00%) &self.inputs_and_output[..self.inputs_and_output.len() - 1] 212,786 ( 0.00%) } . 55,017 ( 0.00%) pub fn output(&self) -> Ty<'tcx> { 479,807 ( 0.00%) self.inputs_and_output[self.inputs_and_output.len() - 1] 110,034 ( 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>]> { 28,999 ( 0.00%) self.map_bound_ref_unchecked(|fn_sig| fn_sig.inputs()) . } . #[inline] . pub fn input(&self, index: usize) -> ty::Binder<'tcx, Ty<'tcx>> { 8,286 ( 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) 431 ( 0.00%) } . #[inline] . pub fn output(&self) -> ty::Binder<'tcx, Ty<'tcx>> { 5,466 ( 0.00%) self.map_bound_ref(|fn_sig| fn_sig.output()) . } . pub fn c_variadic(&self) -> bool { 860 ( 0.00%) self.skip_binder().c_variadic 430 ( 0.00%) } . pub fn unsafety(&self) -> hir::Unsafety { 3,526 ( 0.00%) self.skip_binder().unsafety 1,763 ( 0.00%) } . pub fn abi(&self) -> abi::Abi { 218,692 ( 0.00%) self.skip_binder().abi 54,673 ( 0.00%) } . } . . pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder<'tcx, FnSig<'tcx>>>; . 164 ( 0.00%) #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] 2,870 ( 0.00%) #[derive(HashStable)] . pub struct ParamTy { 326 ( 0.00%) pub index: u32, . pub name: Symbol, . } . . impl<'tcx> ParamTy { 232 ( 0.00%) pub fn new(index: u32, name: Symbol) -> ParamTy { . ParamTy { index, name } 116 ( 0.00%) } . . pub fn for_def(def: &ty::GenericParamDef) -> ParamTy { 74 ( 0.00%) ParamTy::new(def.index, def.name) 37 ( 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)] 41 ( 0.00%) #[derive(HashStable)] . pub struct ParamConst { 278 ( 0.00%) pub index: u32, 278 ( 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 6,601,083 ( 0.02%) #[derive(Clone, PartialEq, Eq, Hash, Copy, TyEncodable, TyDecodable, PartialOrd, Ord)] 31,800 ( 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. 328,404 ( 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, . } . 38,640 ( 0.00%) #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, PartialOrd, Ord)] . pub struct EarlyBoundRegion { 1,990 ( 0.00%) pub def_id: DefId, 19,524 ( 0.00%) pub index: u32, 17,018 ( 0.00%) pub name: Symbol, . } . . /// A **`const`** **v**ariable **ID**. . #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] . pub struct ConstVid<'tcx> { 1,439 ( 0.00%) pub index: u32, 395 ( 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, 2,636 ( 0.00%) pub kind: BoundTyKind, . } . 44,914 ( 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`. 188 ( 0.00%) #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] 10,275 ( 0.00%) #[derive(HashStable, TypeFoldable)] . pub struct ExistentialProjection<'tcx> { 3,518 ( 0.00%) pub item_def_id: DefId, 14,152 ( 0.00%) pub substs: SubstsRef<'tcx>, 3,448 ( 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. 637 ( 0.00%) pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::ExistentialTraitRef<'tcx> { 273 ( 0.00%) let def_id = tcx.associated_item(self.item_def_id).container.id(); 182 ( 0.00%) let subst_count = tcx.generics_of(def_id).count() - 1; 91 ( 0.00%) let substs = tcx.intern_substs(&self.substs[..subst_count]); . ty::ExistentialTraitRef { def_id, substs } 819 ( 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, . } . } . 90 ( 0.00%) pub fn erase_self_ty( . tcx: TyCtxt<'tcx>, . projection_predicate: ty::ProjectionPredicate<'tcx>, . ) -> Self { . // Assert there is a Self. 54 ( 0.00%) projection_predicate.projection_ty.substs.type_at(0); . 72 ( 0.00%) Self { 36 ( 0.00%) item_def_id: projection_predicate.projection_ty.item_def_id, . substs: tcx.intern_substs(&projection_predicate.projection_ty.substs[1..]), 18 ( 0.00%) term: projection_predicate.term, . } 126 ( 0.00%) } . } . . impl<'tcx> PolyExistentialProjection<'tcx> { 310 ( 0.00%) pub fn with_self_ty( . &self, . tcx: TyCtxt<'tcx>, . self_ty: Ty<'tcx>, . ) -> ty::PolyProjectionPredicate<'tcx> { 310 ( 0.00%) self.map_bound(|p| p.with_self_ty(tcx, self_ty)) 372 ( 0.00%) } . . pub fn item_def_id(&self) -> DefId { 170 ( 0.00%) self.skip_binder().item_def_id 85 ( 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 { 3,117 ( 0.00%) matches!(*self, ty::ReLateBound(..)) . } . . #[inline] . pub fn is_placeholder(&self) -> bool { 19 ( 0.00%) matches!(*self, ty::RePlaceholder(..)) . } . . #[inline] . pub fn bound_at_or_above_binder(&self, index: ty::DebruijnIndex) -> bool { 113,240 ( 0.00%) match *self { . ty::ReLateBound(debruijn, _) => debruijn >= index, . _ => false, . } . } . . pub fn type_flags(&self) -> TypeFlags { . let mut flags = TypeFlags::empty(); . 305,910 ( 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 21,281 ( 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 { 9,650 ( 0.00%) match self.kind() { 905 ( 0.00%) Tuple(ref tys) => tys.is_empty(), . _ => false, . } . } . . #[inline] . pub fn is_never(&self) -> bool { 27,551 ( 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 { 56,588 ( 0.00%) matches!(self.kind(), Infer(TyVar(_))) . } . . #[inline] . pub fn ty_vid(&self) -> Option { 47,404 ( 0.00%) match self.kind() { 6,025 ( 0.00%) &Infer(TyVar(vid)) => Some(vid), . _ => None, . } . } . . #[inline] . pub fn is_ty_infer(&self) -> bool { 135 ( 0.00%) matches!(self.kind(), Infer(_)) . } . . #[inline] . pub fn is_phantom_data(&self) -> bool { 5 ( 0.00%) if let Adt(def, _) = self.kind() { def.is_phantom_data() } else { false } . } . . #[inline] . pub fn is_bool(&self) -> bool { . *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 { 635 ( 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 { 140 ( 0.00%) matches!(self.kind(), Array(..)) . } . . #[inline] . pub fn is_simd(&self) -> bool { 4 ( 0.00%) match self.kind() { 2 ( 0.00%) Adt(def, _) => def.repr.simd(), . _ => false, . } . } . 168 ( 0.00%) pub fn sequence_element_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { 336 ( 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), . } 168 ( 0.00%) } . . pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) { . match self.kind() { . Adt(def, substs) => { . assert!(def.repr.simd(), "`simd_size_and_type` called on non-SIMD type"); . let variant = def.non_enum_variant(); . let f0_ty = variant.fields[0].ty(tcx, substs); . -- line 1824 ---------------------------------------- -- line 1838 ---------------------------------------- . } . } . _ => bug!("`simd_size_and_type` called on invalid type"), . } . } . . #[inline] . pub fn is_region_ptr(&self) -> bool { 4 ( 0.00%) matches!(self.kind(), Ref(..)) . } . . #[inline] . pub fn is_mutable_ptr(&self) -> bool { . matches!( . self.kind(), . RawPtr(TypeAndMut { mutbl: hir::Mutability::Mut, .. }) . | Ref(_, _, hir::Mutability::Mut) -- line 1854 ---------------------------------------- -- line 1861 ---------------------------------------- . match self.kind() { . Ref(_, _, mutability) => Some(*mutability), . _ => None, . } . } . . #[inline] . pub fn is_unsafe_ptr(&self) -> bool { 25,357 ( 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 { 12 ( 0.00%) self.is_region_ptr() || self.is_unsafe_ptr() || self.is_fn_ptr() . } . . #[inline] . pub fn is_box(&self) -> bool { 36,446 ( 0.00%) match self.kind() { 10,062 ( 0.00%) Adt(def, _) => def.is_box(), . _ => false, . } . } . . /// Panics if called on any type other than `Box`. 8,330 ( 0.00%) pub fn boxed_ty(&self) -> Ty<'tcx> { 8,330 ( 0.00%) match self.kind() { 20,825 ( 0.00%) Adt(def, substs) if def.is_box() => substs.type_at(0), . _ => bug!("`boxed_ty` is called on non-box type {:?}", self), . } 8,330 ( 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 { 308 ( 0.00%) matches!( 701 ( 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 { 7,232 ( 0.00%) matches!(self.kind(), Float(_) | Infer(FloatVar(_))) . } . . #[inline] . pub fn is_trait(&self) -> bool { 3,898 ( 0.00%) matches!(self.kind(), Dynamic(..)) . } . . #[inline] . pub fn is_enum(&self) -> bool { 1,704 ( 0.00%) matches!(self.kind(), Adt(adt_def, _) if adt_def.is_enum()) . } . . #[inline] . pub fn is_union(&self) -> bool { 7,621 ( 0.00%) matches!(self.kind(), Adt(adt_def, _) if adt_def.is_union()) . } . . #[inline] . pub fn is_closure(&self) -> bool { 1,542 ( 0.00%) matches!(self.kind(), Closure(..)) . } . . #[inline] . pub fn is_generator(&self) -> bool { 3,162 ( 0.00%) matches!(self.kind(), Generator(..)) . } . . #[inline] . pub fn is_integral(&self) -> bool { 5,187 ( 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 { 13,564 ( 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 { 1,795 ( 0.00%) matches!(self.kind(), Int(_)) . } . . #[inline] . pub fn is_ptr_sized_integral(&self) -> bool { 165 ( 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. 34,570 ( 0.00%) pub fn builtin_deref(&self, explicit: bool) -> Option> { 222,495 ( 0.00%) match self.kind() { 9,582 ( 0.00%) Adt(def, _) if def.is_box() => { 2,499 ( 0.00%) Some(TypeAndMut { ty: self.boxed_ty(), mutbl: hir::Mutability::Not }) . } 80,476 ( 0.00%) Ref(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl: *mutbl }), 30,528 ( 0.00%) RawPtr(mt) if explicit => Some(*mt), . _ => None, . } 69,140 ( 0.00%) } . . /// Returns the type of `ty[i]`. . pub fn builtin_index(&self) -> Option> { 452 ( 0.00%) match self.kind() { . Array(ty, _) | Slice(ty) => Some(ty), . _ => None, . } 8 ( 0.00%) } . 519,984 ( 0.00%) pub fn fn_sig(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { 259,992 ( 0.00%) match self.kind() { 193,782 ( 0.00%) FnDef(def_id, substs) => tcx.fn_sig(*def_id).subst(tcx, substs), 2,020 ( 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), . } 584,982 ( 0.00%) } . . #[inline] . pub fn is_fn(&self) -> bool { 80,259 ( 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 { 6 ( 0.00%) matches!(self.kind(), Opaque(..)) . } . . #[inline] . pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> { 13,817 ( 0.00%) match self.kind() { . Adt(adt, _) => Some(adt), . _ => None, . } . } . . /// Iterates over tuple fields. . /// Panics when called on anything but a tuple. 4,378 ( 0.00%) pub fn tuple_fields(&self) -> impl DoubleEndedIterator> { 11,924 ( 0.00%) match self.kind() { 18,682 ( 0.00%) Tuple(substs) => substs.iter().map(|field| field.expect_ty()), . _ => bug!("tuple_fields called on non-tuple"), . } 8,756 ( 0.00%) } . . /// Get the `i`-th element of a tuple. . /// Panics when called on anything but a tuple. 46 ( 0.00%) pub fn tuple_element_ty(&self, i: usize) -> Option> { 92 ( 0.00%) match self.kind() { 92 ( 0.00%) Tuple(substs) => substs.iter().nth(i).map(|field| field.expect_ty()), . _ => bug!("tuple_fields called on non-tuple"), . } 92 ( 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] 43,530 ( 0.00%) pub fn discriminant_for_variant( . &self, . tcx: TyCtxt<'tcx>, . variant_index: VariantIdx, . ) -> Option> { 50,569 ( 0.00%) match self.kind() { 18,942 ( 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 . } 9,471 ( 0.00%) TyKind::Adt(adt, _) if adt.is_enum() => { . Some(adt.discriminant_for_variant(tcx, variant_index)) . } . TyKind::Generator(def_id, substs, _) => { 5,796 ( 0.00%) Some(substs.as_generator().discriminant_for_variant(*def_id, tcx, variant_index)) . } . _ => None, . } 34,824 ( 0.00%) } . . /// Returns the type of the discriminant of this type. 59,360 ( 0.00%) pub fn discriminant_ty(&'tcx self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { 29,680 ( 0.00%) match self.kind() { 46,816 ( 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(_) 12 ( 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) . } . } 47,488 ( 0.00%) } . . /// Returns the type of metadata for (potentially fat) pointers to this type. 270 ( 0.00%) pub fn ptr_metadata_ty( . &'tcx self, . tcx: TyCtxt<'tcx>, . normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>, . ) -> Ty<'tcx> { 270 ( 0.00%) let tail = tcx.struct_tail_with_normalize(self, normalize); 150 ( 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, . 60 ( 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) . } . } 240 ( 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. 6,696 ( 0.00%) pub fn to_opt_closure_kind(&self) -> Option { 13,392 ( 0.00%) match self.kind() { 13,384 ( 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), . } 6,696 ( 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`. 695,646 ( 0.00%) pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool { 463,764 ( 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, . 5,925 ( 0.00%) ty::Tuple(tys) => tys.iter().all(|ty| ty.expect_ty().is_trivially_sized(tcx)), . 131,187 ( 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) . } . } 695,646 ( 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()` 216 ( 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. 38,412 ( 0.00%) pub fn xform(self, other: VarianceDiagInfo<'tcx>) -> VarianceDiagInfo<'tcx> { . // For now, just use the first `VarianceDiagInfo::Invariant` that we see 57,618 ( 0.00%) match self { . VarianceDiagInfo::None => other, . VarianceDiagInfo::Invariant { .. } => self, . } 19,206 ( 0.00%) } . } 44,844,769 ( 0.14%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs -------------------------------------------------------------------------------- Ir -- line 24 ---------------------------------------- . use smallvec::SmallVec; . . use std::fmt::Write; . . // Compute the name of the type as it should be stored in debuginfo. Does not do . // any caching, i.e., calling the function twice with the same type will also do . // the work twice. The `qualified` parameter only affects the first level of the . // type name, further levels (i.e., type parameters) are always fully qualified. 567,476 ( 0.00%) pub fn compute_debuginfo_type_name<'tcx>( . tcx: TyCtxt<'tcx>, . t: Ty<'tcx>, . qualified: bool, . ) -> String { . let _prof = tcx.prof.generic_activity("compute_debuginfo_type_name"); . . let mut result = String::with_capacity(64); . let mut visited = FxHashSet::default(); 243,204 ( 0.00%) push_debuginfo_type_name(tcx, t, qualified, &mut result, &mut visited); . result 364,806 ( 0.00%) } . . // Pushes the name of the type as it should be stored in debuginfo on the . // `output` String. See also compute_debuginfo_type_name(). 5,582,826 ( 0.02%) fn push_debuginfo_type_name<'tcx>( . tcx: TyCtxt<'tcx>, . t: Ty<'tcx>, . qualified: bool, . output: &mut String, . visited: &mut FxHashSet>, . ) { . // When targeting MSVC, emit C++ style type names for compatibility with . // .natvis visualizers (and perhaps other existing native debuggers?) . let cpp_like_debuginfo = cpp_like_debuginfo(tcx); . 1,132,452 ( 0.00%) match *t.kind() { . ty::Bool => output.push_str("bool"), . ty::Char => output.push_str("char"), . ty::Str => output.push_str("str"), . ty::Never => { . if cpp_like_debuginfo { . output.push_str("never$"); . } else { . output.push('!'); . } . } 217 ( 0.00%) ty::Int(int_ty) => output.push_str(int_ty.name_str()), 11,606 ( 0.00%) ty::Uint(uint_ty) => output.push_str(uint_ty.name_str()), . ty::Float(float_ty) => output.push_str(float_ty.name_str()), 156 ( 0.00%) ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output), 450,768 ( 0.00%) ty::Adt(def, substs) => { 676,152 ( 0.00%) if def.is_enum() && cpp_like_debuginfo { . msvc_enum_fallback(tcx, t, def, substs, output, visited); . } else { 1,577,688 ( 0.00%) push_item_name(tcx, def.did, qualified, output); 2,704,608 ( 0.01%) push_generic_params_internal(tcx, substs, output, visited); . } . } 7,704 ( 0.00%) ty::Tuple(component_types) => { 7,704 ( 0.00%) if cpp_like_debuginfo { . output.push_str("tuple$<"); . } else { . output.push('('); . } . . for component_type in component_types { 90,117 ( 0.00%) push_debuginfo_type_name(tcx, component_type.expect_ty(), true, output, visited); . push_arg_separator(cpp_like_debuginfo, output); . } 5,165 ( 0.00%) if !component_types.is_empty() { . pop_arg_separator(output); . } . 5,165 ( 0.00%) if cpp_like_debuginfo { . push_close_angle_bracket(cpp_like_debuginfo, output); . } else { . output.push(')'); . } . } 8,826 ( 0.00%) ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl }) => { 4,413 ( 0.00%) if cpp_like_debuginfo { . match mutbl { . hir::Mutability::Not => output.push_str("ptr_const$<"), . hir::Mutability::Mut => output.push_str("ptr_mut$<"), . } . } else { . output.push('*'); 8,826 ( 0.00%) match mutbl { . hir::Mutability::Not => output.push_str("const "), . hir::Mutability::Mut => output.push_str("mut "), . } . } . 13,239 ( 0.00%) push_debuginfo_type_name(tcx, inner_type, qualified, output, visited); . . if cpp_like_debuginfo { . push_close_angle_bracket(cpp_like_debuginfo, output); . } . } 25,107 ( 0.00%) ty::Ref(_, inner_type, mutbl) => { . // Slices and `&str` are treated like C++ pointers when computing debug . // info for MSVC debugger. However, wrapping these types' names in a synthetic type . // causes the .natvis engine for WinDbg to fail to display their data, so we opt these . // types out to aid debugging in MSVC. . let is_slice_or_str = matches!(*inner_type.kind(), ty::Slice(_) | ty::Str); . 8,369 ( 0.00%) if !cpp_like_debuginfo { . output.push('&'); 8,369 ( 0.00%) output.push_str(mutbl.prefix_str()); . } else if !is_slice_or_str { . match mutbl { . hir::Mutability::Not => output.push_str("ref$<"), . hir::Mutability::Mut => output.push_str("ref_mut$<"), . } . } . 66,952 ( 0.00%) push_debuginfo_type_name(tcx, inner_type, qualified, output, visited); . . if cpp_like_debuginfo && !is_slice_or_str { . push_close_angle_bracket(cpp_like_debuginfo, output); . } . } 300 ( 0.00%) ty::Array(inner_type, len) => { 100 ( 0.00%) if cpp_like_debuginfo { . output.push_str("array$<"); . push_debuginfo_type_name(tcx, inner_type, true, output, visited); . match len.val { . ty::ConstKind::Param(param) => write!(output, ",{}>", param.name).unwrap(), . _ => write!(output, ",{}>", len.eval_usize(tcx, ty::ParamEnv::reveal_all())) . .unwrap(), . } . } else { . output.push('['); 600 ( 0.00%) push_debuginfo_type_name(tcx, inner_type, true, output, visited); 200 ( 0.00%) match len.val { . ty::ConstKind::Param(param) => write!(output, "; {}]", param.name).unwrap(), 900 ( 0.00%) _ => write!(output, "; {}]", len.eval_usize(tcx, ty::ParamEnv::reveal_all())) . .unwrap(), . } . } . } 469 ( 0.00%) ty::Slice(inner_type) => { 469 ( 0.00%) if cpp_like_debuginfo { . output.push_str("slice$<"); . } else { . output.push('['); . } . 2,345 ( 0.00%) push_debuginfo_type_name(tcx, inner_type, true, output, visited); . . if cpp_like_debuginfo { . push_close_angle_bracket(cpp_like_debuginfo, output); . } else { . output.push(']'); . } . } . ty::Dynamic(ref trait_data, ..) => { 4,067 ( 0.00%) let auto_traits: SmallVec<[DefId; 4]> = trait_data.auto_traits().collect(); . 4,067 ( 0.00%) let has_enclosing_parens = if cpp_like_debuginfo { . output.push_str("dyn$<"); . false . } else { 23,950 ( 0.00%) if trait_data.len() > 1 && auto_traits.len() != 0 { . // We need enclosing parens because there is more than one trait . output.push_str("(dyn "); . true . } else { . output.push_str("dyn "); . false . } . }; . 20,335 ( 0.00%) if let Some(principal) = trait_data.principal() { . let principal = 44,737 ( 0.00%) tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), principal); 24,402 ( 0.00%) push_item_name(tcx, principal.def_id, qualified, output); . let principal_has_generic_params = 20,335 ( 0.00%) push_generic_params_internal(tcx, principal.substs, output, visited); . 4,067 ( 0.00%) let projection_bounds: SmallVec<[_; 4]> = trait_data . .projection_bounds() . .map(|bound| { 3,544 ( 0.00%) let ExistentialProjection { item_def_id, term, .. } = bound.skip_binder(); . // FIXME(associated_const_equality): allow for consts here 886 ( 0.00%) (item_def_id, term.ty().unwrap()) 2,658 ( 0.00%) }) . .collect(); . 12,201 ( 0.00%) if projection_bounds.len() != 0 { 2,358 ( 0.00%) if principal_has_generic_params { . // push_generic_params_internal() above added a `>` but we actually . // want to add more items to that list, so remove that again. 284 ( 0.00%) pop_close_angle_bracket(output); . } . 14,130 ( 0.00%) for (item_def_id, ty) in projection_bounds { . push_arg_separator(cpp_like_debuginfo, output); . . if cpp_like_debuginfo { . output.push_str("assoc$<"); . push_item_name(tcx, item_def_id, false, output); . push_arg_separator(cpp_like_debuginfo, output); . push_debuginfo_type_name(tcx, ty, true, output, visited); . push_close_angle_bracket(cpp_like_debuginfo, output); . } else { 886 ( 0.00%) push_item_name(tcx, item_def_id, false, output); . output.push('='); 4,430 ( 0.00%) push_debuginfo_type_name(tcx, ty, true, output, visited); . } . } . 786 ( 0.00%) push_close_angle_bracket(cpp_like_debuginfo, output); . } . 8,134 ( 0.00%) if auto_traits.len() != 0 { 3,840 ( 0.00%) push_auto_trait_separator(cpp_like_debuginfo, output); . } 4,067 ( 0.00%) } . 12,201 ( 0.00%) if auto_traits.len() != 0 { 19,200 ( 0.00%) let mut auto_traits: SmallVec<[String; 4]> = auto_traits . .into_iter() . .map(|def_id| { . let mut name = String::with_capacity(20); 35,745 ( 0.00%) push_item_name(tcx, def_id, true, &mut name); . name . }) . .collect(); . auto_traits.sort_unstable(); . 91,098 ( 0.00%) for auto_trait in auto_traits { . output.push_str(&auto_trait); . push_auto_trait_separator(cpp_like_debuginfo, output); . } . . pop_auto_trait_separator(output); . } . 4,067 ( 0.00%) if cpp_like_debuginfo { . push_close_angle_bracket(cpp_like_debuginfo, output); 8,134 ( 0.00%) } else if has_enclosing_parens { 7,680 ( 0.00%) output.push(')'); . } 4,067 ( 0.00%) } . ty::FnDef(..) | ty::FnPtr(_) => { . // We've encountered a weird 'recursive type' . // Currently, the only way to generate such a type . // is by using 'impl trait': . // . // fn foo() -> impl Copy { foo } . // . // There's not really a sensible name we can generate, . // since we don't include 'impl trait' types (e.g. ty::Opaque) . // in the output . // . // Since we need to generate *something*, we just . // use a dummy string that should make it clear . // that something unusual is going on 5,302 ( 0.00%) if !visited.insert(t) { . output.push_str(if cpp_like_debuginfo { . "recursive_type$" . } else { . "" . }); . return; . } . . let sig = 29,161 ( 0.00%) tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), t.fn_sig(tcx)); . 2,651 ( 0.00%) if cpp_like_debuginfo { . // Format as a C++ function pointer: return_type (*)(params...) . if sig.output().is_unit() { . output.push_str("void"); . } else { . push_debuginfo_type_name(tcx, sig.output(), true, output, visited); . } . output.push_str(" (*)("); . } else { 7,953 ( 0.00%) output.push_str(sig.unsafety.prefix_str()); . 2,651 ( 0.00%) if sig.abi != rustc_target::spec::abi::Abi::Rust { . output.push_str("extern \""); . output.push_str(sig.abi.name()); . output.push_str("\" "); . } . . output.push_str("fn("); . } . 5,302 ( 0.00%) if !sig.inputs().is_empty() { 7,890 ( 0.00%) for ¶meter_type in sig.inputs() { 16,272 ( 0.00%) push_debuginfo_type_name(tcx, parameter_type, true, output, visited); . push_arg_separator(cpp_like_debuginfo, output); . } . pop_arg_separator(output); . } . 5,302 ( 0.00%) if sig.c_variadic { . if !sig.inputs().is_empty() { . output.push_str(", ..."); . } else { . output.push_str("..."); . } . } . . output.push(')'); . 5,494 ( 0.00%) if !cpp_like_debuginfo && !sig.output().is_unit() { . output.push_str(" -> "); 22,131 ( 0.00%) push_debuginfo_type_name(tcx, sig.output(), true, output, visited); . } . . // We only keep the type in 'visited' . // for the duration of the body of this method. . // It's fine for a particular function type . // to show up multiple times in one overall type . // (e.g. MyType u8, fn() -> u8> . // . // We only care about avoiding recursing . // directly back to the type we're currently . // processing 5,302 ( 0.00%) visited.remove(t); . } . ty::Closure(def_id, ..) | ty::Generator(def_id, ..) => { 167,256 ( 0.00%) let key = tcx.def_key(def_id); 55,752 ( 0.00%) if qualified { . let parent_def_id = DefId { index: key.parent.unwrap(), ..def_id }; 177,940 ( 0.00%) push_item_name(tcx, parent_def_id, true, output); . output.push_str("::"); . } 362,388 ( 0.00%) push_unqualified_item_name(tcx, def_id, key.disambiguated_data, output); . } . // Type parameters from polymorphized functions. . ty::Param(_) => { . output.push_str(&format!("{:?}", t)); . } . ty::Error(_) . | ty::Infer(_) . | ty::Placeholder(..) -- line 363 ---------------------------------------- -- line 422 ---------------------------------------- . output.push_str(&format!(", {}", variant)); . } . } . push_close_angle_bracket(true, output); . } . . const NON_CPP_AUTO_TRAIT_SEPARATOR: &str = " + "; . 7,680 ( 0.00%) fn push_auto_trait_separator(cpp_like_debuginfo: bool, output: &mut String) { 14,829 ( 0.00%) if cpp_like_debuginfo { . push_arg_separator(cpp_like_debuginfo, output); . } else { . output.push_str(NON_CPP_AUTO_TRAIT_SEPARATOR); . } 7,680 ( 0.00%) } . . fn pop_auto_trait_separator(output: &mut String) { 3,840 ( 0.00%) if output.ends_with(NON_CPP_AUTO_TRAIT_SEPARATOR) { 15,360 ( 0.00%) output.truncate(output.len() - NON_CPP_AUTO_TRAIT_SEPARATOR.len()); . } else { . pop_arg_separator(output); . } . } 203,424 ( 0.00%) } . . /// Computes a name for the global variable storing a vtable. . /// . /// The name is of the form: . /// . /// `::{vtable}` . /// . /// or, when generating C++-like names: . /// . /// `impl$::vtable$` 2,211 ( 0.00%) pub fn compute_debuginfo_vtable_name<'tcx>( . tcx: TyCtxt<'tcx>, . t: Ty<'tcx>, . trait_ref: Option>, . ) -> String { . let cpp_like_debuginfo = cpp_like_debuginfo(tcx); . . let mut vtable_name = String::with_capacity(64); . 201 ( 0.00%) if cpp_like_debuginfo { . vtable_name.push_str("impl$<"); . } else { . vtable_name.push('<'); . } . . let mut visited = FxHashSet::default(); 1,005 ( 0.00%) push_debuginfo_type_name(tcx, t, true, &mut vtable_name, &mut visited); . 201 ( 0.00%) if cpp_like_debuginfo { . vtable_name.push_str(", "); . } else { . vtable_name.push_str(" as "); . } . 402 ( 0.00%) if let Some(trait_ref) = trait_ref { . let trait_ref = 2,010 ( 0.00%) tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), trait_ref); 1,206 ( 0.00%) push_item_name(tcx, trait_ref.def_id, true, &mut vtable_name); . visited.clear(); 804 ( 0.00%) push_generic_params_internal(tcx, trait_ref.substs, &mut vtable_name, &mut visited); . } else { . vtable_name.push_str("_"); . } . 804 ( 0.00%) push_close_angle_bracket(cpp_like_debuginfo, &mut vtable_name); . 201 ( 0.00%) let suffix = if cpp_like_debuginfo { "::vtable$" } else { "::{vtable}" }; . . vtable_name.reserve_exact(suffix.len()); . vtable_name.push_str(suffix); . . vtable_name 1,809 ( 0.00%) } . 11,093,196 ( 0.03%) pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: &mut String) { 4,628,367 ( 0.01%) let def_key = tcx.def_key(def_id); 3,697,732 ( 0.01%) if qualified { . if let Some(parent) = def_key.parent { 3,849,636 ( 0.01%) push_item_name(tcx, DefId { krate: def_id.krate, index: parent }, true, output); . output.push_str("::"); . } . } . 12,947,378 ( 0.04%) push_unqualified_item_name(tcx, def_id, def_key.disambiguated_data, output); . } . 11,438,340 ( 0.04%) fn push_unqualified_item_name( . tcx: TyCtxt<'_>, . def_id: DefId, . disambiguated_data: DisambiguatedDefPathData, . output: &mut String, . ) { 3,359,568 ( 0.01%) match disambiguated_data.data { . DefPathData::CrateRoot => { 1,133,030 ( 0.00%) output.push_str(tcx.crate_name(def_id.krate).as_str()); . } 48,268 ( 0.00%) DefPathData::ClosureExpr if tcx.generator_kind(def_id).is_some() => { . let key = match tcx.generator_kind(def_id).unwrap() { 16,944 ( 0.00%) hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) => "async_block", . hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure) => "async_closure", 45,580 ( 0.00%) hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn) => "async_fn", . hir::GeneratorKind::Gen => "generator", . }; . // Generators look like closures, but we want to treat them differently . // in the debug info. 15,631 ( 0.00%) if cpp_like_debuginfo(tcx) { . write!(output, "{}${}", key, disambiguated_data.disambiguator).unwrap(); . } else { 140,679 ( 0.00%) write!(output, "{{{}#{}}}", key, disambiguated_data.disambiguator).unwrap(); . } . } 2,132,874 ( 0.01%) _ => match disambiguated_data.data.name() { 1,311,114 ( 0.00%) DefPathDataName::Named(name) => { 1,966,671 ( 0.01%) output.push_str(name.as_str()); . } 55,401 ( 0.00%) DefPathDataName::Anon { namespace } => { 55,401 ( 0.00%) if cpp_like_debuginfo(tcx) { . write!(output, "{}${}", namespace, disambiguated_data.disambiguator).unwrap(); . } else { 498,609 ( 0.00%) write!(output, "{{{}#{}}}", namespace, disambiguated_data.disambiguator) . .unwrap(); . } . } . }, . }; 7,625,560 ( 0.02%) } . . // Pushes the generic parameters in the given `InternalSubsts` to the output string. . // This ignores region parameters, since they can't reliably be . // reconstructed for items from non-local crates. For local crates, this . // would be possible but with inlining and LTO we have to use the least . // common denominator - otherwise we would run into conflicts. 2,659,492 ( 0.01%) fn push_generic_params_internal<'tcx>( . tcx: TyCtxt<'tcx>, . substs: SubstsRef<'tcx>, . output: &mut String, . visited: &mut FxHashSet>, . ) -> bool { . if substs.non_erasable_generics().next().is_none() { . return false; . } -- line 566 ---------------------------------------- -- line 569 ---------------------------------------- . . let cpp_like_debuginfo = cpp_like_debuginfo(tcx); . . output.push('<'); . . for type_parameter in substs.non_erasable_generics() { . match type_parameter { . GenericArgKind::Type(type_parameter) => { 1,277,742 ( 0.00%) push_debuginfo_type_name(tcx, type_parameter, true, output, visited); . } . GenericArgKind::Const(ct) => { . push_const_param(tcx, ct, output); . } . other => bug!("Unexpected non-erasable generic: {:?}", other), . } . . push_arg_separator(cpp_like_debuginfo, output); . } . pop_arg_separator(output); 610,000 ( 0.00%) push_close_angle_bracket(cpp_like_debuginfo, output); . . true 1,934,176 ( 0.01%) } . . fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: &'tcx ty::Const<'tcx>, output: &mut String) { 28 ( 0.00%) match ct.val { . ty::ConstKind::Param(param) => { . write!(output, "{}", param.name) . } 64 ( 0.00%) _ => match ct.ty.kind() { . ty::Int(ity) => { . let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty); . let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128; . write!(output, "{}", val) . } . ty::Uint(_) => { 84 ( 0.00%) let val = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty); 60 ( 0.00%) write!(output, "{}", val) . } . ty::Bool => { 2 ( 0.00%) let val = ct.try_eval_bool(tcx, ty::ParamEnv::reveal_all()).unwrap(); 6 ( 0.00%) write!(output, "{}", val) . } . _ => { . // If we cannot evaluate the constant to a known type, we fall back . // to emitting a stable hash value of the constant. This isn't very pretty . // but we get a deterministic, virtually unique value for the constant. . let hcx = &mut tcx.create_stable_hashing_context(); . let mut hasher = StableHasher::new(); . hcx.while_hashing_spans(false, |hcx| { -- line 618 ---------------------------------------- -- line 630 ---------------------------------------- . write!(output, "{{CONST#{:x}}}", hash) . } . } . }, . } . .unwrap(); . } . 145,440 ( 0.00%) pub fn push_generic_params<'tcx>(tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, output: &mut String) { . let _prof = tcx.prof.generic_activity("compute_debuginfo_type_name"); . let mut visited = FxHashSet::default(); 48,480 ( 0.00%) push_generic_params_internal(tcx, substs, output, &mut visited); 84,840 ( 0.00%) } . 306,974 ( 0.00%) fn push_close_angle_bracket(cpp_like_debuginfo: bool, output: &mut String) { . // MSVC debugger always treats `>>` as a shift, even when parsing templates, . // so add a space to avoid confusion. 306,974 ( 0.00%) if cpp_like_debuginfo && output.ends_with('>') { . output.push(' ') . }; . . output.push('>'); 306,974 ( 0.00%) } . 568 ( 0.00%) fn pop_close_angle_bracket(output: &mut String) { 284 ( 0.00%) assert!(output.ends_with('>'), "'output' does not end with '>': {}", output); . output.pop(); 284 ( 0.00%) if output.ends_with(' ') { . output.pop(); . } 568 ( 0.00%) } . . fn push_arg_separator(cpp_like_debuginfo: bool, output: &mut String) { . // Natvis does not always like having spaces between parts of the type name . // and this causes issues when we need to write a typename in natvis, for example . // as part of a cast like the `HashMap` visualizer does. 216,346 ( 0.00%) if cpp_like_debuginfo { . output.push(','); . } else { . output.push_str(", "); . }; . } . . fn pop_arg_separator(output: &mut String) { 160,254 ( 0.00%) if output.ends_with(' ') { . output.pop(); . } . 160,254 ( 0.00%) assert!(output.ends_with(',')); . . output.pop(); . } . . /// Check if we should generate C++ like names and debug information. 16,262 ( 0.00%) pub fn cpp_like_debuginfo(tcx: TyCtxt<'_>) -> bool { 1,985,578 ( 0.01%) tcx.sess.target.is_like_msvc 32,524 ( 0.00%) } 2,044,598 ( 0.01%) -------------------------------------------------------------------------------- -- 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,084,188 ( 0.01%) ptr: NonZeroUsize, 4,206,103 ( 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; . 443,146 ( 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> { 100,678 ( 0.00%) fn pack(self) -> GenericArg<'tcx> { 100,678 ( 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) . } . }; . 326,544 ( 0.00%) GenericArg { ptr: unsafe { NonZeroUsize::new_unchecked(ptr | tag) }, marker: PhantomData } 100,678 ( 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), -- line 75 ---------------------------------------- -- line 85 ---------------------------------------- . . impl<'tcx> PartialOrd for GenericArg<'tcx> { . fn partial_cmp(&self, other: &GenericArg<'_>) -> Option { . Some(self.cmp(&other)) . } . } . . impl<'tcx> From> for GenericArg<'tcx> { 128,370 ( 0.00%) fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> { . GenericArgKind::Lifetime(r).pack() 128,370 ( 0.00%) } . } . . impl<'tcx> From> for GenericArg<'tcx> { 1,642,408 ( 0.01%) fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> { . GenericArgKind::Type(ty).pack() 1,642,408 ( 0.01%) } . } . . impl<'tcx> From<&'tcx ty::Const<'tcx>> for GenericArg<'tcx> { 167 ( 0.00%) fn from(c: &'tcx ty::Const<'tcx>) -> GenericArg<'tcx> { . GenericArgKind::Const(c).pack() 167 ( 0.00%) } . } . . impl<'tcx> GenericArg<'tcx> { . #[inline] . pub fn unpack(self) -> GenericArgKind<'tcx> { . let ptr = self.ptr.get(); . unsafe { 26,323,475 ( 0.08%) match ptr & TAG_MASK { 141,278 ( 0.00%) REGION_TAG => GenericArgKind::Lifetime(&*((ptr & !TAG_MASK) as *const _)), 7,169,588 ( 0.02%) TYPE_TAG => GenericArgKind::Type(&*((ptr & !TAG_MASK) as *const _)), 5,539 ( 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"), . } 341,554 ( 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), 3 ( 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> { 63,722 ( 0.00%) self.unpack().encode(e) . } . } . . impl<'tcx, D: TyDecoder<'tcx>> Decodable for GenericArg<'tcx> { 503,390 ( 0.00%) fn decode(d: &mut D) -> GenericArg<'tcx> { 503,390 ( 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. 21,462 ( 0.00%) pub fn as_closure(&'a self) -> ClosureSubsts<'a> { . ClosureSubsts { substs: self } 21,462 ( 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. 41,450 ( 0.00%) pub fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx> { 4,636 ( 0.00%) Self::for_item(tcx, def_id, |param, _| tcx.mk_param_from_def(param)) 37,305 ( 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. 303,969 ( 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); 114,502 ( 0.00%) Self::fill_item(&mut substs, tcx, defs, &mut mk_kind); 61,116 ( 0.00%) tcx.intern_substs(&substs) 304,929 ( 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)) . }) . } . 447,147 ( 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>, . { 185,545 ( 0.00%) if let Some(def_id) = defs.parent { . let parent_defs = tcx.generics_of(def_id); 31,127 ( 0.00%) Self::fill_item(substs, tcx, parent_defs, mk_kind); . } . Self::fill_single(substs, defs, mk_kind) 353,200 ( 0.00%) } . 224 ( 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 { 56 ( 0.00%) let kind = mk_kind(param, substs); 241,292 ( 0.00%) assert_eq!(param.index as usize, substs.len()); . substs.push(kind); . } 224 ( 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] 60 ( 0.00%) pub fn type_at(&self, i: usize) -> Ty<'tcx> { 510,870 ( 0.00%) if let GenericArgKind::Type(ty) = self[i].unpack() { . ty . } else { . bug!("expected type for param #{} in {:?}", i, self); . } 40 ( 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. 58,534 ( 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); 16,724 ( 0.00%) tcx.mk_substs(target_substs.iter().chain(self.iter().skip(defs.params.len()))) 66,896 ( 0.00%) } . 12,120 ( 0.00%) pub fn truncate_to(&self, tcx: TyCtxt<'tcx>, generics: &ty::Generics) -> SubstsRef<'tcx> { . tcx.mk_substs(self.iter().take(generics.count())) 24,240 ( 0.00%) } . } . . impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> { 1,390,130 ( 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`. 6,045,156 ( 0.02%) match self.len() { . 1 => { 865,024 ( 0.00%) let param0 = self[0].try_fold_with(folder)?; 2,993,123 ( 0.01%) if param0 == self[0] { Ok(self) } else { Ok(folder.tcx().intern_substs(&[param0])) } . } . 2 => { 492,991 ( 0.00%) let param0 = self[0].try_fold_with(folder)?; 1,258,426 ( 0.00%) let param1 = self[1].try_fold_with(folder)?; 1,229,139 ( 0.00%) if param0 == self[0] && param1 == self[1] { . Ok(self) . } else { 872,450 ( 0.00%) Ok(folder.tcx().intern_substs(&[param0, param1])) . } . } . 0 => Ok(self), . _ => { . let params: SmallVec<[_; 8]> = 145,233 ( 0.00%) self.iter().map(|k| k.try_fold_with(folder)).collect::>()?; 3,406 ( 0.00%) if params[..] == self[..] { . Ok(self) . } else { 9,447 ( 0.00%) Ok(folder.tcx().intern_substs(¶ms)) . } . } . } 1,631,974 ( 0.01%) } . . fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { 699,754 ( 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 { 5,932,845 ( 0.02%) 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> { 1,224,782 ( 0.00%) self.tcx . } . . fn fold_binder>( . &mut self, . t: ty::Binder<'tcx, T>, . ) -> ty::Binder<'tcx, T> { 445,556 ( 0.00%) self.binders_passed += 1; 80,225 ( 0.00%) let t = t.super_fold_with(self); 445,556 ( 0.00%) self.binders_passed -= 1; . t . } . 1,005,282 ( 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()`. 335,094 ( 0.00%) match *r { 79,568 ( 0.00%) ty::ReEarlyBound(data) => { 79,568 ( 0.00%) let rk = self.substs.get(data.index as usize).map(|k| k.unpack()); . match rk { 39,784 ( 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, . } 1,172,829 ( 0.00%) } . 6,247,620 ( 0.02%) fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { 2,082,540 ( 0.01%) if !t.needs_subst() { . return t; . } . 2,959,136 ( 0.01%) match *t.kind() { 3,927,455 ( 0.01%) ty::Param(p) => self.ty_for_param(p, t), 4,164,462 ( 0.01%) _ => t.super_fold_with(self), . } 6,942,315 ( 0.02%) } . 594,146 ( 0.00%) fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { 171,486 ( 0.00%) if let ty::ConstKind::Param(p) = c.val { . self.const_for_param(p, c) . } else { 760,788 ( 0.00%) c.super_fold_with(self) . } 2,768 ( 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. 1,570,982 ( 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. 692 ( 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() . ); . 2,591,404 ( 0.01%) 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> { 94,513 ( 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)] 4,853 ( 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. 1,994 ( 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, 675 ( 0.00%) pub self_ty: Ty<'tcx>, . } 11,268,520 ( 0.04%) -------------------------------------------------------------------------------- The following files chosen for auto-annotation could not be found: -------------------------------------------------------------------------------- ./malloc/malloc.c ./nptl/pthread_rwlock_common.c ./stdlib/msort.c ./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 /tmp/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/../../../../gcc-5.5.0/libstdc++-v3/libsupc++/new_op.cc -------------------------------------------------------------------------------- Ir -------------------------------------------------------------------------------- 1,172,835,042 ( 3.67%) events annotated