-------------------------------------------------------------------------------- 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 pest 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 -C metadata=1b11f6c16e7f43a7 -C extra-filename=-1b11f6c16e7f43a7 --out-dir /usr/home/liquid/tmp/.tmp7dGQ9R/target/debug/deps -L dependency=/usr/home/liquid/tmp/.tmp7dGQ9R/target/debug/deps --extern ucd_trie=/usr/home/liquid/tmp/.tmp7dGQ9R/target/debug/deps/libucd_trie-54a4eac8451c1bb7.rmeta -Adeprecated -Aunknown-lints -Zincremental-verify-ich Data file: results/cgout-w-profiling-pest-2.1.3-Debug-Full Events recorded: Ir Events shown: Ir Event sort order: Ir Thresholds: 0.1 Include dirs: User annotated: Auto-annotation: on -------------------------------------------------------------------------------- Ir -------------------------------------------------------------------------------- 5,757,500,851 (100.0%) PROGRAM TOTALS -------------------------------------------------------------------------------- Ir file:function -------------------------------------------------------------------------------- 139,978,445 ( 2.43%) ./malloc/malloc.c:_int_malloc 120,793,480 ( 2.10%) ./malloc/malloc.c:_int_free 108,523,581 ( 1.88%) ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms 76,270,675 ( 1.32%) ./malloc/malloc.c:malloc 57,140,280 ( 0.99%) ???:llvm::FPPassManager::runOnFunction(llvm::Function&) 47,052,132 ( 0.82%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs:rustc_const_eval::transform::check_consts::qualifs::in_operand::::qualif_local::{closure#0}> 41,081,584 ( 0.71%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>>::from_key_hashed_nocheck:: 37,275,487 ( 0.65%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>>::get:: 33,382,079 ( 0.58%) ./malloc/malloc.c:free 30,678,921 ( 0.53%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/lexer/mod.rs:::next_token 29,041,638 ( 0.50%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/util.rs:::is_trivially_unpin 28,272,657 ( 0.49%) ./malloc/malloc.c:malloc_consolidate 28,015,771 ( 0.49%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/num/uint_macros.rs:::short_write_process_buffer:: 27,646,440 ( 0.48%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/util.rs:::is_freeze 23,613,382 ( 0.41%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lexer/src/lib.rs:::advance_token 22,153,259 ( 0.38%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/middle/region.rs:::temporary_scope 22,127,385 ( 0.38%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/lexer/tokentrees.rs:::parse_token_tree 21,981,302 ( 0.38%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_span/src/caching_source_map_view.rs:::span_data_to_lines_and_cols 21,754,496 ( 0.38%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/hir/map/mod.rs:::attrs 19,186,180 ( 0.33%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/hir/map/mod.rs:::find_parent_node 18,933,426 ( 0.33%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast_pretty/src/pp/ring.rs:>::pop_first 18,851,467 ( 0.33%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast_pretty/src/pp.rs:::advance_left 18,793,188 ( 0.33%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_data_structures/src/sip128.rs:::short_write_process_buffer:: 18,762,804 ( 0.33%) ???:llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) 18,481,409 ( 0.32%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/mod.rs:::check 18,262,775 ( 0.32%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/mir/mod.rs:::check_static_ptr 17,628,665 ( 0.31%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_span/src/lib.rs:>::hash_stable 17,533,194 ( 0.30%) /usr/home/liquid/rust/worktree-benchmarking/library/alloc/src/collections/vec_deque/mod.rs:>::push_back 17,203,972 ( 0.30%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/middle/region.rs:>>::get:: 16,928,378 ( 0.29%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/context.rs:::maybe_lint_level_root_bounded 16,793,787 ( 0.29%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/mod.rs:::bump 16,508,004 ( 0.29%) ./malloc/malloc.c:unlink_chunk.constprop.0 16,084,279 ( 0.28%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_mir_build/src/thir/cx/expr.rs:::mirror_expr_inner 15,495,961 ( 0.27%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/mod.rs:::next 15,134,502 ( 0.26%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/map.rs:>>::from_key_hashed_nocheck:: 14,660,632 ( 0.25%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:::node_type_opt 14,369,940 ( 0.25%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_infer/src/infer/mod.rs:::enter::, rustc_trait_selection::traits::structural_match::search_for_structural_match_violation::{closure#0}> 14,025,119 ( 0.24%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast/src/token.rs:::clone 13,735,968 ( 0.24%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_infer/src/infer/mod.rs:::new 13,534,311 ( 0.24%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/option.rs:::advance_left 13,283,440 ( 0.23%) ???:llvm::PMDataManager::verifyPreservedAnalysis(llvm::Pass*) 13,233,060 ( 0.23%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:, (), core::hash::BuildHasherDefault>>::from_hash::>::{closure#0}> 12,435,525 ( 0.22%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_trait_selection/src/traits/structural_match.rs:::enter::, rustc_trait_selection::traits::structural_match::search_for_structural_match_violation::{closure#0}> 12,276,972 ( 0.21%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>>::insert 12,237,366 ( 0.21%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_data_structures/src/sip128.rs:>::hash_stable 12,236,904 ( 0.21%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/cell.rs:::attrs 12,185,073 ( 0.21%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast/src/tokenstream.rs:::next_with_spacing 12,166,228 ( 0.21%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>::reserve_rehash::>::{closure#0}> 12,142,478 ( 0.21%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/expr.rs:::parse_assoc_expr_with 11,879,395 ( 0.21%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_mir_build/src/thir/cx/expr.rs:::make_mirror_unadjusted 11,818,540 ( 0.21%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/mir/mod.rs:::ty 11,783,659 ( 0.20%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_typeck/src/check/regionck.rs:::visit_expr 11,455,291 ( 0.20%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_mir_build/src/build/expr/as_operand.rs:::as_operand 11,239,921 ( 0.20%) ???:llvm::AttributeList::addAttributes(llvm::LLVMContext&, unsigned int, llvm::AttrBuilder const&) const 11,085,841 ( 0.19%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lint/src/levels.rs:::push 10,958,498 ( 0.19%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/lexer/tokentrees.rs:::push 10,821,464 ( 0.19%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/../../stdarch/crates/core_arch/src/x86/sse2.rs:>>::from_key_hashed_nocheck:: 10,745,114 ( 0.19%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_typeck/src/check/writeback.rs:::visit_node_id 10,308,908 ( 0.18%) ./elf/dl-lookup.c:_dl_lookup_symbol_x 10,098,622 ( 0.18%) ???:llvm::raw_svector_ostream::write_impl(char const*, unsigned long) 10,032,603 ( 0.17%) /usr/home/liquid/rust/worktree-benchmarking/library/std/src/collections/hash/map.rs:>>::get:: 10,022,552 ( 0.17%) ???:(anonymous namespace)::Verifier::visitInstruction(llvm::Instruction&) 9,751,424 ( 0.17%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/slice/iter/macros.rs:rustc_const_eval::transform::check_consts::qualifs::in_rvalue::::qualif_local::{closure#0}> 9,742,791 ( 0.17%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_typeck/src/check/expr.rs:::check_expr_with_expectation_and_args 9,646,341 ( 0.17%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/expr.rs:::collect_tokens_for_expr::<::parse_dot_or_call_expr::{closure#0}>::{closure#0} 9,465,465 ( 0.16%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast/src/token.rs:::eq 9,263,781 ( 0.16%) ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_erms 9,178,415 ( 0.16%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lint/src/types.rs:::check_expr 9,129,944 ( 0.16%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/operand.rs:>::const_val_to_op 9,046,996 ( 0.16%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/operand.rs:>::eval_operand 8,984,864 ( 0.16%) ???:(anonymous namespace)::RegAllocFast::allocateBasicBlock(llvm::MachineBasicBlock&) 8,942,538 ( 0.16%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_borrowck/src/type_check/mod.rs:::visit_constant 8,866,447 ( 0.15%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs:rustc_const_eval::transform::check_consts::qualifs::in_operand:: as rustc_middle::mir::visit::Visitor>::visit_assign::{closure#0}> 8,704,141 ( 0.15%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast_pretty/src/pp.rs:::scan_string 8,688,613 ( 0.15%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_data_structures/src/sip128.rs:::slice_write_process_buffer 8,649,290 ( 0.15%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/bitmask.rs:>>::from_key_hashed_nocheck:: 8,604,973 ( 0.15%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/bitmask.rs:>>::get:: 8,533,449 ( 0.15%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_hir_pretty/src/lib.rs:::print_expr 8,475,068 ( 0.15%) ./malloc/malloc.c:realloc 8,466,595 ( 0.15%) ???:llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) 8,402,303 ( 0.15%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_passes/src/region.rs:::visit_expr 8,394,513 ( 0.15%) /usr/home/liquid/rust/worktree-benchmarking/library/std/src/sys/unix/alloc.rs:__rdl_alloc 8,368,229 ( 0.15%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast_pretty/src/pp.rs:::check_stack 8,332,754 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/ptr/mod.rs:>::truncate 8,315,510 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs:rustc_const_eval::transform::check_consts::qualifs::in_operand::::qualif_local::{closure#0}> 8,312,155 ( 0.14%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:, (core::result::Result, rustc_middle::ty::layout::LayoutError>, rustc_query_system::dep_graph::graph::DepNodeIndex), core::hash::BuildHasherDefault>>::from_key_hashed_nocheck::> 8,304,214 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_typeck/src/mem_categorization.rs:::cat_expr_unadjusted 8,292,558 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_typeck/src/check/coercion.rs:>::coerce 8,291,964 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/mir/mod.rs:::const_for_ty 8,234,569 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/num/uint_macros.rs:::slice_write_process_buffer 8,152,284 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/flags.rs:::add_const 8,147,998 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_metadata/src/rmeta/encoder.rs:>::encode 7,975,500 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs:> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform 7,970,194 ( 0.14%) ???:(anonymous namespace)::Verifier::visitMDNode(llvm::MDNode const&, (anonymous namespace)::Verifier::AreDebugLocsAllowed) 7,922,004 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/library/alloc/src/collections/vec_deque/mod.rs:::advance_left 7,829,460 ( 0.14%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_hir/src/intravisit.rs:rustc_hir::intravisit::walk_expr:: 7,771,490 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/place.rs:>::place_field 7,768,675 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/mod.rs:::bump_with 7,753,401 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_trait_selection/src/traits/structural_match.rs:::visit_ty 7,745,351 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/place.rs:>::force_allocation_maybe_sized 7,726,482 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/ptr/mod.rs:core::ptr::drop_in_place::> 7,707,480 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast/src/token.rs:::ident 7,679,687 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_privacy/src/lib.rs:::check_expr_pat_type 7,515,343 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/place.rs:>::copy_op_no_validate 7,441,232 ( 0.13%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:)>>::remove_entry::>::{closure#0}> 7,396,982 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/library/alloc/src/collections/vec_deque/mod.rs:::check_stack 7,394,969 ( 0.13%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>::insert::>::{closure#0}> 7,335,847 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs:rustc_const_eval::transform::check_consts::qualifs::in_rvalue::::qualif_local::{closure#0}> 7,311,608 ( 0.13%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_expand/src/expand.rs:::filter_map_expr 7,178,934 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_passes/src/check_attr.rs:::check_attributes 7,166,145 ( 0.12%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/map.rs:>>::get:: 7,143,804 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_span/src/symbol.rs:::as_str 7,105,490 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lint/src/early.rs: as rustc_ast::visit::Visitor>::visit_expr 7,098,944 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/place.rs:>::write_immediate_to_mplace_no_validate 7,015,668 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast/src/token.rs:::clone 7,011,888 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/context.rs:::node_type 6,981,749 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/walk.rs:::next 6,943,243 ( 0.12%) ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:__memcmp_avx2_movbe 6,908,876 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/cell.rs:::find_parent_node 6,892,073 ( 0.12%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>::insert::>::{closure#0}> 6,844,320 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lint/src/early.rs: as rustc_ast::visit::Visitor>::visit_expr 6,827,819 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast/src/util/literal.rs:rustc_ast::util::literal::integer_lit 6,815,515 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/option.rs:::attrs 6,800,797 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/operand.rs:>::try_read_immediate 6,731,341 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_mir_build/src/build/scope.rs:::as_operand 6,713,884 ( 0.12%) ???:llvm::MCExpr::evaluateAsRelocatableImpl(llvm::MCValue&, llvm::MCAssembler const*, llvm::MCAsmLayout const*, llvm::MCFixup const*, llvm::DenseMap, llvm::detail::DenseMapPair > const*, bool) const 6,676,704 ( 0.12%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/rustc_entry.rs:, rustc_middle::mir::interpret::allocation::Allocation), core::hash::BuildHasherDefault>>::rustc_entry 6,671,932 ( 0.12%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/ptr/mod.rs:core::ptr::drop_in_place:: 6,618,660 ( 0.11%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:::push 6,562,251 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/expr.rs:::parse_dot_or_call_expr_with_ 6,542,008 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/str/mod.rs:::next_token 6,454,230 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_span/src/hygiene.rs:>::hash_stable 6,422,671 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_mir_build/src/build/expr/as_constant.rs:::as_constant 6,359,805 ( 0.11%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>::reserve_rehash::>::{closure#0}> 6,354,909 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_span/src/span_encoding.rs:::to 6,341,416 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_infer/src/infer/mod.rs:::shallow_resolve_ty 6,311,142 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/library/alloc/src/collections/vec_deque/mod.rs:>::pop_first 6,290,063 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/util.rs:rustc_middle::ty::util::needs_drop_components 6,275,666 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_typeck/src/check/writeback.rs:::visit_expr 6,267,902 ( 0.11%) ???:llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) 6,246,810 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast_pretty/src/pprust/state.rs:::maybe_print_comment 6,221,021 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_typeck/src/check/expr.rs:::check_expr_kind 6,184,146 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/sty.rs:::eq 6,154,900 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/slice/mod.rs:::attrs 6,120,797 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_resolve/src/late.rs:::resolve_expr 6,119,007 ( 0.11%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/map.rs:, (), core::hash::BuildHasherDefault>>::from_hash::>::{closure#0}> 6,116,437 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_serialize/src/leb128.rs:>::encode 6,106,966 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/expr.rs:::parse_prefix_expr 6,079,590 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_trait_selection/src/traits/structural_match.rs:rustc_trait_selection::traits::structural_match::search_for_structural_match_violation 6,076,792 ( 0.11%) /usr/home/liquid/rust/worktree-benchmarking/library/alloc/src/vec/mod.rs:::check 6,028,700 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_borrowck/src/type_check/canonical.rs:::fully_perform_op::<&rustc_middle::ty::TyS, rustc_middle::ty::ParamEnvAnd>> 6,024,378 ( 0.10%) /usr/home/liquid/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.0/src/raw/mod.rs:>::reserve_rehash::>::{closure#0}> 5,993,641 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lint/src/late.rs:rustc_hir::intravisit::walk_expr::> 5,971,998 ( 0.10%) ./malloc/malloc.c:_int_realloc 5,969,308 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_privacy/src/lib.rs: as rustc_middle::ty::fold::TypeVisitor>::visit_ty 5,952,344 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/expr.rs:::parse_opt_lit 5,922,798 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast/src/ptr.rs:>::map::<::parse_dot_or_call_expr_with::{closure#0}::{closure#0}> 5,901,954 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_span/src/lib.rs:::next_token 5,857,609 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_middle/src/ty/context.rs:::intern_ty 5,838,327 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/interpret/memory.rs:>::get_mut 5,822,707 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_ast_lowering/src/expr.rs:rustc_data_structures::stack::ensure_sufficient_stack::::lower_expr_mut::{closure#0}> 5,807,340 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_parse/src/parser/expr.rs:::parse_lit_expr 5,774,038 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_index/src/vec.rs:::mirror_expr_inner 5,762,533 ( 0.10%) /usr/home/liquid/rust/worktree-benchmarking/library/core/src/slice/iter/macros.rs:::advance_token -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lint/src/levels.rs -------------------------------------------------------------------------------- Ir -- line 20 ---------------------------------------- . Level, Lint, LintId, . }; . use rustc_session::parse::feature_err; . use rustc_session::Session; . use rustc_span::symbol::{sym, Symbol}; . use rustc_span::{source_map::MultiSpan, Span, DUMMY_SP}; . use tracing::debug; . 9 ( 0.00%) fn lint_levels(tcx: TyCtxt<'_>, (): ()) -> LintLevelMap { . let store = unerased_lint_store(tcx); . let levels = 6 ( 0.00%) LintLevelsBuilder::new(tcx.sess, false, &store, &tcx.resolutions(()).registered_tools); 13 ( 0.00%) let mut builder = LintLevelMapBuilder { levels, tcx }; 3 ( 0.00%) let krate = tcx.hir().krate(); . 2 ( 0.00%) builder.levels.id_to_set.reserve(krate.owners.len() + 1); . 8 ( 0.00%) let push = builder.levels.push(tcx.hir().attrs(hir::CRATE_HIR_ID), true); . builder.levels.register_id(hir::CRATE_HIR_ID); . tcx.hir().walk_toplevel_module(&mut builder); . builder.levels.pop(push); . 16 ( 0.00%) builder.levels.build_map() 9 ( 0.00%) } . . pub struct LintLevelsBuilder<'s> { . sess: &'s Session, . sets: LintLevelSets, . id_to_set: FxHashMap, . cur: LintStackIndex, . warn_about_weird_lints: bool, . store: &'s LintStore, -- line 51 ---------------------------------------- -- line 53 ---------------------------------------- . } . . pub struct BuilderPush { . prev: LintStackIndex, . pub changed: bool, . } . . impl<'s> LintLevelsBuilder<'s> { 273 ( 0.00%) pub fn new( . sess: &'s Session, . warn_about_weird_lints: bool, . store: &'s LintStore, . registered_tools: &'s RegisteredTools, . ) -> Self { 231 ( 0.00%) let mut builder = LintLevelsBuilder { . sess, 21 ( 0.00%) sets: LintLevelSets::new(), . cur: COMMAND_LINE, . id_to_set: Default::default(), . warn_about_weird_lints, . store, . registered_tools, . }; . builder.process_command_line(sess, store); 63 ( 0.00%) assert_eq!(builder.sets.list.len(), 1); . builder 189 ( 0.00%) } . . pub(crate) fn sess(&self) -> &Session { 8,446 ( 0.00%) self.sess . } . . pub(crate) fn lint_store(&self) -> &LintStore { . self.store . } . . fn process_command_line(&mut self, sess: &Session, store: &LintStore) { . let mut specs = FxHashMap::default(); 42 ( 0.00%) self.sets.lint_cap = sess.opts.lint_cap.unwrap_or(Level::Forbid); . 42 ( 0.00%) for &(ref lint_name, level) in &sess.opts.lint_opts { 210 ( 0.00%) store.check_lint_name_cmdline(sess, &lint_name, level, self.registered_tools); . let orig_level = level; 84 ( 0.00%) let lint_flag_val = Symbol::intern(lint_name); . 210 ( 0.00%) let ids = match store.find_lints(&lint_name) { 168 ( 0.00%) Ok(ids) => ids, . Err(_) => continue, // errors handled in check_lint_name_cmdline above . }; 126 ( 0.00%) for id in ids { . // ForceWarn and Forbid cannot be overriden . if let Some((Level::ForceWarn | Level::Forbid, _)) = specs.get(&id) { . continue; . } . 168 ( 0.00%) self.check_gated_lint(id, DUMMY_SP); . let src = LintLevelSource::CommandLine(lint_flag_val, orig_level); 84 ( 0.00%) specs.insert(id, (level, src)); . } . } . 168 ( 0.00%) self.cur = self.sets.list.push(LintSet { specs, parent: COMMAND_LINE }); . } . . /// Attempts to insert the `id` to `level_src` map entry. If unsuccessful . /// (e.g. if a forbid was already inserted on the same scope), then emits a . /// diagnostic with no change to `specs`. 2,783 ( 0.00%) fn insert_spec( . &mut self, . specs: &mut FxHashMap, . id: LintId, 1,518 ( 0.00%) (level, src): LevelAndSource, . ) { 1,265 ( 0.00%) let (old_level, old_src) = 1,771 ( 0.00%) self.sets.get_lint_level(id.lint, self.cur, Some(&specs), &self.sess); . // Setting to a non-forbid level is an error if the lint previously had . // a forbid level. Note that this is not necessarily true even with a . // `#[forbid(..)]` attribute present, as that is overriden by `--cap-lints`. . // . // This means that this only errors if we're truly lowering the lint . // level from forbid. 253 ( 0.00%) if level != Level::Forbid { 1,012 ( 0.00%) if let Level::Forbid = old_level { . // Backwards compatibility check: . // . // We used to not consider `forbid(lint_group)` . // as preventing `allow(lint)` for some lint `lint` in . // `lint_group`. For now, issue a future-compatibility . // warning for this case. . let id_name = id.lint.name_lower(); . let fcw_warning = match old_src { -- line 143 ---------------------------------------- -- line 202 ---------------------------------------- . if !fcw_warning { . return; . } . } . } . if let Level::ForceWarn = old_level { . specs.insert(id, (old_level, old_src)); . } else { 1,012 ( 0.00%) specs.insert(id, (level, src)); . } 2,024 ( 0.00%) } . . /// Pushes a list of AST lint attributes onto this context. . /// . /// This function will return a `BuilderPush` object which should be passed . /// to `pop` when this scope for the attributes provided is exited. . /// . /// This function will perform a number of tasks: . /// . /// * It'll validate all lint-related attributes in `attrs` . /// * It'll mark all lint-related attributes as used . /// * Lint levels will be updated based on the attributes provided . /// * Lint attributes are validated, e.g., a `#[forbid]` can't be switched to . /// `#[allow]` . /// . /// Don't forget to call `pop`! 3,528,960 ( 0.06%) pub(crate) fn push(&mut self, attrs: &[ast::Attribute], is_crate_node: bool) -> BuilderPush { . let mut specs = FxHashMap::default(); 882,240 ( 0.02%) let sess = self.sess; 441,120 ( 0.01%) let bad_attr = |span| struct_span_err!(sess, span, E0452, "malformed lint attribute input"); . for attr in attrs { 35,742 ( 0.00%) let Some(level) = Level::from_symbol(attr.name_or_empty()) else { . continue . }; . 1,359 ( 0.00%) let Some(mut metas) = attr.meta_item_list() else { . continue . }; . 151 ( 0.00%) if metas.is_empty() { . // FIXME (#55112): issue unused-attributes lint for `#[level()]` . continue; . } . . // Before processing the lint names, look for a reason (RFC 2383) . // at the end. . let mut reason = None; 151 ( 0.00%) let tail_li = &metas[metas.len() - 1]; 453 ( 0.00%) if let Some(item) = tail_li.meta_item() { 755 ( 0.00%) match item.kind { . ast::MetaItemKind::Word => {} // actual lint names handled later . ast::MetaItemKind::NameValue(ref name_value) => { . if item.path == sym::reason { . // FIXME (#55112): issue unused-attributes lint if we thereby . // don't have any lint names (`#[level(reason = "foo")]`) . if let ast::LitKind::Str(rationale, _) = name_value.kind { . if !self.sess.features_untracked().lint_reasons { . feature_err( -- line 259 ---------------------------------------- -- line 279 ---------------------------------------- . } . } . ast::MetaItemKind::List(_) => { . bad_attr(item.span).span_label(item.span, "bad attribute argument").emit(); . } . } . } . 3,322 ( 0.00%) for li in metas { 604 ( 0.00%) let sp = li.span(); 302 ( 0.00%) let mut meta_item = match li { 2,718 ( 0.00%) ast::NestedMetaItem::MetaItem(meta_item) if meta_item.is_word() => meta_item, . _ => { . let mut err = bad_attr(sp); . let mut add_label = true; . if let Some(item) = li.meta_item() { . if let ast::MetaItemKind::NameValue(_) = item.kind { . if item.path == sym::reason { . err.span_label(sp, "reason in lint attribute must come last"); . add_label = false; -- line 298 ---------------------------------------- -- line 301 ---------------------------------------- . } . if add_label { . err.span_label(sp, "bad attribute argument"); . } . err.emit(); . continue; . } . }; 453 ( 0.00%) let tool_ident = if meta_item.path.segments.len() > 1 { 72 ( 0.00%) Some(meta_item.path.segments.remove(0).ident) . } else { 133 ( 0.00%) None . }; 151 ( 0.00%) let tool_name = tool_ident.map(|ident| ident.name); 453 ( 0.00%) let name = pprust::path_to_string(&meta_item.path); . let lint_result = 755 ( 0.00%) self.store.check_lint_name(&name, tool_name, self.registered_tools); 525 ( 0.00%) match &lint_result { . CheckLintNameResult::Ok(ids) => { . let src = LintLevelSource::Node( . meta_item.path.segments.last().expect("empty lint name").ident.name, . sp, . reason, . ); 639 ( 0.00%) for &id in *ids { 1,265 ( 0.00%) self.check_gated_lint(id, attr.span); 3,036 ( 0.00%) self.insert_spec(&mut specs, id, (level, src)); . } . } . . CheckLintNameResult::Tool(result) => { 90 ( 0.00%) match *result { . Ok(ids) => { . let complete_name = . &format!("{}::{}", tool_ident.unwrap().name, name); . let src = LintLevelSource::Node( . Symbol::intern(complete_name), . sp, . reason, . ); -- line 340 ---------------------------------------- -- line 454 ---------------------------------------- . } . db.emit(); . }); . } . } . // If this lint was renamed, apply the new lint instead of ignoring the attribute. . // This happens outside of the match because the new lint should be applied even if . // we don't warn about the name change. 755 ( 0.00%) if let CheckLintNameResult::Warning(_, Some(new_name)) = lint_result { . // Ignore any errors or warnings that happen because the new name is inaccurate . // NOTE: `new_name` already includes the tool name, so we don't have to add it again. . if let CheckLintNameResult::Ok(ids) = . self.store.check_lint_name(&new_name, None, self.registered_tools) . { . let src = LintLevelSource::Node(Symbol::intern(&new_name), sp, reason); . for &id in ids { . self.check_gated_lint(id, attr.span); . self.insert_spec(&mut specs, id, (level, src)); . } . } else { . panic!("renamed lint does not exist: {}", new_name); . } . } 604 ( 0.00%) } . } . 882,240 ( 0.02%) if !is_crate_node { 500 ( 0.00%) for (id, &(level, ref src)) in specs.iter() { 750 ( 0.00%) if !id.lint.crate_level_only { . continue; . } . . let LintLevelSource::Node(lint_attr_name, lint_attr_span, _) = *src else { . continue . }; . . let lint = builtin::UNUSED_ATTRIBUTES; -- line 490 ---------------------------------------- -- line 505 ---------------------------------------- . db.emit(); . }, . ); . // don't set a separate error for every lint in the group . break; . } . } . 441,120 ( 0.01%) let prev = self.cur; 441,120 ( 0.01%) if !specs.is_empty() { 798 ( 0.00%) self.cur = self.sets.list.push(LintSet { specs, parent: prev }); . } . . BuilderPush { prev, changed: prev != self.cur } 3,970,080 ( 0.07%) } . . /// Checks if the lint is gated on a feature that is not enabled. 2,065 ( 0.00%) fn check_gated_lint(&self, lint_id: LintId, span: Span) { 885 ( 0.00%) if let Some(feature) = lint_id.lint.feature_gate { . if !self.sess.features_untracked().enabled(feature) { . feature_err( . &self.sess.parse_sess, . feature, . span, . &format!("the `{}` lint is unstable", lint_id.lint.name_lower()), . ) . .emit(); . } . } 2,360 ( 0.00%) } . . /// Called after `push` when the scope of a set of attributes are exited. . pub fn pop(&mut self, push: BuilderPush) { 579,011 ( 0.01%) self.cur = push.prev; 293,896 ( 0.01%) } . . /// Find the lint level for a lint. 130 ( 0.00%) pub fn lint_level(&self, lint: &'static Lint) -> (Level, LintLevelSource) { 541 ( 0.00%) self.sets.get_lint_level(lint, self.cur, None, self.sess) 195 ( 0.00%) } . . /// Used to emit a lint-related diagnostic based on the current state of . /// this lint context. 763 ( 0.00%) pub fn struct_lint( . &self, . lint: &'static Lint, . span: Option, . decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>), . ) { 592 ( 0.00%) let (level, src) = self.lint_level(lint); 82 ( 0.00%) struct_lint_level(self.sess, lint, level, src, span, decorate) 487 ( 0.00%) } . . /// Registers the ID provided with the current set of lints stored in . /// this context. . pub fn register_id(&mut self, id: HirId) { 128 ( 0.00%) self.id_to_set.insert(id, self.cur); . } . . pub fn build_map(self) -> LintLevelMap { 8 ( 0.00%) LintLevelMap { sets: self.sets, id_to_set: self.id_to_set } . } . } . . struct LintLevelMapBuilder<'tcx> { . levels: LintLevelsBuilder<'tcx>, . tcx: TyCtxt<'tcx>, . } . . impl LintLevelMapBuilder<'_> { . fn with_lint_attrs(&mut self, id: hir::HirId, f: F) . where . F: FnOnce(&mut Self), . { . let is_crate_hir = id == hir::CRATE_HIR_ID; 870,048 ( 0.02%) let attrs = self.tcx.hir().attrs(id); 870,738 ( 0.02%) let push = self.levels.push(attrs, is_crate_hir); 145,180 ( 0.00%) if push.changed { . self.levels.register_id(id); . } . f(self); . self.levels.pop(push); . } . } . . impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'tcx> { . type NestedFilter = nested_filter::All; . . fn nested_visit_map(&mut self) -> Self::Map { 1,091 ( 0.00%) self.tcx.hir() . } . . fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) { 884 ( 0.00%) self.with_lint_attrs(param.hir_id, |builder| { . intravisit::walk_param(builder, param); . }); . } . . fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) { 492 ( 0.00%) self.with_lint_attrs(it.hir_id(), |builder| { 1,476 ( 0.00%) intravisit::walk_item(builder, it); . }); . } . . fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) { . self.with_lint_attrs(it.hir_id(), |builder| { . intravisit::walk_foreign_item(builder, it); . }) . } . . fn visit_stmt(&mut self, e: &'tcx hir::Stmt<'tcx>) { . // We will call `with_lint_attrs` when we walk . // the `StmtKind`. The outer statement itself doesn't . // define the lint levels. 1,314 ( 0.00%) intravisit::walk_stmt(self, e); . } . 756 ( 0.00%) fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) { 286,966 ( 0.00%) self.with_lint_attrs(e.hir_id, |builder| { 570,516 ( 0.01%) intravisit::walk_expr(builder, e); . }) 672 ( 0.00%) } . . fn visit_field_def(&mut self, s: &'tcx hir::FieldDef<'tcx>) { 186 ( 0.00%) self.with_lint_attrs(s.hir_id, |builder| { . intravisit::walk_field_def(builder, s); . }) . } . . fn visit_variant( . &mut self, . v: &'tcx hir::Variant<'tcx>, . g: &'tcx hir::Generics<'tcx>, . item_id: hir::HirId, . ) { 44 ( 0.00%) self.with_lint_attrs(v.id, |builder| { . intravisit::walk_variant(builder, v, g, item_id); . }) . } . . fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) { 444 ( 0.00%) self.with_lint_attrs(l.hir_id, |builder| { 888 ( 0.00%) intravisit::walk_local(builder, l); . }) . } . . fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) { 414 ( 0.00%) self.with_lint_attrs(a.hir_id, |builder| { 828 ( 0.00%) intravisit::walk_arm(builder, a); . }) . } . . fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { 1 ( 0.00%) self.with_lint_attrs(trait_item.hir_id(), |builder| { 3 ( 0.00%) intravisit::walk_trait_item(builder, trait_item); . }); . } . . fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) { 197 ( 0.00%) self.with_lint_attrs(impl_item.hir_id(), |builder| { 591 ( 0.00%) intravisit::walk_impl_item(builder, impl_item); . }); . } . } . . pub fn provide(providers: &mut Providers) { 2 ( 0.00%) providers.lint_levels = lint_levels; . } 444,931 ( 0.01%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs -------------------------------------------------------------------------------- Ir -- line 82 ---------------------------------------- . /// promotion of temporaries must not change program behavior; if the promoted could be . /// written to, that would be a problem. . pub struct HasMutInterior; . . impl Qualif for HasMutInterior { . const ANALYSIS_NAME: &'static str = "flow_has_mut_interior"; . . fn in_qualifs(qualifs: &ConstQualifs) -> bool { 363 ( 0.00%) qualifs.has_mut_interior . } . . fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool { 8,286,264 ( 0.14%) !ty.is_freeze(cx.tcx.at(DUMMY_SP), cx.param_env) . } . . fn in_adt_inherently<'tcx>( . cx: &ConstCx<'_, 'tcx>, . adt: &'tcx AdtDef, . _: SubstsRef<'tcx>, . ) -> bool { . // Exactly one type, `UnsafeCell`, has the `HasMutInterior` qualif inherently. . // It arises structurally for all other types. 4,495 ( 0.00%) Some(adt.did) == cx.tcx.lang_items().unsafe_cell_type() . } . } . . /// Constant containing an ADT that implements `Drop`. . /// This must be ruled out because implicit promotion would remove side-effects . /// that occur as part of dropping that value. N.B., the implicit promotion has . /// to reject const Drop implementations because even if side-effects are ruled . /// out through other means, the execution of the drop could diverge. . pub struct NeedsDrop; . . impl Qualif for NeedsDrop { . const ANALYSIS_NAME: &'static str = "flow_needs_drop"; . const IS_CLEARED_ON_MOVE: bool = true; . . fn in_qualifs(qualifs: &ConstQualifs) -> bool { 91 ( 0.00%) qualifs.needs_drop . } . 2,210,016 ( 0.04%) fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool { 552,504 ( 0.01%) ty.needs_drop(cx.tcx, cx.param_env) 2,486,268 ( 0.04%) } . . fn in_adt_inherently<'tcx>( . cx: &ConstCx<'_, 'tcx>, . adt: &'tcx AdtDef, . _: SubstsRef<'tcx>, . ) -> bool { 921 ( 0.00%) adt.has_dtor(cx.tcx) . } . } . . /// Constant containing an ADT that implements non-const `Drop`. . /// This must be ruled out because we cannot run `Drop` during compile-time. . pub struct NeedsNonConstDrop; . . impl Qualif for NeedsNonConstDrop { -- line 140 ---------------------------------------- -- line 141 ---------------------------------------- . const ANALYSIS_NAME: &'static str = "flow_needs_nonconst_drop"; . const IS_CLEARED_ON_MOVE: bool = true; . const ALLOW_PROMOTED: bool = true; . . fn in_qualifs(qualifs: &ConstQualifs) -> bool { . qualifs.needs_non_const_drop . } . 837 ( 0.00%) fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool { . // Avoid selecting for simple cases, such as builtin types. 372 ( 0.00%) if ty::util::is_trivially_const_drop(ty) { . return false; . } . . let Some(drop_trait) = cx.tcx.lang_items().drop_trait() else { . // there is no way to define a type that needs non-const drop . // without having the lang item present. . return false; . }; -- line 159 ---------------------------------------- -- line 196 ---------------------------------------- . let mut fcx = FulfillmentContext::new(); . for nested in impl_src.nested_obligations() { . fcx.register_predicate_obligation(&infcx, nested); . } . . // If we had any errors, then it's bad . !fcx.select_all_or_error(&infcx).is_empty() . }) 837 ( 0.00%) } . . fn in_adt_inherently<'tcx>( . cx: &ConstCx<'_, 'tcx>, . adt: &'tcx AdtDef, . _: SubstsRef<'tcx>, . ) -> bool { . adt.has_non_const_dtor(cx.tcx) . } -- line 212 ---------------------------------------- -- line 214 ---------------------------------------- . . /// A constant that cannot be used as part of a pattern in a `match` expression. . pub struct CustomEq; . . impl Qualif for CustomEq { . const ANALYSIS_NAME: &'static str = "flow_custom_eq"; . . fn in_qualifs(qualifs: &ConstQualifs) -> bool { 182 ( 0.00%) qualifs.custom_eq . } . . fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool { . // If *any* component of a composite data type does not implement `Structural{Partial,}Eq`, . // we know that at least some values of that type are not structural-match. I say "some" . // because that component may be part of an enum variant (e.g., . // `Option::::Some`), in which case some values of this type may be . // structural-match (`Option::None`). 1,105,231 ( 0.02%) traits::search_for_structural_match_violation(cx.body.span, cx.tcx, ty).is_some() . } . 1,274 ( 0.00%) fn in_adt_inherently<'tcx>( . cx: &ConstCx<'_, 'tcx>, . adt: &'tcx AdtDef, . substs: SubstsRef<'tcx>, . ) -> bool { 182 ( 0.00%) let ty = cx.tcx.mk_ty(ty::Adt(adt, substs)); . !ty.is_structural_eq_shallow(cx.tcx) 1,456 ( 0.00%) } . } . . // FIXME: Use `mir::visit::Visitor` for the `in_*` functions if/when it supports early return. . . /// Returns `true` if this `Rvalue` contains qualif `Q`. 218,020 ( 0.00%) pub fn in_rvalue<'tcx, Q, F>( . cx: &ConstCx<'_, 'tcx>, . in_local: &mut F, . rvalue: &Rvalue<'tcx>, . ) -> bool . where . Q: Qualif, . F: FnMut(Local) -> bool, . { 109,010 ( 0.00%) match rvalue { . Rvalue::ThreadLocalRef(_) | Rvalue::NullaryOp(..) => { . Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)) . } . . Rvalue::Discriminant(place) | Rvalue::Len(place) => { . in_place::(cx, in_local, place.as_ref()) . } . . Rvalue::Use(operand) . | Rvalue::Repeat(operand, _) . | Rvalue::UnaryOp(_, operand) . | Rvalue::Cast(_, operand, _) 13,459 ( 0.00%) | Rvalue::ShallowInitBox(operand, _) => in_operand::(cx, in_local, operand), . . Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => { . in_operand::(cx, in_local, lhs) || in_operand::(cx, in_local, rhs) . } . 17,350 ( 0.00%) Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { . // Special-case reborrows to be more like a copy of the reference. 6,924 ( 0.00%) if let Some((place_base, ProjectionElem::Deref)) = place.as_ref().last_projection() { 3,462 ( 0.00%) let base_ty = place_base.ty(cx.body, cx.tcx).ty; 6,924 ( 0.00%) if let ty::Ref(..) = base_ty.kind() { 18,948 ( 0.00%) return in_place::(cx, in_local, place_base); . } . } . 27,084 ( 0.00%) in_place::(cx, in_local, place.as_ref()) . } . . Rvalue::Aggregate(kind, operands) => { . // Return early if we know that the struct or enum being constructed is always . // qualified. 32,150 ( 0.00%) if let AggregateKind::Adt(adt_did, _, substs, ..) = **kind { 1,388 ( 0.00%) let def = cx.tcx.adt_def(adt_did); 2,787 ( 0.00%) if Q::in_adt_inherently(cx, def, substs) { . return true; . } 1,206 ( 0.00%) if def.is_union() && Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)) { . return true; . } . } . . // Otherwise, proceed structurally... 8,851,364 ( 0.15%) operands.iter().any(|o| in_operand::(cx, in_local, o)) . } . } 120,548 ( 0.00%) } . . /// Returns `true` if this `Place` contains qualif `Q`. 180,484 ( 0.00%) pub fn in_place<'tcx, Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, place: PlaceRef<'tcx>) -> bool . where . Q: Qualif, . F: FnMut(Local) -> bool, . { 5,751 ( 0.00%) let mut place = place; . while let Some((place_base, elem)) = place.last_projection() { . match elem { . ProjectionElem::Index(index) if in_local(index) => return true, . . ProjectionElem::Deref . | ProjectionElem::Field(_, _) . | ProjectionElem::ConstantIndex { .. } . | ProjectionElem::Subslice { .. } -- line 320 ---------------------------------------- -- line 327 ---------------------------------------- . if !Q::in_any_value_of_ty(cx, proj_ty) { . return false; . } . . place = place_base; . } . . assert!(place.projection.is_empty()); 3,195 ( 0.00%) in_local(place.local) 29,248 ( 0.00%) } . . /// Returns `true` if this `Operand` contains qualif `Q`. 17,180,697 ( 0.30%) pub fn in_operand<'tcx, Q, F>( . cx: &ConstCx<'_, 'tcx>, . in_local: &mut F, . operand: &Operand<'tcx>, . ) -> bool . where . Q: Qualif, . F: FnMut(Local) -> bool, . { 3,879,630 ( 0.07%) let constant = match operand { . Operand::Copy(place) | Operand::Move(place) => { 52,640 ( 0.00%) return in_place::(cx, in_local, place.as_ref()); . } . . Operand::Constant(c) => c, . }; . . // Check the qualifs of the value of `const` items. 9,665,815 ( 0.17%) if let Some(ct) = constant.literal.const_for_ty() { 3,866,326 ( 0.07%) if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.val { . // Use qualifs of the type for the promoted. Promoteds in MIR body should be possible . // only for `NeedsNonConstDrop` with precise drop checking. This is the only const . // check performed after the promotion. Verify that with an assertion. 636 ( 0.00%) assert!(promoted.is_none() || Q::ALLOW_PROMOTED); . // Don't peek inside trait associated constants. 727 ( 0.00%) if promoted.is_none() && cx.tcx.trait_of_item(def.did).is_none() { 6,269 ( 0.00%) let qualifs = if let Some((did, param_did)) = def.as_const_arg() { . cx.tcx.at(constant.span).mir_const_qualif_const_arg((did, param_did)) . } else { . cx.tcx.at(constant.span).mir_const_qualif(def.did) . }; . 636 ( 0.00%) if !Q::in_qualifs(&qualifs) { . return false; . } . . // Just in case the type is more specific than . // the definition, e.g., impl associated const . // with type parameters, take it into account. . } . } . } . // Otherwise use the qualifs of the type. 4,693,895 ( 0.08%) Q::in_any_value_of_ty(cx, constant.literal.ty()) 15,494,452 ( 0.27%) } 92,516 ( 0.00%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/library/core/src/num/uint_macros.rs -------------------------------------------------------------------------------- Ir -- line 57 ---------------------------------------- . /// # Examples . /// . /// Basic usage: . /// . /// ``` . #[doc = concat!("assert_eq!(", stringify!($SelfT), "::from_str_radix(\"A\", 16), Ok(10));")] . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] 276,174 ( 0.00%) pub fn from_str_radix(src: &str, radix: u32) -> Result { 138,087 ( 0.00%) from_str_radix(src, radix) 414,261 ( 0.01%) } . . /// Returns the number of ones in the binary representation of `self`. . /// . /// # Examples . /// . /// Basic usage: . /// . /// ``` -- line 75 ---------------------------------------- -- line 80 ---------------------------------------- . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_math", since = "1.32.0")] . #[doc(alias = "popcount")] . #[doc(alias = "popcnt")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn count_ones(self) -> u32 { 186,075 ( 0.00%) intrinsics::ctpop(self as $ActualT) as u32 . } . . /// Returns the number of zeros in the binary representation of `self`. . /// . /// # Examples . /// . /// Basic usage: . /// -- line 96 ---------------------------------------- -- line 118 ---------------------------------------- . /// assert_eq!(n.leading_zeros(), 2); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn leading_zeros(self) -> u32 { 416,740 ( 0.01%) intrinsics::ctlz(self as $ActualT) as u32 . } . . /// Returns the number of trailing zeros in the binary representation . /// of `self`. . /// . /// # Examples . /// . /// Basic usage: -- line 134 ---------------------------------------- -- line 139 ---------------------------------------- . /// assert_eq!(n.trailing_zeros(), 3); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn trailing_zeros(self) -> u32 { 1,535,150 ( 0.03%) intrinsics::cttz(self) as u32 . } . . /// Returns the number of leading ones in the binary representation of `self`. . /// . /// # Examples . /// . /// Basic usage: . /// -- line 155 ---------------------------------------- -- line 204 ---------------------------------------- . #[doc = concat!("assert_eq!(n.rotate_left(", $rot, "), m);")] . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn rotate_left(self, n: u32) -> Self { 29,805,112 ( 0.52%) intrinsics::rotate_left(self, n as $SelfT) . } . . /// Shifts the bits to the right by a specified amount, `n`, . /// wrapping the truncated bits to the beginning of the resulting . /// integer. . /// . /// Please note this isn't the same operation as the `>>` shifting operator! . /// -- line 220 ---------------------------------------- -- line 430 ---------------------------------------- . #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);")] . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.47.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline] . pub const fn checked_add(self, rhs: Self) -> Option { 4 ( 0.00%) let (a, b) = self.overflowing_add(rhs); . if unlikely!(b) {None} else {Some(a)} . } . . /// Unchecked integer addition. Computes `self + rhs`, assuming overflow . /// cannot occur. . /// . /// # Safety . /// -- line 446 ---------------------------------------- -- line 456 ---------------------------------------- . )] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] . #[inline(always)] . pub const unsafe fn unchecked_add(self, rhs: Self) -> Self { . // SAFETY: the caller must uphold the safety contract for . // `unchecked_add`. 2,241,488 ( 0.04%) unsafe { intrinsics::unchecked_add(self, rhs) } . } . . /// Checked addition with a signed integer. Computes `self + rhs`, . /// returning `None` if overflow occurred. . /// . /// # Examples . /// . /// Basic usage: -- line 472 ---------------------------------------- -- line 525 ---------------------------------------- . )] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] . #[inline(always)] . pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self { . // SAFETY: the caller must uphold the safety contract for . // `unchecked_sub`. 39,253 ( 0.00%) unsafe { intrinsics::unchecked_sub(self, rhs) } . } . . /// Checked integer multiplication. Computes `self * rhs`, returning . /// `None` if overflow occurred. . /// . /// # Examples . /// . /// Basic usage: -- line 541 ---------------------------------------- -- line 596 ---------------------------------------- . without modifying the original"] . #[inline] . pub const fn checked_div(self, rhs: Self) -> Option { . if unlikely!(rhs == 0) { . None . } else { . // SAFETY: div by zero has been checked above and unsigned types have no other . // failure modes for division 1,160 ( 0.00%) Some(unsafe { intrinsics::unchecked_div(self, rhs) }) . } . } . . /// Checked Euclidean division. Computes `self.div_euclid(rhs)`, returning `None` . /// if `rhs == 0`. . /// . /// # Examples . /// -- line 612 ---------------------------------------- -- line 1035 ---------------------------------------- . #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_add(127), ", stringify!($SelfT), "::MAX);")] . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")] . #[inline(always)] . pub const fn saturating_add(self, rhs: Self) -> Self { 278,249 ( 0.00%) intrinsics::saturating_add(self, rhs) . } . . /// Saturating addition with a signed integer. Computes `self + rhs`, . /// saturating at the numeric bounds instead of overflowing. . /// . /// # Examples . /// . /// Basic usage: -- line 1051 ---------------------------------------- -- line 1084 ---------------------------------------- . #[doc = concat!("assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);")] . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[rustc_const_stable(feature = "const_saturating_int_methods", since = "1.47.0")] . #[inline(always)] . pub const fn saturating_sub(self, rhs: Self) -> Self { 322,001 ( 0.01%) intrinsics::saturating_sub(self, rhs) . } . . /// Saturating integer multiplication. Computes `self * rhs`, . /// saturating at the numeric bounds instead of overflowing. . /// . /// # Examples . /// . /// Basic usage: -- line 1100 ---------------------------------------- -- line 1175 ---------------------------------------- . #[doc = concat!("assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::MAX), 199);")] . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn wrapping_add(self, rhs: Self) -> Self { 20,019,361 ( 0.35%) intrinsics::wrapping_add(self, rhs) . } . . /// Wrapping (modular) addition with a signed integer. Computes . /// `self + rhs`, wrapping around at the boundary of the type. . /// . /// # Examples . /// . /// Basic usage: -- line 1191 ---------------------------------------- -- line 1217 ---------------------------------------- . #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::MAX), 101);")] . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn wrapping_sub(self, rhs: Self) -> Self { 9,055,792 ( 0.16%) intrinsics::wrapping_sub(self, rhs) . } . . /// Wrapping (modular) multiplication. Computes `self * . /// rhs`, wrapping around at the boundary of the type. . /// . /// # Examples . /// . /// Basic usage: -- line 1233 ---------------------------------------- -- line 1240 ---------------------------------------- . /// assert_eq!(25u8.wrapping_mul(12), 44); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn wrapping_mul(self, rhs: Self) -> Self { 17,722,903 ( 0.31%) intrinsics::wrapping_mul(self, rhs) . } . . /// Wrapping (modular) division. Computes `self / rhs`. . /// Wrapped division on unsigned types is just normal division. . /// There's no way wrapping could ever happen. . /// This function exists, so that all operations . /// are accounted for in the wrapping operations. . /// -- line 1256 ---------------------------------------- -- line 1491 ---------------------------------------- . #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false));")] . #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (0, true));")] . /// ``` . #[stable(feature = "wrapping", since = "1.7.0")] . #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] 10 ( 0.00%) pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { 4,164,636 ( 0.07%) let (a, b) = intrinsics::add_with_overflow(self as $ActualT, rhs as $ActualT); . (a as Self, b) 20 ( 0.00%) } . . /// Calculates `self + rhs + carry` without the ability to overflow. . /// . /// Performs "ternary addition" which takes in an extra bit to add, and may return an . /// additional bit of overflow. This allows for chaining together multiple additions . /// to create "big integers" which represent larger values. . /// . #[doc = concat!("This can be thought of as a ", stringify!($BITS), "-bit \"full adder\", in the electronics sense.")] -- line 1510 ---------------------------------------- -- line 1587 ---------------------------------------- . #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_sub(2), (3, false));")] . #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".overflowing_sub(1), (", stringify!($SelfT), "::MAX, true));")] . /// ``` . #[stable(feature = "wrapping", since = "1.7.0")] . #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] 2 ( 0.00%) pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { 625,576 ( 0.01%) let (a, b) = intrinsics::sub_with_overflow(self as $ActualT, rhs as $ActualT); . (a as Self, b) 4 ( 0.00%) } . . /// Calculates `self - rhs - borrow` without the ability to overflow. . /// . /// Performs "ternary subtraction" which takes in an extra bit to subtract, and may return . /// an additional bit of overflow. This allows for chaining together multiple subtractions . /// to create "big integers" which represent larger values. . /// . /// # Examples -- line 1606 ---------------------------------------- -- line 1674 ---------------------------------------- . /// assert_eq!(1_000_000_000u32.overflowing_mul(10), (1410065408, true)); . /// ``` . #[stable(feature = "wrapping", since = "1.7.0")] . #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline(always)] . pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { 3,836,541 ( 0.07%) let (a, b) = intrinsics::mul_with_overflow(self as $ActualT, rhs as $ActualT); . (a as Self, b) . } . . /// Calculates the divisor when `self` is divided by `rhs`. . /// . /// Returns a tuple of the divisor along with a boolean indicating . /// whether an arithmetic overflow would occur. Note that for unsigned . /// integers overflow never occurs, so the second value is always -- line 1690 ---------------------------------------- -- line 2132 ---------------------------------------- . #[doc = concat!("assert!(16", stringify!($SelfT), ".is_power_of_two());")] . #[doc = concat!("assert!(!10", stringify!($SelfT), ".is_power_of_two());")] . /// ``` . #[must_use] . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_is_power_of_two", since = "1.32.0")] . #[inline(always)] . pub const fn is_power_of_two(self) -> bool { 168 ( 0.00%) self.count_ones() == 1 . } . . // Returns one less than next power of two. . // (For 8u8 next power of two is 8u8 and for 6u8 it is 8u8) . // . // 8u8.one_less_than_next_power_of_two() == 7 . // 6u8.one_less_than_next_power_of_two() == 7 . // . // This method cannot overflow, as in the `next_power_of_two` . // overflow cases it instead ends up returning the maximum value . // of the type, and can return 0 for 0. . #[inline] . #[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")] . const fn one_less_than_next_power_of_two(self) -> Self { 7,554 ( 0.00%) if self <= 1 { return 0; } . 20,818 ( 0.00%) let p = self - 1; . // SAFETY: Because `p > 0`, it cannot consist entirely of leading zeros. . // That means the shift is always in-bounds, and some processors . // (such as intel pre-haswell) have more efficient ctlz . // intrinsics when the argument is non-zero. 62,324 ( 0.00%) let z = unsafe { intrinsics::ctlz_nonzero(p) }; 20,884 ( 0.00%) <$SelfT>::MAX >> z . } . . /// Returns the smallest power of two greater than or equal to `self`. . /// . /// When return value overflows (i.e., `self > (1 << (N-1))` for type . /// `uN`), it panics in debug mode and the return value is wrapped to 0 in . /// release mode (the only situation in which method can return 0). . /// -- line 2171 ---------------------------------------- -- line 2179 ---------------------------------------- . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")] . #[must_use = "this returns the result of the operation, \ . without modifying the original"] . #[inline] . #[rustc_inherit_overflow_checks] . pub const fn next_power_of_two(self) -> Self { 34,042 ( 0.00%) self.one_less_than_next_power_of_two() + 1 . } . . /// Returns the smallest power of two greater than or equal to `n`. If . /// the next power of two is greater than the type's maximum value, . /// `None` is returned, otherwise the power of two is wrapped in `Some`. . /// . /// # Examples . /// -- line 2195 ---------------------------------------- 376,170 ( 0.01%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/library/alloc/src/collections/vec_deque/mod.rs -------------------------------------------------------------------------------- Ir -- line 126 ---------------------------------------- . self.extend(remainder.iter().cloned()); . } . } . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . unsafe impl<#[may_dangle] T, A: Allocator> Drop for VecDeque { 3,871 ( 0.00%) fn drop(&mut self) { . /// Runs the destructor for all items in the slice when it gets dropped (normally or . /// during unwinding). . struct Dropper<'a, T>(&'a mut [T]); . . impl<'a, T> Drop for Dropper<'a, T> { . fn drop(&mut self) { . unsafe { . ptr::drop_in_place(self.0); -- line 142 ---------------------------------------- -- line 146 ---------------------------------------- . . let (front, back) = self.as_mut_slices(); . unsafe { . let _back_dropper = Dropper(back); . // use drop for [T] . ptr::drop_in_place(front); . } . // RawVec handles deallocation 4,424 ( 0.00%) } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Default for VecDeque { . /// Creates an empty `VecDeque`. . #[inline] . fn default() -> VecDeque { . VecDeque::new() . } . } . . impl VecDeque { . /// Marginally more convenient . #[inline] . fn ptr(&self) -> *mut T { 1,404,673 ( 0.02%) self.buf.ptr() . } . . /// Marginally more convenient . #[inline] . fn cap(&self) -> usize { . if mem::size_of::() == 0 { . // For zero sized types, we are always at maximum capacity . MAXIMUM_ZST_CAPACITY . } else { 1,579,761 ( 0.03%) self.buf.capacity() . } . } . . /// Turn ptr into a slice . #[inline] . unsafe fn buffer_as_slice(&self) -> &[T] { . unsafe { slice::from_raw_parts(self.ptr(), self.cap()) } . } -- line 188 ---------------------------------------- -- line 191 ---------------------------------------- . #[inline] . unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] { . unsafe { slice::from_raw_parts_mut(self.ptr(), self.cap()) } . } . . /// Moves an element out of the buffer . #[inline] . unsafe fn buffer_read(&mut self, off: usize) -> T { 73,805 ( 0.00%) unsafe { ptr::read(self.ptr().add(off)) } . } . . /// Writes an element into the buffer, moving it. . #[inline] . unsafe fn buffer_write(&mut self, off: usize, value: T) { . unsafe { . ptr::write(self.ptr().add(off), value); . } . } . . /// Returns `true` if the buffer is at full capacity. . #[inline] . fn is_full(&self) -> bool { 3,443,355 ( 0.06%) self.cap() - self.len() == 1 . } . . /// Returns the index in the underlying buffer for a given logical element . /// index. . #[inline] . fn wrap_index(&self, idx: usize) -> usize { . wrap_index(idx, self.cap()) . } -- line 221 ---------------------------------------- -- line 452 ---------------------------------------- . // [o o . o o o o o ] . // T H . // B [. . . o o o o o o o . . . . . . ] . // H T . // [o o o o o . o o ] . // H T . // C [o o o o o . . . . . . . . . o o ] . 1,940 ( 0.00%) if self.tail <= self.head { . // A . // Nop 393 ( 0.00%) } else if self.head < old_capacity - self.tail { . // B . unsafe { 12 ( 0.00%) self.copy_nonoverlapping(old_capacity, 0, self.head); . } 180 ( 0.00%) self.head += old_capacity; . debug_assert!(self.head > self.tail); . } else { . // C 64 ( 0.00%) let new_tail = new_capacity - (old_capacity - self.tail); . unsafe { 2 ( 0.00%) self.copy_nonoverlapping(new_tail, self.tail, old_capacity - self.tail); . } 32 ( 0.00%) self.tail = new_tail; . debug_assert!(self.head < self.tail); . } . debug_assert!(self.head < self.cap()); . debug_assert!(self.tail < self.cap()); . debug_assert!(self.cap().count_ones() == 1); . } . } . -- line 484 ---------------------------------------- -- line 507 ---------------------------------------- . /// use std::collections::VecDeque; . /// . /// let vector: VecDeque = VecDeque::with_capacity(10); . /// ``` . #[inline] . #[stable(feature = "rust1", since = "1.0.0")] . #[must_use] . pub fn with_capacity(capacity: usize) -> VecDeque { 4,196 ( 0.00%) Self::with_capacity_in(capacity, Global) . } . } . . impl VecDeque { . /// Creates an empty `VecDeque`. . /// . /// # Examples . /// -- line 523 ---------------------------------------- -- line 524 ---------------------------------------- . /// ``` . /// use std::collections::VecDeque; . /// . /// let vector: VecDeque = VecDeque::new(); . /// ``` . #[inline] . #[unstable(feature = "allocator_api", issue = "32838")] . pub fn new_in(alloc: A) -> VecDeque { 614 ( 0.00%) VecDeque::with_capacity_in(INITIAL_CAPACITY, alloc) . } . . /// Creates an empty `VecDeque` with space for at least `capacity` elements. . /// . /// # Examples . /// . /// ``` . /// use std::collections::VecDeque; . /// . /// let vector: VecDeque = VecDeque::with_capacity(10); . /// ``` . #[unstable(feature = "allocator_api", issue = "32838")] 9,620 ( 0.00%) pub fn with_capacity_in(capacity: usize, alloc: A) -> VecDeque { 7,960 ( 0.00%) assert!(capacity < 1_usize << usize::BITS - 1, "capacity overflow"); . // +1 since the ringbuffer always leaves one space empty . let cap = cmp::max(capacity + 1, MINIMUM_CAPACITY + 1).next_power_of_two(); . 13,218 ( 0.00%) VecDeque { tail: 0, head: 0, buf: RawVec::with_capacity_in(cap, alloc) } 14,430 ( 0.00%) } . . /// Provides a reference to the element at the given index. . /// . /// Element at index 0 is the front of the queue. . /// . /// # Examples . /// . /// ``` -- line 559 ---------------------------------------- -- line 562 ---------------------------------------- . /// let mut buf = VecDeque::new(); . /// buf.push_back(3); . /// buf.push_back(4); . /// buf.push_back(5); . /// assert_eq!(buf.get(1), Some(&4)); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn get(&self, index: usize) -> Option<&T> { 5,379,600 ( 0.09%) if index < self.len() { . let idx = self.wrap_add(self.tail, index); . unsafe { Some(&*self.ptr().add(idx)) } . } else { . None . } . } . . /// Provides a mutable reference to the element at the given index. -- line 578 ---------------------------------------- -- line 591 ---------------------------------------- . /// if let Some(elem) = buf.get_mut(1) { . /// *elem = 7; . /// } . /// . /// assert_eq!(buf[1], 7); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn get_mut(&mut self, index: usize) -> Option<&mut T> { 2,508,130 ( 0.04%) if index < self.len() { . let idx = self.wrap_add(self.tail, index); . unsafe { Some(&mut *self.ptr().add(idx)) } . } else { . None . } . } . . /// Swaps elements at indices `i` and `j`. -- line 607 ---------------------------------------- -- line 694 ---------------------------------------- . /// . /// let mut buf: VecDeque = [1].into(); . /// buf.reserve(10); . /// assert!(buf.capacity() >= 11); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn reserve(&mut self, additional: usize) { . let old_cap = self.cap(); 8 ( 0.00%) let used_cap = self.len() + 1; . let new_cap = used_cap . .checked_add(additional) . .and_then(|needed_cap| needed_cap.checked_next_power_of_two()) . .expect("capacity overflow"); . 16 ( 0.00%) if new_cap > old_cap { 24 ( 0.00%) self.buf.reserve_exact(used_cap, new_cap - used_cap); . unsafe { . self.handle_capacity_increase(old_cap); . } . } . } . . /// Tries to reserve the minimum capacity for exactly `additional` more elements to . /// be inserted in the given `VecDeque`. After calling `try_reserve_exact`, -- line 717 ---------------------------------------- -- line 924 ---------------------------------------- . /// buf.push_back(5); . /// buf.push_back(10); . /// buf.push_back(15); . /// assert_eq!(buf, [5, 10, 15]); . /// buf.truncate(1); . /// assert_eq!(buf, [5]); . /// ``` . #[stable(feature = "deque_extras", since = "1.16.0")] 760 ( 0.00%) pub fn truncate(&mut self, len: usize) { . /// Runs the destructor for all items in the slice when it gets dropped (normally or . /// during unwinding). . struct Dropper<'a, T>(&'a mut [T]); . . impl<'a, T> Drop for Dropper<'a, T> { . fn drop(&mut self) { . unsafe { . ptr::drop_in_place(self.0); -- line 940 ---------------------------------------- -- line 945 ---------------------------------------- . // Safe because: . // . // * Any slice passed to `drop_in_place` is valid; the second case has . // `len <= front.len()` and returning on `len > self.len()` ensures . // `begin <= back.len()` in the first case . // * The head of the VecDeque is moved before calling `drop_in_place`, . // so no value is dropped twice if `drop_in_place` panics . unsafe { 190 ( 0.00%) if len > self.len() { . return; . } . let num_dropped = self.len() - len; . let (front, back) = self.as_mut_slices(); 190 ( 0.00%) if len > front.len() { . let begin = len - front.len(); . let drop_back = back.get_unchecked_mut(begin..) as *mut _; . self.head = self.wrap_sub(self.head, num_dropped); . ptr::drop_in_place(drop_back); . } else { . let drop_back = back as *mut _; . let drop_front = front.get_unchecked_mut(len..) as *mut _; 95 ( 0.00%) self.head = self.wrap_sub(self.head, num_dropped); . . // Make sure the second half is dropped even when a destructor . // in the first one panics. . let _back_dropper = Dropper(&mut *drop_back); . ptr::drop_in_place(drop_front); . } . } 760 ( 0.00%) } . . /// Returns a reference to the underlying allocator. . #[unstable(feature = "allocator_api", issue = "32838")] . #[inline] . pub fn allocator(&self) -> &A { . self.buf.allocator() . } . -- line 982 ---------------------------------------- -- line 1085 ---------------------------------------- . /// vector.as_mut_slices().0[0] = 42; . /// vector.as_mut_slices().1[0] = 24; . /// assert_eq!(vector.as_slices(), (&[42, 10][..], &[24, 1][..])); . /// ``` . #[inline] . #[stable(feature = "deque_extras_15", since = "1.5.0")] . pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) { . unsafe { 4,780 ( 0.00%) let head = self.head; 4,780 ( 0.00%) let tail = self.tail; 5,855 ( 0.00%) let buf = self.buffer_as_mut_slice(); . RingSlices::ring_slices(buf, head, tail) . } . } . . /// Returns the number of elements in the `VecDeque`. . /// . /// # Examples . /// -- line 1103 ---------------------------------------- -- line 1106 ---------------------------------------- . /// . /// let mut v = VecDeque::new(); . /// assert_eq!(v.len(), 0); . /// v.push_back(1); . /// assert_eq!(v.len(), 1); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn len(&self) -> usize { 2,452,798 ( 0.04%) count(self.tail, self.head, self.cap()) . } . . /// Returns `true` if the `VecDeque` is empty. . /// . /// # Examples . /// . /// ``` . /// use std::collections::VecDeque; -- line 1122 ---------------------------------------- -- line 1123 ---------------------------------------- . /// . /// let mut v = VecDeque::new(); . /// assert!(v.is_empty()); . /// v.push_front(1); . /// assert!(!v.is_empty()); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn is_empty(&self) -> bool { 4,709,847 ( 0.08%) self.tail == self.head . } . . fn range_tail_head(&self, range: R) -> (usize, usize) . where . R: RangeBounds, . { . let Range { start, end } = slice::range(range, ..self.len()); . let tail = self.wrap_add(self.tail, start); -- line 1139 ---------------------------------------- -- line 1307 ---------------------------------------- . /// let mut v = VecDeque::new(); . /// v.push_back(1); . /// v.clear(); . /// assert!(v.is_empty()); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . #[inline] . pub fn clear(&mut self) { 190 ( 0.00%) self.truncate(0); . } . . /// Returns `true` if the `VecDeque` contains an element equal to the . /// given value. . /// . /// # Examples . /// . /// ``` -- line 1323 ---------------------------------------- -- line 1396 ---------------------------------------- . /// assert_eq!(d.back(), None); . /// . /// d.push_back(1); . /// d.push_back(2); . /// assert_eq!(d.back(), Some(&2)); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn back(&self) -> Option<&T> { 138,766 ( 0.00%) self.get(self.len().wrapping_sub(1)) . } . . /// Provides a mutable reference to the back element, or `None` if the . /// `VecDeque` is empty. . /// . /// # Examples . /// . /// ``` -- line 1412 ---------------------------------------- -- line 1441 ---------------------------------------- . /// d.push_back(2); . /// . /// assert_eq!(d.pop_front(), Some(1)); . /// assert_eq!(d.pop_front(), Some(2)); . /// assert_eq!(d.pop_front(), None); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn pop_front(&mut self) -> Option { 774,723 ( 0.01%) if self.is_empty() { . None . } else { . let tail = self.tail; 1,467,255 ( 0.03%) self.tail = self.wrap_add(self.tail, 1); 25,366 ( 0.00%) unsafe { Some(self.buffer_read(tail)) } . } . } . . /// Removes the last element from the `VecDeque` and returns it, or `None` if . /// it is empty. . /// . /// # Examples . /// -- line 1462 ---------------------------------------- -- line 1466 ---------------------------------------- . /// let mut buf = VecDeque::new(); . /// assert_eq!(buf.pop_back(), None); . /// buf.push_back(1); . /// buf.push_back(3); . /// assert_eq!(buf.pop_back(), Some(3)); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] . pub fn pop_back(&mut self) -> Option { 408,157 ( 0.01%) if self.is_empty() { . None . } else { 674,987 ( 0.01%) self.head = self.wrap_sub(self.head, 1); . let head = self.head; . unsafe { Some(self.buffer_read(head)) } . } . } . . /// Prepends an element to the `VecDeque`. . /// . /// # Examples -- line 1485 ---------------------------------------- -- line 1513 ---------------------------------------- . /// use std::collections::VecDeque; . /// . /// let mut buf = VecDeque::new(); . /// buf.push_back(1); . /// buf.push_back(3); . /// assert_eq!(3, *buf.back().unwrap()); . /// ``` . #[stable(feature = "rust1", since = "1.0.0")] 2,804,952 ( 0.05%) pub fn push_back(&mut self, value: T) { 3,443,339 ( 0.06%) if self.is_full() { 851 ( 0.00%) self.grow(); . } . 477 ( 0.00%) let head = self.head; 1,148,254 ( 0.02%) self.head = self.wrap_add(self.head, 1); 446,539 ( 0.01%) unsafe { self.buffer_write(head, value) } 2,804,952 ( 0.05%) } . . #[inline] . fn is_contiguous(&self) -> bool { . // FIXME: Should we consider `head == 0` to mean . // that `self` is contiguous? . self.tail <= self.head . } . -- line 1537 ---------------------------------------- -- line 2209 ---------------------------------------- . self.truncate(idx); . } . } . . // Double the buffer size. This method is inline(never), so we expect it to only . // be called in cold paths. . // This may panic or abort . #[inline(never)] 2,862 ( 0.00%) fn grow(&mut self) { . // Extend or possibly remove this assertion when valid use-cases for growing the . // buffer without it being full emerge . debug_assert!(self.is_full()); . let old_cap = self.cap(); 1,431 ( 0.00%) self.buf.reserve_exact(old_cap, old_cap); 2,385 ( 0.00%) assert!(self.cap() == old_cap * 2); . unsafe { . self.handle_capacity_increase(old_cap); . } . debug_assert!(!self.is_full()); 2,862 ( 0.00%) } . . /// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`, . /// either by removing excess elements from the back or by appending . /// elements generated by calling `generator` to the back. . /// . /// # Examples . /// . /// ``` -- line 2236 ---------------------------------------- -- line 2751 ---------------------------------------- . } . } . . /// Returns the index in the underlying buffer for a given logical element index. . #[inline] . fn wrap_index(index: usize, size: usize) -> usize { . // size is always a power of 2 . debug_assert!(size.is_power_of_two()); 6,047,913 ( 0.11%) index & (size - 1) . } . . /// Calculate the number of elements left to be read in the buffer . #[inline] . fn count(tail: usize, head: usize, size: usize) -> usize { . // size is always a power of 2 10,196,380 ( 0.18%) (head.wrapping_sub(tail)) & (size - 1) . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl PartialEq for VecDeque { . fn eq(&self, other: &Self) -> bool { . if self.len() != other.len() { . return false; . } -- line 2774 ---------------------------------------- -- line 2902 ---------------------------------------- . . fn into_iter(self) -> IterMut<'a, T> { . self.iter_mut() . } . } . . #[stable(feature = "rust1", since = "1.0.0")] . impl Extend for VecDeque { 1,064 ( 0.00%) fn extend>(&mut self, iter: I) { . // This function should be the moral equivalent of: . // . // for item in iter.into_iter() { . // self.push_back(item); . // } . let mut iter = iter.into_iter(); . while let Some(element) = iter.next() { 1,149 ( 0.00%) if self.len() == self.capacity() { . let (lower, _) = iter.size_hint(); . self.reserve(lower.saturating_add(1)); . } . . let head = self.head; 269 ( 0.00%) self.head = self.wrap_add(self.head, 1); . unsafe { 144 ( 0.00%) self.buffer_write(head, element); . } . } 1,216 ( 0.00%) } . . #[inline] . fn extend_one(&mut self, elem: T) { . self.push_back(elem); . } . . #[inline] . fn extend_reserve(&mut self, additional: usize) { -- line 2937 ---------------------------------------- 1,954,961 ( 0.03%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_lint/src/late.rs -------------------------------------------------------------------------------- Ir -- line 29 ---------------------------------------- . . use std::any::Any; . use std::cell::Cell; . use std::slice; . use tracing::debug; . . /// Extract the `LintStore` from the query context. . /// This function exists because we've erased `LintStore` as `dyn Any` in the context. 2 ( 0.00%) crate fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore { 41 ( 0.00%) let store: &dyn Any = &*tcx.lint_store; . store.downcast_ref().unwrap() 6 ( 0.00%) } . . macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({ . $cx.pass.$f(&$cx.context, $($args),*); . }) } . . struct LateContextAndPass<'tcx, T: LateLintPass<'tcx>> { . context: LateContext<'tcx>, . pass: T, -- line 48 ---------------------------------------- -- line 51 ---------------------------------------- . impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> { . /// Merge the lints specified by any lint attributes into the . /// current lint context, call the provided function, then reset the . /// lints in effect to their previous state. . fn with_lint_attrs(&mut self, id: hir::HirId, f: F) . where . F: FnOnce(&mut Self), . { 2,202,554 ( 0.04%) let attrs = self.context.tcx.hir().attrs(id); 42,065 ( 0.00%) let prev = self.context.last_node_with_lint_attrs; 1,012,826 ( 0.02%) self.context.last_node_with_lint_attrs = id; . self.enter_attrs(attrs); . f(self); . self.exit_attrs(attrs); 1,151,049 ( 0.02%) self.context.last_node_with_lint_attrs = prev; . } . . fn with_param_env(&mut self, id: hir::HirId, f: F) . where . F: FnOnce(&mut Self), . { 1,380 ( 0.00%) let old_param_env = self.context.param_env; 1,872 ( 0.00%) self.context.param_env = 4,830 ( 0.00%) self.context.tcx.param_env(self.context.tcx.hir().local_def_id(id)); . f(self); 2,070 ( 0.00%) self.context.param_env = old_param_env; . } . . fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) { 152 ( 0.00%) lint_callback!(self, check_mod, m, s, n); . hir_visit::walk_mod(self, m, n); 259 ( 0.00%) lint_callback!(self, check_mod_post, m, s, n); . } . . fn enter_attrs(&mut self, attrs: &'tcx [ast::Attribute]) { . debug!("late context: enter_attrs({:?})", attrs); 748,590 ( 0.01%) lint_callback!(self, enter_lint_attrs, attrs); . } . . fn exit_attrs(&mut self, attrs: &'tcx [ast::Attribute]) { . debug!("late context: exit_attrs({:?})", attrs); 1,030,079 ( 0.02%) lint_callback!(self, exit_lint_attrs, attrs); . } . } . . impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPass<'tcx, T> { . type NestedFilter = nested_filter::All; . . /// Because lints are scoped lexically, we want to walk nested . /// items in the context of the outer item, so enable . /// deep-walking. . fn nested_visit_map(&mut self) -> Self::Map { . self.context.tcx.hir() . } . 5,937 ( 0.00%) fn visit_nested_body(&mut self, body_id: hir::BodyId) { . let old_enclosing_body = self.context.enclosing_body.replace(body_id); 785 ( 0.00%) let old_cached_typeck_results = self.context.cached_typeck_results.get(); . . // HACK(eddyb) avoid trashing `cached_typeck_results` when we're . // nested in `visit_fn`, which may have already resulted in them . // being queried. 2,127 ( 0.00%) if old_enclosing_body != Some(body_id) { . self.context.cached_typeck_results.set(None); . } . 5,871 ( 0.00%) let body = self.context.tcx.hir().body(body_id); . self.visit_body(body); 1,861 ( 0.00%) self.context.enclosing_body = old_enclosing_body; . . // See HACK comment above. 2,076 ( 0.00%) if old_enclosing_body != Some(body_id) { . self.context.cached_typeck_results.set(old_cached_typeck_results); . } 5,536 ( 0.00%) } . 3,807 ( 0.00%) fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) { 1,768 ( 0.00%) self.with_lint_attrs(param.hir_id, |cx| { 1,768 ( 0.00%) lint_callback!(cx, check_param, param); . hir_visit::walk_param(cx, param); . }); 3,384 ( 0.00%) } . . fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) { 2,005 ( 0.00%) lint_callback!(self, check_body, body); 1,533 ( 0.00%) hir_visit::walk_body(self, body); 2,005 ( 0.00%) lint_callback!(self, check_body_post, body); . } . . fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) { . let generics = self.context.generics.take(); 2,952 ( 0.00%) self.context.generics = it.kind.generics(); . let old_cached_typeck_results = self.context.cached_typeck_results.take(); . let old_enclosing_body = self.context.enclosing_body.take(); 984 ( 0.00%) self.with_lint_attrs(it.hir_id(), |cx| { 2,952 ( 0.00%) cx.with_param_env(it.hir_id(), |cx| { 3,936 ( 0.00%) lint_callback!(cx, check_item, it); 3,444 ( 0.00%) hir_visit::walk_item(cx, it); 1,968 ( 0.00%) lint_callback!(cx, check_item_post, it); . }); . }); 2,460 ( 0.00%) self.context.enclosing_body = old_enclosing_body; . self.context.cached_typeck_results.set(old_cached_typeck_results); 984 ( 0.00%) self.context.generics = generics; . } . . fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) { . self.with_lint_attrs(it.hir_id(), |cx| { . cx.with_param_env(it.hir_id(), |cx| { . lint_callback!(cx, check_foreign_item, it); . hir_visit::walk_foreign_item(cx, it); . lint_callback!(cx, check_foreign_item_post, it); . }); . }) . } . . fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) { 5,882 ( 0.00%) lint_callback!(self, check_pat, p); 8,440 ( 0.00%) hir_visit::walk_pat(self, p); . } . 1,428 ( 0.00%) fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) { 578,326 ( 0.01%) self.with_lint_attrs(e.hir_id, |cx| { 1,152,767 ( 0.02%) lint_callback!(cx, check_expr, e); 867,966 ( 0.02%) hir_visit::walk_expr(cx, e); 575,679 ( 0.01%) lint_callback!(cx, check_expr_post, e); . }) 1,260 ( 0.00%) } . . fn visit_stmt(&mut self, s: &'tcx hir::Stmt<'tcx>) { . // See `EarlyContextAndPass::visit_stmt` for an explanation . // of why we call `walk_stmt` outside of `with_lint_attrs` 1,752 ( 0.00%) self.with_lint_attrs(s.hir_id, |cx| { 1,752 ( 0.00%) lint_callback!(cx, check_stmt, s); . }); 3,504 ( 0.00%) hir_visit::walk_stmt(self, s); . } . 3,201 ( 0.00%) fn visit_fn( . &mut self, . fk: hir_visit::FnKind<'tcx>, . decl: &'tcx hir::FnDecl<'tcx>, . body_id: hir::BodyId, . span: Span, . id: hir::HirId, . ) { . // Wrap in typeck results here, not just in visit_nested_body, . // in order for `check_fn` to be able to use them. . let old_enclosing_body = self.context.enclosing_body.replace(body_id); . let old_cached_typeck_results = self.context.cached_typeck_results.take(); 4,586 ( 0.00%) let body = self.context.tcx.hir().body(body_id); 7,773 ( 0.00%) lint_callback!(self, check_fn, fk, decl, body, span, id); 5,056 ( 0.00%) hir_visit::walk_fn(self, fk, decl, body_id, span, id); 5,842 ( 0.00%) lint_callback!(self, check_fn_post, fk, decl, body, span, id); 1,283 ( 0.00%) self.context.enclosing_body = old_enclosing_body; . self.context.cached_typeck_results.set(old_cached_typeck_results); 2,328 ( 0.00%) } . . fn visit_variant_data( . &mut self, . s: &'tcx hir::VariantData<'tcx>, . _: Symbol, . _: &'tcx hir::Generics<'tcx>, . _: hir::HirId, . _: Span, . ) { 148 ( 0.00%) lint_callback!(self, check_struct_def, s); . hir_visit::walk_struct_def(self, s); 220 ( 0.00%) lint_callback!(self, check_struct_def_post, s); . } . 1,116 ( 0.00%) fn visit_field_def(&mut self, s: &'tcx hir::FieldDef<'tcx>) { 248 ( 0.00%) self.with_lint_attrs(s.hir_id, |cx| { 248 ( 0.00%) lint_callback!(cx, check_field_def, s); . hir_visit::walk_field_def(cx, s); . }) 992 ( 0.00%) } . . fn visit_variant( . &mut self, . v: &'tcx hir::Variant<'tcx>, . g: &'tcx hir::Generics<'tcx>, . item_id: hir::HirId, . ) { 88 ( 0.00%) self.with_lint_attrs(v.id, |cx| { 88 ( 0.00%) lint_callback!(cx, check_variant, v); 286 ( 0.00%) hir_visit::walk_variant(cx, v, g, item_id); 88 ( 0.00%) lint_callback!(cx, check_variant_post, v); . }) . } . . fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) { 7,213 ( 0.00%) lint_callback!(self, check_ty, t); 11,370 ( 0.00%) hir_visit::walk_ty(self, t); . } . . fn visit_infer(&mut self, inf: &'tcx hir::InferArg) { . lint_callback!(self, check_infer, inf); . hir_visit::walk_inf(self, inf); . } . . fn visit_name(&mut self, sp: Span, name: Symbol) { 35,984 ( 0.00%) lint_callback!(self, check_name, sp, name); . } . . fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) { 74 ( 0.00%) if !self.context.only_module { . self.process_mod(m, s, n); . } . } . . fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) { 888 ( 0.00%) self.with_lint_attrs(l.hir_id, |cx| { 888 ( 0.00%) lint_callback!(cx, check_local, l); 1,332 ( 0.00%) hir_visit::walk_local(cx, l); . }) . } . . fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) { . lint_callback!(self, check_block, b); . hir_visit::walk_block(self, b); . lint_callback!(self, check_block_post, b); . } . . fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) { 828 ( 0.00%) lint_callback!(self, check_arm, a); 1,656 ( 0.00%) hir_visit::walk_arm(self, a); . } . . fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) { 720 ( 0.00%) lint_callback!(self, check_generic_param, p); 1,441 ( 0.00%) hir_visit::walk_generic_param(self, p); . } . . fn visit_generics(&mut self, g: &'tcx hir::Generics<'tcx>) { 2,185 ( 0.00%) lint_callback!(self, check_generics, g); 1,202 ( 0.00%) hir_visit::walk_generics(self, g); . } . . fn visit_where_predicate(&mut self, p: &'tcx hir::WherePredicate<'tcx>) { 80 ( 0.00%) lint_callback!(self, check_where_predicate, p); 140 ( 0.00%) hir_visit::walk_where_predicate(self, p); . } . . fn visit_poly_trait_ref( . &mut self, . t: &'tcx hir::PolyTraitRef<'tcx>, . m: hir::TraitBoundModifier, . ) { 672 ( 0.00%) lint_callback!(self, check_poly_trait_ref, t, m); . hir_visit::walk_poly_trait_ref(self, t, m); . } . . fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { . let generics = self.context.generics.take(); 2 ( 0.00%) self.context.generics = Some(&trait_item.generics); 2 ( 0.00%) self.with_lint_attrs(trait_item.hir_id(), |cx| { 6 ( 0.00%) cx.with_param_env(trait_item.hir_id(), |cx| { 5 ( 0.00%) lint_callback!(cx, check_trait_item, trait_item); 7 ( 0.00%) hir_visit::walk_trait_item(cx, trait_item); 5 ( 0.00%) lint_callback!(cx, check_trait_item_post, trait_item); . }); . }); 2 ( 0.00%) self.context.generics = generics; . } . . fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) { . let generics = self.context.generics.take(); 788 ( 0.00%) self.context.generics = Some(&impl_item.generics); 394 ( 0.00%) self.with_lint_attrs(impl_item.hir_id(), |cx| { 1,182 ( 0.00%) cx.with_param_env(impl_item.hir_id(), |cx| { 985 ( 0.00%) lint_callback!(cx, check_impl_item, impl_item); 1,379 ( 0.00%) hir_visit::walk_impl_item(cx, impl_item); 985 ( 0.00%) lint_callback!(cx, check_impl_item_post, impl_item); . }); . }); 394 ( 0.00%) self.context.generics = generics; . } . . fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) { 2,640 ( 0.00%) lint_callback!(self, check_lifetime, lt); . hir_visit::walk_lifetime(self, lt); . } . 4,284 ( 0.00%) fn visit_path(&mut self, p: &'tcx hir::Path<'tcx>, id: hir::HirId) { 30,058 ( 0.00%) lint_callback!(self, check_path, p, id); . hir_visit::walk_path(self, p); 3,808 ( 0.00%) } . . fn visit_attribute(&mut self, hir_id: hir::HirId, attr: &'tcx ast::Attribute) { . self.with_lint_attrs(hir_id, |cx| { 6,932 ( 0.00%) lint_callback!(cx, check_attribute, attr); . }) . } . } . . struct LateLintPassObjects<'a> { . lints: &'a mut [LateLintPassObject], . } . -- line 350 ---------------------------------------- -- line 389 ---------------------------------------- . param_env: ty::ParamEnv::empty(), . access_levels, . lint_store: unerased_lint_store(tcx), . last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id), . generics: None, . only_module: true, . }; . 342 ( 0.00%) let mut cx = LateContextAndPass { context, pass }; . 209 ( 0.00%) let (module, span, hir_id) = tcx.hir().get_module(module_def_id); . cx.process_mod(module, span, hir_id); . . // Visit the crate attributes 57 ( 0.00%) if hir_id == hir::CRATE_HIR_ID { 5 ( 0.00%) for attr in tcx.hir().attrs(hir::CRATE_HIR_ID).iter() { . cx.visit_attribute(hir_id, attr) . } . } . } . 133 ( 0.00%) pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx>>( . tcx: TyCtxt<'tcx>, . module_def_id: LocalDefId, . builtin_lints: T, . ) { 57 ( 0.00%) if tcx.sess.opts.debugging_opts.no_interleave_lints { . // These passes runs in late_lint_crate with -Z no_interleave_lints . return; . } . . late_lint_mod_pass(tcx, module_def_id, builtin_lints); . . let mut passes: Vec<_> = . unerased_lint_store(tcx).late_module_passes.iter().map(|pass| (pass)()).collect(); . 19 ( 0.00%) if !passes.is_empty() { . late_lint_mod_pass(tcx, module_def_id, LateLintPassObjects { lints: &mut passes[..] }); . } 152 ( 0.00%) } . . fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T) { . let access_levels = &tcx.privacy_access_levels(()); . . let context = LateContext { . tcx, . enclosing_body: None, . cached_typeck_results: Cell::new(None), . param_env: ty::ParamEnv::empty(), . access_levels, 2 ( 0.00%) lint_store: unerased_lint_store(tcx), . last_node_with_lint_attrs: hir::CRATE_HIR_ID, . generics: None, . only_module: false, . }; . 16 ( 0.00%) let mut cx = LateContextAndPass { context, pass }; . . // Visit the whole crate. . cx.with_lint_attrs(hir::CRATE_HIR_ID, |cx| { . // since the root module isn't visited as an item (because it isn't an . // item), warn for it here. 2 ( 0.00%) lint_callback!(cx, check_crate,); 1 ( 0.00%) tcx.hir().walk_toplevel_module(cx); 1 ( 0.00%) tcx.hir().walk_attributes(cx); 2 ( 0.00%) lint_callback!(cx, check_crate_post,); . }) . } . 10 ( 0.00%) fn late_lint_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, builtin_lints: T) { 1 ( 0.00%) let mut passes = unerased_lint_store(tcx).late_passes.iter().map(|p| (p)()).collect::>(); . 6 ( 0.00%) if !tcx.sess.opts.debugging_opts.no_interleave_lints { 1 ( 0.00%) if !passes.is_empty() { . late_lint_pass_crate(tcx, LateLintPassObjects { lints: &mut passes[..] }); . } . 4 ( 0.00%) late_lint_pass_crate(tcx, builtin_lints); . } else { . for pass in &mut passes { . tcx.sess.prof.extra_verbose_generic_activity("run_late_lint", pass.name()).run(|| { . late_lint_pass_crate(tcx, LateLintPassObjects { lints: slice::from_mut(pass) }); . }); . } . . let mut passes: Vec<_> = -- line 474 ---------------------------------------- -- line 477 ---------------------------------------- . for pass in &mut passes { . tcx.sess.prof.extra_verbose_generic_activity("run_late_module_lint", pass.name()).run( . || { . late_lint_pass_crate(tcx, LateLintPassObjects { lints: slice::from_mut(pass) }); . }, . ); . } . } 9 ( 0.00%) } . . /// Performs lint checking on a crate. . pub fn check_crate<'tcx, T: LateLintPass<'tcx>>( . tcx: TyCtxt<'tcx>, . builtin_lints: impl FnOnce() -> T + Send, . ) { . join( . || { 5 ( 0.00%) tcx.sess.time("crate_lints", || { . // Run whole crate non-incremental lints 4 ( 0.00%) late_lint_crate(tcx, builtin_lints()); . }); . }, . || { 5 ( 0.00%) tcx.sess.time("module_lints", || { . // Run per-module lints 1 ( 0.00%) tcx.hir().par_for_each_module(|module| tcx.ensure().lint_mod(module)); . }); . }, . ); . } 2,251 ( 0.00%) -------------------------------------------------------------------------------- -- Auto-annotated source: /usr/home/liquid/rust/worktree-benchmarking/compiler/rustc_resolve/src/late.rs -------------------------------------------------------------------------------- Ir -- line 141 ---------------------------------------- . /// parameters. . ConstParamTyRibKind, . } . . impl RibKind<'_> { . /// Whether this rib kind contains generic parameters, as opposed to local . /// variables. . crate fn contains_params(&self) -> bool { 202,279 ( 0.00%) match self { . NormalRibKind . | ClosureOrAsyncRibKind . | FnItemRibKind . | ConstantItemRibKind(..) . | ModuleRibKind(_) . | MacroDefinition(_) . | ConstParamTyRibKind => false, . AssocItemRibKind | ItemRibKind(_) | ForwardGenericParamBanRibKind => true, -- line 157 ---------------------------------------- -- line 174 ---------------------------------------- . #[derive(Debug)] . crate struct Rib<'a, R = Res> { . pub bindings: IdentMap, . pub kind: RibKind<'a>, . } . . impl<'a, R> Rib<'a, R> { . fn new(kind: RibKind<'a>) -> Rib<'a, R> { 4,226 ( 0.00%) Rib { bindings: Default::default(), kind } . } . } . . #[derive(Copy, Clone, PartialEq, Eq, Debug)] . crate enum AliasPossibility { . No, . Maybe, . } -- line 190 ---------------------------------------- -- line 212 ---------------------------------------- . match self { . PathSource::Type | PathSource::Trait(_) | PathSource::Struct => TypeNS, . PathSource::Expr(..) | PathSource::Pat | PathSource::TupleStruct(..) => ValueNS, . PathSource::TraitItem(ns) => ns, . } . } . . fn defer_to_typeck(self) -> bool { 12,091 ( 0.00%) match self { . PathSource::Type . | PathSource::Expr(..) . | PathSource::Pat . | PathSource::Struct . | PathSource::TupleStruct(..) => true, . PathSource::Trait(_) | PathSource::TraitItem(..) => false, . } . } -- line 228 ---------------------------------------- -- line 268 ---------------------------------------- . } . } . . fn is_call(self) -> bool { . matches!(self, PathSource::Expr(Some(&Expr { kind: ExprKind::Call(..), .. }))) . } . . crate fn is_expected(self, res: Res) -> bool { 43,427 ( 0.00%) match self { 43,762 ( 0.00%) PathSource::Type => matches!( 11,128 ( 0.00%) res, . Res::Def( . DefKind::Struct . | DefKind::Union . | DefKind::Enum . | DefKind::Trait . | DefKind::TraitAlias . | DefKind::TyAlias . | DefKind::AssocTy . | DefKind::TyParam . | DefKind::OpaqueTy . | DefKind::ForeignTy, . _, . ) | Res::PrimTy(..) . | Res::SelfTy(..) . ), 327 ( 0.00%) PathSource::Trait(AliasPossibility::No) => matches!(res, Res::Def(DefKind::Trait, _)), . PathSource::Trait(AliasPossibility::Maybe) => { 784 ( 0.00%) matches!(res, Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) . } 8,501 ( 0.00%) PathSource::Expr(..) => matches!( 3,909 ( 0.00%) res, . Res::Def( . DefKind::Ctor(_, CtorKind::Const | CtorKind::Fn) . | DefKind::Const . | DefKind::Static . | DefKind::Fn . | DefKind::AssocFn . | DefKind::AssocConst . | DefKind::ConstParam, . _, . ) | Res::Local(..) . | Res::SelfCtor(..) . ), 108 ( 0.00%) PathSource::Pat => matches!( 72 ( 0.00%) res, . Res::Def( . DefKind::Ctor(_, CtorKind::Const) | DefKind::Const | DefKind::AssocConst, . _, . ) | Res::SelfCtor(..) . ), . PathSource::TupleStruct(..) => res.expected_in_tuple_struct_pat(), 1,096 ( 0.00%) PathSource::Struct => matches!( 822 ( 0.00%) res, . Res::Def( . DefKind::Struct . | DefKind::Union . | DefKind::Variant . | DefKind::TyAlias . | DefKind::AssocTy, . _, . ) | Res::SelfTy(..) . ), . PathSource::TraitItem(ns) => match res { . Res::Def(DefKind::AssocConst | DefKind::AssocFn, _) if ns == ValueNS => true, . Res::Def(DefKind::AssocTy, _) if ns == TypeNS => true, . _ => false, . }, . } 8,597 ( 0.00%) } . . fn error_code(self, has_unexpected_resolution: bool) -> DiagnosticId { . use rustc_errors::error_code; . match (self, has_unexpected_resolution) { . (PathSource::Trait(_), true) => error_code!(E0404), . (PathSource::Trait(_), false) => error_code!(E0405), . (PathSource::Type, true) => error_code!(E0573), . (PathSource::Type, false) => error_code!(E0412), -- line 345 ---------------------------------------- -- line 350 ---------------------------------------- . (PathSource::Pat | PathSource::TupleStruct(..), true) => error_code!(E0532), . (PathSource::Pat | PathSource::TupleStruct(..), false) => error_code!(E0531), . (PathSource::TraitItem(..), true) => error_code!(E0575), . (PathSource::TraitItem(..), false) => error_code!(E0576), . } . } . } . 2 ( 0.00%) #[derive(Default)] . struct DiagnosticMetadata<'ast> { . /// The current trait's associated items' ident, used for diagnostic suggestions. . current_trait_assoc_items: Option<&'ast [P]>, . . /// The current self type if inside an impl (used for better errors). . current_self_type: Option, . . /// The current self item if inside an ADT (used for better errors). -- line 366 ---------------------------------------- -- line 434 ---------------------------------------- . fn visit_attribute(&mut self, _: &'ast Attribute) { . // We do not want to resolve expressions that appear in attributes, . // as they do not correspond to actual code. . } . fn visit_item(&mut self, item: &'ast Item) { . let prev = replace(&mut self.diagnostic_metadata.current_item, Some(item)); . // Always report errors in items we just entered. . let old_ignore = replace(&mut self.in_func_body, false); 892 ( 0.00%) self.resolve_item(item); 446 ( 0.00%) self.in_func_body = old_ignore; 447 ( 0.00%) self.diagnostic_metadata.current_item = prev; . } 1,162 ( 0.00%) fn visit_arm(&mut self, arm: &'ast Arm) { . self.resolve_arm(arm); 996 ( 0.00%) } 5,391 ( 0.00%) fn visit_block(&mut self, block: &'ast Block) { . self.resolve_block(block); 4,792 ( 0.00%) } . fn visit_anon_const(&mut self, constant: &'ast AnonConst) { . // We deal with repeat expressions explicitly in `resolve_expr`. . self.resolve_anon_const(constant, IsRepeatExpr::No); . } . fn visit_expr(&mut self, expr: &'ast Expr) { 426,304 ( 0.01%) self.resolve_expr(expr, None); . } 1,998 ( 0.00%) fn visit_local(&mut self, local: &'ast Local) { 444 ( 0.00%) let local_spans = match local.pat.kind { . // We check for this to avoid tuple struct fields. . PatKind::Wild => None, . _ => Some(( . local.pat.span, . local.ty.as_ref().map(|ty| ty.span), 820 ( 0.00%) local.kind.init().map(|init| init.span), . )), . }; . let original = replace(&mut self.diagnostic_metadata.current_let_binding, local_spans); . self.resolve_local(local); 888 ( 0.00%) self.diagnostic_metadata.current_let_binding = original; 1,776 ( 0.00%) } 14,520 ( 0.00%) fn visit_ty(&mut self, ty: &'ast Ty) { 3,630 ( 0.00%) let prev = self.diagnostic_metadata.current_trait_object; 7,699 ( 0.00%) match ty.kind { 2,502 ( 0.00%) TyKind::Path(ref qself, ref path) => { 7,506 ( 0.00%) self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type); . } . TyKind::ImplicitSelf => { . let self_ty = Ident::with_dummy_span(kw::SelfUpper); . let res = self 152 ( 0.00%) .resolve_ident_in_lexical_scope(self_ty, TypeNS, Some(ty.id), ty.span) 912 ( 0.00%) .map_or(Res::Err, |d| d.res()); 1,672 ( 0.00%) self.r.record_partial_res(ty.id, PartialRes::new(res)); . } . TyKind::TraitObject(ref bounds, ..) => { 3 ( 0.00%) self.diagnostic_metadata.current_trait_object = Some(&bounds[..]); . } . _ => (), . } 5,445 ( 0.00%) visit::walk_ty(self, ty); 3,630 ( 0.00%) self.diagnostic_metadata.current_trait_object = prev; 12,705 ( 0.00%) } . fn visit_poly_trait_ref(&mut self, tref: &'ast PolyTraitRef, m: &'ast TraitBoundModifier) { 99 ( 0.00%) self.smart_resolve_path( 132 ( 0.00%) tref.trait_ref.ref_id, . None, 6 ( 0.00%) &tref.trait_ref.path, 51 ( 0.00%) PathSource::Trait(AliasPossibility::Maybe), . ); 80 ( 0.00%) visit::walk_poly_trait_ref(self, tref, m); . } . fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) { . match foreign_item.kind { . ForeignItemKind::Fn(box Fn { ref generics, .. }) . | ForeignItemKind::TyAlias(box TyAlias { ref generics, .. }) => { . self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { . visit::walk_foreign_item(this, foreign_item); . }); -- line 509 ---------------------------------------- -- line 513 ---------------------------------------- . visit::walk_foreign_item(this, foreign_item); . }); . } . ForeignItemKind::MacCall(..) => { . visit::walk_foreign_item(self, foreign_item); . } . } . } 2,781 ( 0.00%) fn visit_fn(&mut self, fn_kind: FnKind<'ast>, sp: Span, _: NodeId) { 5,320 ( 0.00%) let rib_kind = match fn_kind { . // Bail if the function is foreign, and thus cannot validly have . // a body, or if there's no body for some other reason. . FnKind::Fn(FnCtxt::Foreign, _, sig, ..) | FnKind::Fn(_, _, sig, .., None) => { . // We don't need to deal with patterns in parameters, because . // they are not possible for foreign or bodiless functions. . self.visit_fn_header(&sig.header); . visit::walk_fn_decl(self, &sig.decl); . return; . } . FnKind::Fn(FnCtxt::Free, ..) => FnItemRibKind, . FnKind::Fn(FnCtxt::Assoc(_), ..) => NormalRibKind, . FnKind::Closure(..) => ClosureOrAsyncRibKind, . }; 2,156 ( 0.00%) let previous_value = self.diagnostic_metadata.current_function; 616 ( 0.00%) if matches!(fn_kind, FnKind::Fn(..)) { 2,037 ( 0.00%) self.diagnostic_metadata.current_function = Some((fn_kind, sp)); . } . debug!("(resolving function) entering function"); 924 ( 0.00%) let declaration = fn_kind.decl(); . . // Create a value rib for the function. . self.with_rib(ValueNS, rib_kind, |this| { . // Create a label rib for the function. . this.with_label_rib(rib_kind, |this| { . // Add each argument to the rib. 616 ( 0.00%) this.resolve_params(&declaration.inputs); . . visit::walk_fn_ret_ty(this, &declaration.output); . . // Ignore errors in function bodies if this is rustdoc . // Be sure not to set this until the function signature has been resolved. . let previous_state = replace(&mut this.in_func_body, true); . // Resolve the function body, potentially inside the body of an async closure 616 ( 0.00%) match fn_kind { 1,455 ( 0.00%) FnKind::Fn(.., body) => walk_list!(this, visit_block, body), 17 ( 0.00%) FnKind::Closure(_, body) => this.visit_expr(body), . }; . . debug!("(resolving function) leaving function"); 308 ( 0.00%) this.in_func_body = previous_state; . }) . }); 1,848 ( 0.00%) self.diagnostic_metadata.current_function = previous_value; 2,464 ( 0.00%) } . 3,552 ( 0.00%) fn visit_generics(&mut self, generics: &'ast Generics) { . // For type parameter defaults, we have to ban access . // to following type parameters, as the InternalSubsts can only . // provide previous type parameters as they're built. We . // put all the parameters on the ban list and then remove . // them one by one as they are processed and become available. . let mut forward_ty_ban_rib = Rib::new(ForwardGenericParamBanRibKind); . let mut forward_const_ban_rib = Rib::new(ForwardGenericParamBanRibKind); . for param in generics.params.iter() { 1,661 ( 0.00%) match param.kind { . GenericParamKind::Type { .. } => { . forward_ty_ban_rib . .bindings 116 ( 0.00%) .insert(Ident::with_dummy_span(param.ident.name), Res::Err); . } . GenericParamKind::Const { .. } => { . forward_const_ban_rib . .bindings . .insert(Ident::with_dummy_span(param.ident.name), Res::Err); . } . GenericParamKind::Lifetime => {} . } -- line 589 ---------------------------------------- -- line 593 ---------------------------------------- . // another type parameter. For ADTs, we consider it . // well-defined only after all of the ADT type parameters have . // been provided. Therefore, we do not allow use of `Self` . // anywhere in ADT type parameter defaults. . // . // (We however cannot ban `Self` for defaults on *all* generic . // lists; e.g. trait generics can usefully refer to `Self`, . // such as in the case of `trait Add`.) 444 ( 0.00%) if self.diagnostic_metadata.current_self_item.is_some() { . // (`Some` if + only if we are in ADT's generics.) . forward_ty_ban_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), Res::Err); . } . . for param in &generics.params { 772 ( 0.00%) match param.kind { . GenericParamKind::Lifetime => self.visit_generic_param(param), . GenericParamKind::Type { ref default } => { . for bound in ¶m.bounds { . self.visit_param_bound(bound); . } . 696 ( 0.00%) if let Some(ref ty) = default { . self.ribs[TypeNS].push(forward_ty_ban_rib); . self.ribs[ValueNS].push(forward_const_ban_rib); . self.visit_ty(ty); . forward_const_ban_rib = self.ribs[ValueNS].pop().unwrap(); . forward_ty_ban_rib = self.ribs[TypeNS].pop().unwrap(); . } . . // Allow all following defaults to refer to this type parameter. 348 ( 0.00%) forward_ty_ban_rib.bindings.remove(&Ident::with_dummy_span(param.ident.name)); . } . GenericParamKind::Const { ref ty, kw_span: _, ref default } => { . // Const parameters can't have param bounds. . assert!(param.bounds.is_empty()); . . self.ribs[TypeNS].push(Rib::new(ConstParamTyRibKind)); . self.ribs[ValueNS].push(Rib::new(ConstParamTyRibKind)); . self.visit_ty(ty); -- line 631 ---------------------------------------- -- line 645 ---------------------------------------- . .bindings . .remove(&Ident::with_dummy_span(param.ident.name)); . } . } . } . for p in &generics.where_clause.predicates { . self.visit_where_predicate(p); . } 3,552 ( 0.00%) } . 3,456 ( 0.00%) fn visit_generic_arg(&mut self, arg: &'ast GenericArg) { . debug!("visit_generic_arg({:?})", arg); . let prev = replace(&mut self.diagnostic_metadata.currently_processing_generics, true); 1,954 ( 0.00%) match arg { . GenericArg::Type(ref ty) => { . // We parse const arguments as path types as we cannot distinguish them during . // parsing. We try to resolve that ambiguity by attempting resolution the type . // namespace first, and if that fails we try again in the value namespace. If . // resolution in the value namespace succeeds, we have an generic const argument on . // our hands. 658 ( 0.00%) if let TyKind::Path(ref qself, ref path) = ty.kind { . // We cannot disambiguate multi-segment paths right now as that requires type . // checking. 941 ( 0.00%) if path.segments.len() == 1 && path.segments[0].args.is_none() { . let mut check_ns = |ns| { . self.resolve_ident_in_lexical_scope( 466 ( 0.00%) path.segments[0].ident, . ns, . None, . path.span, . ) . .is_some() . }; 233 ( 0.00%) if !check_ns(TypeNS) && check_ns(ValueNS) { . // This must be equivalent to `visit_anon_const`, but we cannot call it . // directly due to visitor lifetimes so we have to copy-paste some code. . // . // Note that we might not be inside of an repeat expression here, . // but considering that `IsRepeatExpr` is only relevant for . // non-trivial constants this is doesn't matter. . self.with_constant_rib(IsRepeatExpr::No, true, None, |this| { . this.smart_resolve_path( -- line 686 ---------------------------------------- -- line 697 ---------------------------------------- . }); . . self.diagnostic_metadata.currently_processing_generics = prev; . return; . } . } . } . 1,316 ( 0.00%) self.visit_ty(ty); . } . GenericArg::Lifetime(lt) => self.visit_lifetime(lt), . GenericArg::Const(ct) => self.visit_anon_const(ct), . } . self.diagnostic_metadata.currently_processing_generics = prev; 3,456 ( 0.00%) } . . fn visit_where_predicate(&mut self, p: &'ast WherePredicate) { . debug!("visit_where_predicate {:?}", p); . let previous_value = . replace(&mut self.diagnostic_metadata.current_where_predicate, Some(p)); 108 ( 0.00%) visit::walk_where_predicate(self, p); 20 ( 0.00%) self.diagnostic_metadata.current_where_predicate = previous_value; . } . } . . impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { 9 ( 0.00%) fn new(resolver: &'b mut Resolver<'a>) -> LateResolutionVisitor<'a, 'b, 'ast> { . // During late resolution we only track the module component of the parent scope, . // although it may be useful to track other components as well for diagnostics. 1 ( 0.00%) let graph_root = resolver.graph_root; . let parent_scope = ParentScope::module(graph_root, resolver); . let start_rib_kind = ModuleRibKind(graph_root); 30 ( 0.00%) LateResolutionVisitor { . r: resolver, . parent_scope, . ribs: PerNS { 2 ( 0.00%) value_ns: vec![Rib::new(start_rib_kind)], 2 ( 0.00%) type_ns: vec![Rib::new(start_rib_kind)], 2 ( 0.00%) macro_ns: vec![Rib::new(start_rib_kind)], . }, . label_ribs: Vec::new(), . current_trait_ref: None, . diagnostic_metadata: DiagnosticMetadata::default(), . // errors at module scope should always be reported . in_func_body: false, . } 9 ( 0.00%) } . . fn resolve_ident_in_lexical_scope( . &mut self, . ident: Ident, . ns: Namespace, . record_used_id: Option, . path_span: Span, . ) -> Option> { 12,612 ( 0.00%) self.r.resolve_ident_in_lexical_scope( . ident, . ns, 1,246 ( 0.00%) &self.parent_scope, . record_used_id, . path_span, . &self.ribs[ns], . ) . } . . fn resolve_path( . &mut self, . path: &[Segment], . opt_ns: Option, // `None` indicates a module path in import . record_used: bool, . path_span: Span, . crate_lint: CrateLint, . ) -> PathResult<'a> { 68,289 ( 0.00%) self.r.resolve_path_with_ribs( . path, . opt_ns, 109 ( 0.00%) &self.parent_scope, . record_used, . path_span, . crate_lint, 109 ( 0.00%) Some(&self.ribs), . ) . } . . // AST resolution . // . // We maintain a list of value ribs and type ribs. . // . // Simultaneously, we keep track of the current position in the module -- line 785 ---------------------------------------- -- line 798 ---------------------------------------- . . /// Do some `work` within a new innermost rib of the given `kind` in the given namespace (`ns`). . fn with_rib( . &mut self, . ns: Namespace, . kind: RibKind<'a>, . work: impl FnOnce(&mut Self) -> T, . ) -> T { 1,217 ( 0.00%) self.ribs[ns].push(Rib::new(kind)); . let ret = work(self); . self.ribs[ns].pop(); . ret . } . . fn with_scope(&mut self, id: NodeId, f: impl FnOnce(&mut Self) -> T) -> T { 144 ( 0.00%) if let Some(module) = self.r.get_module(self.r.local_def_id(id).to_def_id()) { . // Move down in the graph. . let orig_module = replace(&mut self.parent_scope.module, module); . self.with_rib(ValueNS, ModuleRibKind(module), |this| { . this.with_rib(TypeNS, ModuleRibKind(module), |this| { . let ret = f(this); 18 ( 0.00%) this.parent_scope.module = orig_module; . ret . }) . }) . } else { . f(self) . } . } . -- line 827 ---------------------------------------- -- line 898 ---------------------------------------- . } . } . . true . } . . fn resolve_adt(&mut self, item: &'ast Item, generics: &'ast Generics) { . debug!("resolve_adt"); 44 ( 0.00%) self.with_current_self_item(item, |this| { . this.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { . let item_def_id = this.r.local_def_id(item.id).to_def_id(); . this.with_self_rib(Res::SelfTy(None, Some((item_def_id, false))), |this| { 66 ( 0.00%) visit::walk_item(this, item); . }); . }); . }); . } . 747 ( 0.00%) fn future_proof_import(&mut self, use_tree: &UseTree) { . let segments = &use_tree.prefix.segments; 83 ( 0.00%) if !segments.is_empty() { 166 ( 0.00%) let ident = segments[0].ident; 896 ( 0.00%) if ident.is_path_segment_keyword() || ident.span.rust_2015() { . return; . } . . let nss = match use_tree.kind { . UseTreeKind::Simple(..) if segments.len() == 1 => &[TypeNS, ValueNS][..], . _ => &[TypeNS], . }; . let report_error = |this: &Self, ns| { -- line 928 ---------------------------------------- -- line 952 ---------------------------------------- . None => {} . } . } . } else if let UseTreeKind::Nested(use_trees) = &use_tree.kind { . for (use_tree, _) in use_trees { . self.future_proof_import(use_tree); . } . } 664 ( 0.00%) } . 3,568 ( 0.00%) fn resolve_item(&mut self, item: &'ast Item) { . let name = item.ident.name; . debug!("(resolving item) resolving {} ({:?})", name, item.kind); . 2,676 ( 0.00%) match item.kind { . ItemKind::TyAlias(box TyAlias { ref generics, .. }) . | ItemKind::Fn(box Fn { ref generics, .. }) => { 404 ( 0.00%) self.compute_num_lifetime_params(item.id, generics); . self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { 303 ( 0.00%) visit::walk_item(this, item) . }); . } . 10 ( 0.00%) ItemKind::Enum(_, ref generics) . | ItemKind::Struct(_, ref generics) . | ItemKind::Union(_, ref generics) => { 110 ( 0.00%) self.compute_num_lifetime_params(item.id, generics); . self.resolve_adt(item, generics); . } . . ItemKind::Impl(box Impl { 121 ( 0.00%) ref generics, . ref of_trait, . ref self_ty, . items: ref impl_items, . .. . }) => { 484 ( 0.00%) self.compute_num_lifetime_params(item.id, generics); 121 ( 0.00%) self.resolve_implementation(generics, of_trait, &self_ty, item.id, impl_items); . } . 2 ( 0.00%) ItemKind::Trait(box Trait { ref generics, ref bounds, ref items, .. }) => { 8 ( 0.00%) self.compute_num_lifetime_params(item.id, generics); . // Create a new rib for the trait-wide type parameters. . self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { 4 ( 0.00%) let local_def_id = this.r.local_def_id(item.id).to_def_id(); . this.with_self_rib(Res::SelfTy(Some(local_def_id), None), |this| { 4 ( 0.00%) this.visit_generics(generics); . walk_list!(this, visit_param_bound, bounds); . 9 ( 0.00%) let walk_assoc_item = |this: &mut Self, generics, item| { . this.with_generic_param_rib(generics, AssocItemRibKind, |this| { 4 ( 0.00%) visit::walk_assoc_item(this, item, AssocCtxt::Trait) . }); 8 ( 0.00%) }; . . this.with_trait_items(items, |this| { . for item in items { 8 ( 0.00%) match &item.kind { . AssocItemKind::Const(_, ty, default) => { . this.visit_ty(ty); . // Only impose the restrictions of `ConstRibKind` for an . // actual constant expression in a provided default. . if let Some(expr) = default { . // We allow arbitrary const expressions inside of associated consts, . // even if they are potentially not const evaluatable. . // -- line 1018 ---------------------------------------- -- line 1021 ---------------------------------------- . this.with_constant_rib( . IsRepeatExpr::No, . true, . None, . |this| this.visit_expr(expr), . ); . } . } 2 ( 0.00%) AssocItemKind::Fn(box Fn { generics, .. }) => { 3 ( 0.00%) walk_assoc_item(this, generics, item); . } . AssocItemKind::TyAlias(box TyAlias { generics, .. }) => { . walk_assoc_item(this, generics, item); . } . AssocItemKind::MacCall(_) => { . panic!("unexpanded macro in resolve!") . } . }; -- line 1038 ---------------------------------------- -- line 1050 ---------------------------------------- . this.with_self_rib(Res::SelfTy(Some(local_def_id), None), |this| { . this.visit_generics(generics); . walk_list!(this, visit_param_bound, bounds); . }); . }); . } . . ItemKind::Mod(..) | ItemKind::ForeignMod(_) => { 18 ( 0.00%) self.with_scope(item.id, |this| { 54 ( 0.00%) visit::walk_item(this, item); . }); . } . 372 ( 0.00%) ItemKind::Static(ref ty, _, ref expr) | ItemKind::Const(_, ref ty, ref expr) => { . self.with_item_rib(HasGenericParams::No, |this| { 93 ( 0.00%) this.visit_ty(ty); 186 ( 0.00%) if let Some(expr) = expr { 558 ( 0.00%) let constant_item_kind = match item.kind { . ItemKind::Const(..) => ConstantItemKind::Const, . ItemKind::Static(..) => ConstantItemKind::Static, . _ => unreachable!(), . }; . // We already forbid generic params because of the above item rib, . // so it doesn't matter whether this is a trivial constant. . this.with_constant_rib( . IsRepeatExpr::No, . true, 465 ( 0.00%) Some((item.ident, constant_item_kind)), . |this| this.visit_expr(expr), . ); . } . }); . } . 83 ( 0.00%) ItemKind::Use(ref use_tree) => { 747 ( 0.00%) self.future_proof_import(use_tree); . } . . ItemKind::ExternCrate(..) | ItemKind::MacroDef(..) => { . // do nothing, these are just around to be encoded . } . . ItemKind::GlobalAsm(_) => { . visit::walk_item(self, item); . } . . ItemKind::MacCall(_) => panic!("unexpanded macro in resolve!"), . } 2,904 ( 0.00%) } . . fn with_generic_param_rib<'c, F>(&'c mut self, generics: &'c Generics, kind: RibKind<'a>, f: F) . where . F: FnOnce(&mut Self), . { . debug!("with_generic_param_rib"); 444 ( 0.00%) let mut function_type_rib = Rib::new(kind); . let mut function_value_rib = Rib::new(kind); . let mut seen_bindings = FxHashMap::default(); . . // We also can't shadow bindings from the parent item . if let AssocItemRibKind = kind { 1 ( 0.00%) let mut add_bindings_for_ns = |ns| { . let parent_rib = self.ribs[ns] . .iter() 988 ( 0.00%) .rfind(|r| matches!(r.kind, ItemRibKind(_))) . .expect("associated item outside of an item"); . seen_bindings 524 ( 0.00%) .extend(parent_rib.bindings.iter().map(|(ident, _)| (*ident, ident.span))); . }; . add_bindings_for_ns(ValueNS); . add_bindings_for_ns(TypeNS); . } . . for param in &generics.params { 995 ( 0.00%) if let GenericParamKind::Lifetime { .. } = param.kind { . continue; . } . 494 ( 0.00%) let ident = param.ident.normalize_to_macros_2_0(); . debug!("with_generic_param_rib: {}", param.id); . 232 ( 0.00%) match seen_bindings.entry(ident) { . Entry::Occupied(entry) => { . let span = *entry.get(); . let err = ResolutionError::NameAlreadyUsedInParameterList(ident.name, span); . self.report_error(param.ident.span, err); . } . Entry::Vacant(entry) => { 116 ( 0.00%) entry.insert(param.ident.span); . } . } . . // Plain insert (no renaming). 580 ( 0.00%) let (rib, def_kind) = match param.kind { . GenericParamKind::Type { .. } => (&mut function_type_rib, DefKind::TyParam), . GenericParamKind::Const { .. } => (&mut function_value_rib, DefKind::ConstParam), . _ => unreachable!(), . }; 464 ( 0.00%) let res = Res::Def(def_kind, self.r.local_def_id(param.id).to_def_id()); 348 ( 0.00%) self.r.record_partial_res(param.id, PartialRes::new(res)); . rib.bindings.insert(ident, res); . } . 5,964 ( 0.00%) self.ribs[ValueNS].push(function_value_rib); 3,552 ( 0.00%) self.ribs[TypeNS].push(function_type_rib); . . f(self); . . self.ribs[TypeNS].pop(); . self.ribs[ValueNS].pop(); . } . . fn with_label_rib(&mut self, kind: RibKind<'a>, f: impl FnOnce(&mut Self)) { 604 ( 0.00%) self.label_ribs.push(Rib::new(kind)); . f(self); . self.label_ribs.pop(); . } . . fn with_item_rib(&mut self, has_generic_params: HasGenericParams, f: impl FnOnce(&mut Self)) { . let kind = ItemRibKind(has_generic_params); . self.with_rib(ValueNS, kind, |this| this.with_rib(TypeNS, kind, f)) . } -- line 1171 ---------------------------------------- -- line 1195 ---------------------------------------- . }, . ) . }); . } . . fn with_current_self_type(&mut self, self_type: &Ty, f: impl FnOnce(&mut Self) -> T) -> T { . // Handle nested impls (inside fn bodies) . let previous_value = 121 ( 0.00%) replace(&mut self.diagnostic_metadata.current_self_type, Some(self_type.clone())); . let result = f(self); 3,267 ( 0.00%) self.diagnostic_metadata.current_self_type = previous_value; . result . } . . fn with_current_self_item(&mut self, self_item: &Item, f: impl FnOnce(&mut Self) -> T) -> T { . let previous_value = . replace(&mut self.diagnostic_metadata.current_self_item, Some(self_item.id)); . let result = f(self); 44 ( 0.00%) self.diagnostic_metadata.current_self_item = previous_value; . result . } . . /// When evaluating a `trait` use its associated types' idents for suggestions in E0412. . fn with_trait_items( . &mut self, . trait_items: &'ast [P], . f: impl FnOnce(&mut Self) -> T, . ) -> T { . let trait_assoc_items = . replace(&mut self.diagnostic_metadata.current_trait_assoc_items, Some(&trait_items)); . let result = f(self); 6 ( 0.00%) self.diagnostic_metadata.current_trait_assoc_items = trait_assoc_items; . result . } . . /// This is called to resolve a trait reference from an `impl` (i.e., `impl Trait for Foo`). 1,089 ( 0.00%) fn with_optional_trait_ref( . &mut self, . opt_trait_ref: Option<&TraitRef>, . f: impl FnOnce(&mut Self, Option) -> T, . ) -> T { 121 ( 0.00%) let mut new_val = None; . let mut new_id = None; 242 ( 0.00%) if let Some(trait_ref) = opt_trait_ref { . let path: Vec<_> = Segment::from_path(&trait_ref.path); 1,635 ( 0.00%) let res = self.smart_resolve_path_fragment( 109 ( 0.00%) trait_ref.ref_id, . None, . &path, 109 ( 0.00%) trait_ref.path.span, 109 ( 0.00%) PathSource::Trait(AliasPossibility::No), . CrateLint::SimplePath(trait_ref.ref_id), . ); . let res = res.base_res(); 109 ( 0.00%) if res != Res::Err { 1,417 ( 0.00%) if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.resolve_path( . &path, . Some(TypeNS), . true, . trait_ref.path.span, 109 ( 0.00%) CrateLint::SimplePath(trait_ref.ref_id), . ) { . new_id = Some(res.def_id()); 1,090 ( 0.00%) new_val = Some((module, trait_ref.clone())); . } . } . } . let original_trait_ref = replace(&mut self.current_trait_ref, new_val); 847 ( 0.00%) let result = f(self, new_id); 2,178 ( 0.00%) self.current_trait_ref = original_trait_ref; . result 968 ( 0.00%) } . . fn with_self_rib_ns(&mut self, ns: Namespace, self_res: Res, f: impl FnOnce(&mut Self)) { . let mut self_type_rib = Rib::new(NormalRibKind); . . // Plain insert (no renaming, since types are not currently hygienic) . self_type_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), self_res); 3,120 ( 0.00%) self.ribs[ns].push(self_type_rib); . f(self); . self.ribs[ns].pop(); . } . . fn with_self_rib(&mut self, self_res: Res, f: impl FnOnce(&mut Self)) { . self.with_self_rib_ns(TypeNS, self_res, f) . } . -- line 1281 ---------------------------------------- -- line 1288 ---------------------------------------- . impl_items: &'ast [P], . ) { . debug!("resolve_implementation"); . // If applicable, create a rib for the type parameters. . self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { . // Dummy self type for better errors if `Self` is used in the trait path. . this.with_self_rib(Res::SelfTy(None, None), |this| { . // Resolve the trait reference, if necessary. 1,210 ( 0.00%) this.with_optional_trait_ref(opt_trait_reference.as_ref(), |this, trait_id| { 242 ( 0.00%) let item_def_id = this.r.local_def_id(item_id); . . // Register the trait definitions from here. 242 ( 0.00%) if let Some(trait_id) = trait_id { 436 ( 0.00%) this.r.trait_impls.entry(trait_id).or_default().push(item_def_id); . } . . let item_def_id = item_def_id.to_def_id(); 121 ( 0.00%) this.with_self_rib(Res::SelfTy(trait_id, Some((item_def_id, false))), |this| { 121 ( 0.00%) if let Some(trait_ref) = opt_trait_reference.as_ref() { . // Resolve type arguments in the trait path. . visit::walk_trait_ref(this, trait_ref); . } . // Resolve the self type. 363 ( 0.00%) this.visit_ty(self_type); . // Resolve the generic parameters. 121 ( 0.00%) this.visit_generics(generics); . // Resolve the items within the impl. . this.with_current_self_type(self_type, |this| { . this.with_self_rib_ns(ValueNS, Res::SelfCtor(item_def_id), |this| { . debug!("resolve_implementation with_self_rib_ns(ValueNS, ...)"); 121 ( 0.00%) for item in impl_items { . use crate::ResolutionError::*; 1,182 ( 0.00%) match &item.kind { . AssocItemKind::Const(_default, _ty, _expr) => { . debug!("resolve_implementation AssocItemKind::Const"); . // If this is a trait impl, ensure the const . // exists in trait . this.check_trait_item( . item.id, . item.ident, . &item.kind, -- line 1328 ---------------------------------------- -- line 1344 ---------------------------------------- . visit::walk_assoc_item( . this, . item, . AssocCtxt::Impl, . ) . }, . ); . } 191 ( 0.00%) AssocItemKind::Fn(box Fn { generics, .. }) => { . debug!("resolve_implementation AssocItemKind::Fn"); . // We also need a new scope for the impl item type parameters. . this.with_generic_param_rib( . generics, . AssocItemRibKind, . |this| { . // If this is a trait impl, ensure the method . // exists in trait . this.check_trait_item( 191 ( 0.00%) item.id, 382 ( 0.00%) item.ident, . &item.kind, . ValueNS, 573 ( 0.00%) item.span, . |i, s, c| MethodNotMemberOfTrait(i, s, c), . ); . 382 ( 0.00%) visit::walk_assoc_item( . this, . item, . AssocCtxt::Impl, . ) . }, . ); . } . AssocItemKind::TyAlias(box TyAlias { 6 ( 0.00%) generics, .. . }) => { . debug!("resolve_implementation AssocItemKind::TyAlias"); . // We also need a new scope for the impl item type parameters. . this.with_generic_param_rib( . generics, . AssocItemRibKind, . |this| { . // If this is a trait impl, ensure the type . // exists in trait . this.check_trait_item( 6 ( 0.00%) item.id, 12 ( 0.00%) item.ident, . &item.kind, . TypeNS, 18 ( 0.00%) item.span, . |i, s, c| TypeNotMemberOfTrait(i, s, c), . ); . 12 ( 0.00%) visit::walk_assoc_item( . this, . item, . AssocCtxt::Impl, . ) . }, . ); . } . AssocItemKind::MacCall(_) => { -- line 1406 ---------------------------------------- -- line 1423 ---------------------------------------- . kind: &AssocItemKind, . ns: Namespace, . span: Span, . err: F, . ) where . F: FnOnce(Ident, &str, Option) -> ResolutionError<'_>, . { . // If there is a TraitRef in scope for an impl, then the method must be in the trait. 394 ( 0.00%) let Some((module, _)) = &self.current_trait_ref else { return; }; 558 ( 0.00%) ident.span.normalize_to_macros_2_0_and_adjust(module.expansion); 459 ( 0.00%) let key = self.r.new_key(ident, ns); 930 ( 0.00%) let mut binding = self.r.resolution(module, key).try_borrow().ok().and_then(|r| r.binding); . debug!(?binding); 93 ( 0.00%) if binding.is_none() { . // We could not find the trait item in the correct namespace. . // Check the other namespace to report an error. . let ns = match ns { . ValueNS => TypeNS, . TypeNS => ValueNS, . _ => ns, . }; . let key = self.r.new_key(ident, ns); -- line 1444 ---------------------------------------- -- line 1449 ---------------------------------------- . // We could not find the method: report an error. . let candidate = self.find_similarly_named_assoc_item(ident.name, kind); . let path = &self.current_trait_ref.as_ref().unwrap().1.path; . self.report_error(span, err(ident, &path_names_to_string(path), candidate)); . return; . }; . . let res = binding.res(); 186 ( 0.00%) let Res::Def(def_kind, _) = res else { bug!() }; 645 ( 0.00%) match (def_kind, kind) { . (DefKind::AssocTy, AssocItemKind::TyAlias(..)) . | (DefKind::AssocFn, AssocItemKind::Fn(..)) . | (DefKind::AssocConst, AssocItemKind::Const(..)) => { 1,302 ( 0.00%) self.r.record_partial_res(id, PartialRes::new(res)); . return; . } . _ => {} . } . . // The method kind does not correspond to what appeared in the trait, report. . let path = &self.current_trait_ref.as_ref().unwrap().1.path; . let (code, kind) = match kind { -- line 1470 ---------------------------------------- -- line 1480 ---------------------------------------- . kind, . code, . trait_path: path_names_to_string(path), . trait_item_span: binding.span, . }, . ); . } . 2,772 ( 0.00%) fn resolve_params(&mut self, params: &'ast [Param]) { 1,540 ( 0.00%) let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())]; 1,848 ( 0.00%) for Param { pat, ty, .. } in params { . self.resolve_pattern(pat, PatternSource::FnParam, &mut bindings); 1,768 ( 0.00%) self.visit_ty(ty); . debug!("(resolving function / closure) recorded parameter"); . } 2,464 ( 0.00%) } . . fn resolve_local(&mut self, local: &'ast Local) { . debug!("resolving local ({:?})", local); . // Resolve the type. 258 ( 0.00%) walk_list!(self, visit_ty, &local.ty); . . // Resolve the initializer. 888 ( 0.00%) if let Some((init, els)) = local.kind.init_else_opt() { . self.visit_expr(init); . . // Resolve the `else` block 408 ( 0.00%) if let Some(els) = els { . self.visit_block(els); . } . } . . // Resolve the pattern. . self.resolve_pattern_top(&local.pat, PatternSource::Let); . } . . /// build a map from pattern identifiers to binding-info's. . /// this is done hygienically. This could arise for a macro . /// that expands into an or-pattern where one 'x' was from the . /// user and one 'x' came from the macro. . fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap { . let mut binding_map = FxHashMap::default(); . 60 ( 0.00%) pat.walk(&mut |pat| { 92 ( 0.00%) match pat.kind { 16 ( 0.00%) PatKind::Ident(binding_mode, ident, ref sub_pat) 48 ( 0.00%) if sub_pat.is_some() || self.is_base_res_local(pat.id) => . { 24 ( 0.00%) binding_map.insert(ident, BindingInfo { span: ident.span, binding_mode }); . } . PatKind::Or(ref ps) => { . // Check the consistency of this or-pattern and . // then add all bindings to the larger map. . for bm in self.check_consistent_bindings(ps) { . binding_map.extend(bm); . } . return false; -- line 1536 ---------------------------------------- -- line 1540 ---------------------------------------- . . true . }); . . binding_map . } . . fn is_base_res_local(&self, nid: NodeId) -> bool { 32 ( 0.00%) matches!(self.r.partial_res_map.get(&nid).map(|res| res.base_res()), Some(Res::Local(..))) . } . . /// Checks that all of the arms in an or-pattern have exactly the . /// same set of bindings, with the same binding modes for each. 54 ( 0.00%) fn check_consistent_bindings(&mut self, pats: &[P]) -> Vec { . let mut missing_vars = FxHashMap::default(); . let mut inconsistent_vars = FxHashMap::default(); . . // 1) Compute the binding maps of all arms. . let maps = pats.iter().map(|pat| self.binding_mode_map(pat)).collect::>(); . . // 2) Record any missing bindings or binding mode inconsistencies. . for (map_outer, pat_outer) in pats.iter().enumerate().map(|(idx, pat)| (&maps[idx], pat)) { . // Check against all arms except for the same pattern which is always self-consistent. . let inners = pats . .iter() . .enumerate() 24 ( 0.00%) .filter(|(_, pat)| pat.id != pat_outer.id) . .flat_map(|(idx, _)| maps[idx].iter()) 24 ( 0.00%) .map(|(key, binding)| (key.name, map_outer.get(&key), binding)); . 48 ( 0.00%) for (name, info, &binding_inner) in inners { 8 ( 0.00%) match info { . None => { . // The inner binding is missing in the outer. . let binding_error = . missing_vars.entry(name).or_insert_with(|| BindingError { . name, . origin: BTreeSet::new(), . target: BTreeSet::new(), . could_be_path: name.as_str().starts_with(char::is_uppercase), . }); . binding_error.origin.insert(binding_inner.span); . binding_error.target.insert(pat_outer.span); . } . Some(binding_outer) => { 24 ( 0.00%) if binding_outer.binding_mode != binding_inner.binding_mode { . // The binding modes in the outer and inner bindings differ. . inconsistent_vars . .entry(name) . .or_insert((binding_inner.span, binding_outer.span)); . } . } . } . } . } . . // 3) Report all missing variables we found. . let mut missing_vars = missing_vars.iter_mut().collect::>(); . missing_vars.sort_by_key(|(sym, _err)| sym.as_str()); . 36 ( 0.00%) for (name, mut v) in missing_vars { . if inconsistent_vars.contains_key(name) { . v.could_be_path = false; . } . self.report_error( . *v.origin.iter().next().unwrap(), . ResolutionError::VariableNotBoundInPattern(v), . ); . } . . // 4) Report all inconsistencies in binding modes we found. . let mut inconsistent_vars = inconsistent_vars.iter().collect::>(); . inconsistent_vars.sort(); 24 ( 0.00%) for (name, v) in inconsistent_vars { . self.report_error(v.0, ResolutionError::VariableBoundWithDifferentMode(*name, v.1)); . } . . // 5) Finally bubble up all the binding maps. . maps 54 ( 0.00%) } . . /// Check the consistency of the outermost or-patterns. . fn check_consistent_bindings_top(&mut self, pat: &'ast Pat) { 7,258 ( 0.00%) pat.walk(&mut |pat| match pat.kind { . PatKind::Or(ref ps) => { 18 ( 0.00%) self.check_consistent_bindings(ps); . false . } . _ => true, . }) . } . . fn resolve_arm(&mut self, arm: &'ast Arm) { . self.with_rib(ValueNS, NormalRibKind, |this| { . this.resolve_pattern_top(&arm.pat, PatternSource::Match); 166 ( 0.00%) walk_list!(this, visit_expr, &arm.guard); . this.visit_expr(&arm.body); . }); . } . . /// Arising from `source`, resolve a top level pattern. . fn resolve_pattern_top(&mut self, pat: &'ast Pat, pat_src: PatternSource) { 1,904 ( 0.00%) let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())]; . self.resolve_pattern(pat, pat_src, &mut bindings); . } . . fn resolve_pattern( . &mut self, . pat: &'ast Pat, . pat_src: PatternSource, . bindings: &mut SmallVec<[(PatBoundCtx, FxHashSet); 1]>, . ) { . // We walk the pattern before declaring the pattern's inner bindings, . // so that we avoid resolving a literal expression to a binding defined . // by the pattern. 2,568 ( 0.00%) visit::walk_pat(self, pat); . self.resolve_pattern_inner(pat, pat_src, bindings); . // This has to happen *after* we determine which pat_idents are variants: . self.check_consistent_bindings_top(pat); . } . . /// Resolve bindings in a pattern. This is a helper to `resolve_pattern`. . /// . /// ### `bindings` -- line 1663 ---------------------------------------- -- line 1679 ---------------------------------------- . /// See the implementation and `fresh_binding` for more details. . fn resolve_pattern_inner( . &mut self, . pat: &Pat, . pat_src: PatternSource, . bindings: &mut SmallVec<[(PatBoundCtx, FxHashSet); 1]>, . ) { . // Visit all direct subpatterns of this pattern. 6,894 ( 0.00%) pat.walk(&mut |pat| { . debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind); 6,155 ( 0.00%) match pat.kind { 3,444 ( 0.00%) PatKind::Ident(bmode, ident, ref sub) => { . // First try to resolve the identifier as some existing entity, . // then fall back to a fresh binding. . let has_sub = sub.is_some(); 9,471 ( 0.00%) let res = self . .try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub) 9,405 ( 0.00%) .unwrap_or_else(|| self.fresh_binding(ident, pat.id, pat_src, bindings)); 6,027 ( 0.00%) self.r.record_partial_res(pat.id, PartialRes::new(res)); 2,583 ( 0.00%) self.r.record_pat_span(pat.id, pat.span); . } 162 ( 0.00%) PatKind::TupleStruct(ref qself, ref path, ref sub_patterns) => { 324 ( 0.00%) self.smart_resolve_path( 81 ( 0.00%) pat.id, . qself.as_ref(), . path, 405 ( 0.00%) PathSource::TupleStruct( 81 ( 0.00%) pat.span, 92 ( 0.00%) self.r.arenas.alloc_pattern_spans(sub_patterns.iter().map(|p| p.span)), . ), . ); . } 36 ( 0.00%) PatKind::Path(ref qself, ref path) => { 90 ( 0.00%) self.smart_resolve_path(pat.id, qself.as_ref(), path, PathSource::Pat); . } 136 ( 0.00%) PatKind::Struct(ref qself, ref path, ..) => { 340 ( 0.00%) self.smart_resolve_path(pat.id, qself.as_ref(), path, PathSource::Struct); . } . PatKind::Or(ref ps) => { . // Add a new set of bindings to the stack. `Or` here records that when a . // binding already exists in this set, it should not result in an error because . // `V1(a) | V2(a)` must be allowed and are checked for consistency later. 12 ( 0.00%) bindings.push((PatBoundCtx::Or, Default::default())); . for p in ps { . // Now we need to switch back to a product context so that each . // part of the or-pattern internally rejects already bound names. . // For example, `V1(a) | V2(a, a)` and `V1(a, a) | V2(a)` are bad. 24 ( 0.00%) bindings.push((PatBoundCtx::Product, Default::default())); 36 ( 0.00%) self.resolve_pattern_inner(p, pat_src, bindings); . // Move up the non-overlapping bindings to the or-pattern. . // Existing bindings just get "merged". 48 ( 0.00%) let collected = bindings.pop().unwrap().1; . bindings.last_mut().unwrap().1.extend(collected); . } . // This or-pattern itself can itself be part of a product, . // e.g. `(V1(a) | V2(a), a)` or `(a, V1(a) | V2(a))`. . // Both cases bind `a` again in a product pattern and must be rejected. 36 ( 0.00%) let collected = bindings.pop().unwrap().1; . bindings.last_mut().unwrap().1.extend(collected); . . // Prevent visiting `ps` as we've already done so above. . return false; . } . _ => {} . } . true . }); . } . 10,260 ( 0.00%) fn fresh_binding( . &mut self, . ident: Ident, . pat_id: NodeId, . pat_src: PatternSource, . bindings: &mut SmallVec<[(PatBoundCtx, FxHashSet); 1]>, . ) -> Res { . // Add the binding to the local ribs, if it doesn't already exist in the bindings map. . // (We must not add it if it's in the bindings map because that breaks the assumptions . // later passes make about or-patterns.) 4,275 ( 0.00%) let ident = ident.normalize_to_macro_rules(); . . let mut bound_iter = bindings.iter().filter(|(_, set)| set.contains(&ident)); . // Already bound in a product pattern? e.g. `(a, a)` which is not allowed. . let already_bound_and = bound_iter.clone().any(|(ctx, _)| *ctx == PatBoundCtx::Product); . // Already bound in an or-pattern? e.g. `V1(a) | V2(a)`. . // This is *required* for consistency which is checked later. . let already_bound_or = bound_iter.any(|(ctx, _)| *ctx == PatBoundCtx::Or); . 855 ( 0.00%) if already_bound_and { . // Overlap in a product pattern somewhere; report an error. . use ResolutionError::*; . let error = match pat_src { . // `fn f(a: u8, a: u8)`: . PatternSource::FnParam => IdentifierBoundMoreThanOnceInParameterList, . // `Variant(a, a)`: . _ => IdentifierBoundMoreThanOnceInSamePattern, . }; . self.report_error(ident.span, error(ident.name)); . } . . // Record as bound if it's valid: . let ident_valid = ident.name != kw::Empty; 855 ( 0.00%) if ident_valid { 1,710 ( 0.00%) bindings.last_mut().unwrap().1.insert(ident); . } . 855 ( 0.00%) if already_bound_or { . // `Variant1(a) | Variant2(a)`, ok . // Reuse definition from the first `a`. 24 ( 0.00%) self.innermost_rib_bindings(ValueNS)[&ident] . } else { . let res = Res::Local(pat_id); . if ident_valid { . // A completely fresh binding add to the set if it's valid. 1,702 ( 0.00%) self.innermost_rib_bindings(ValueNS).insert(ident, res); . } 6,808 ( 0.00%) res . } 7,695 ( 0.00%) } . . fn innermost_rib_bindings(&mut self, ns: Namespace) -> &mut IdentMap { 4 ( 0.00%) &mut self.ribs[ns].last_mut().unwrap().bindings . } . 11,193 ( 0.00%) fn try_resolve_as_non_binding( . &mut self, . pat_src: PatternSource, . pat: &Pat, . bm: BindingMode, . ident: Ident, . has_sub: bool, . ) -> Option { . // An immutable (no `mut`) by-value (no `ref`) binding pattern without . // a sub pattern (no `@ $pat`) is syntactically ambiguous as it could . // also be interpreted as a path to e.g. a constant, variant, etc. 1,722 ( 0.00%) let is_syntactic_ambiguity = !has_sub && bm == BindingMode::ByValue(Mutability::Not); . . let ls_binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, pat.span)?; 224 ( 0.00%) let (res, binding) = match ls_binding { . LexicalScopeBinding::Item(binding) 32 ( 0.00%) if is_syntactic_ambiguity && binding.is_ambiguity() => . { . // For ambiguous bindings we don't know all their definitions and cannot check . // whether they can be shadowed by fresh bindings or not, so force an error. . // issues/33118#issuecomment-233962221 (see below) still applies here, . // but we have to ignore it for backward compatibility. . self.r.record_use(ident, binding, false); . return None; . } 144 ( 0.00%) LexicalScopeBinding::Item(binding) => (binding.res(), Some(binding)), 72 ( 0.00%) LexicalScopeBinding::Res(res) => (res, None), . }; . 166 ( 0.00%) match res { . Res::SelfCtor(_) // See #70549. . | Res::Def( . DefKind::Ctor(_, CtorKind::Const) | DefKind::Const | DefKind::ConstParam, . _, . ) if is_syntactic_ambiguity => { . // Disambiguate in favor of a unit struct/variant or constant pattern. 12 ( 0.00%) if let Some(binding) = binding { 36 ( 0.00%) self.r.record_use(ident, binding, false); . } 30 ( 0.00%) Some(res) . } . Res::Def(DefKind::Ctor(..) | DefKind::Const | DefKind::Static, _) => { . // This is unambiguously a fresh binding, either syntactically . // (e.g., `IDENT @ PAT` or `ref IDENT`) or because `IDENT` resolves . // to something unusable as a pattern (e.g., constructor function), . // but we still conservatively report an error, see . // issues/33118#issuecomment-233962221 for one reason why. . let binding = binding.expect("no binding for a ctor or static"); -- line 1850 ---------------------------------------- -- line 1882 ---------------------------------------- . None . } . _ => span_bug!( . ident.span, . "unexpected resolution for an identifier in pattern: {:?}", . res, . ), . } 7,749 ( 0.00%) } . . // High-level and context dependent path resolution routine. . // Resolves the path and records the resolution into definition map. . // If resolution fails tries several techniques to find likely . // resolution candidates, suggest imports or other help, and report . // errors in user friendly way. 46,908 ( 0.00%) fn smart_resolve_path( . &mut self, . id: NodeId, . qself: Option<&QSelf>, . path: &Path, . source: PathSource<'ast>, . ) { 59,925 ( 0.00%) self.smart_resolve_path_fragment( . id, . qself, . &Segment::from_path(path), 3,995 ( 0.00%) path.span, 15,722 ( 0.00%) source, . CrateLint::SimplePath(id), . ); . } . 57,456 ( 0.00%) fn smart_resolve_path_fragment( . &mut self, . id: NodeId, . qself: Option<&QSelf>, . path: &[Segment], . span: Span, . source: PathSource<'ast>, . crate_lint: CrateLint, . ) -> PartialRes { . tracing::debug!( . "smart_resolve_path_fragment(id={:?}, qself={:?}, path={:?})", . id, . qself, . path . ); 32,832 ( 0.00%) let ns = source.namespace(); . 24,624 ( 0.00%) let report_errors = |this: &mut Self, res: Option| { . if this.should_report_errs() { . let (err, candidates) = this.smart_resolve_report_errors(path, span, source, res); . . let def_id = this.parent_scope.module.nearest_parent_mod(); . let instead = res.is_some(); . let suggestion = . if res.is_none() { this.report_missing_type_error(path) } else { None }; . // get_from_node_id -- line 1939 ---------------------------------------- -- line 2014 ---------------------------------------- . err.cancel(); . } . . // We don't return `Some(parent_err)` here, because the error will . // be already printed as part of the `use` injections . None . }; . 90,288 ( 0.00%) let partial_res = match self.resolve_qpath_anywhere( . id, . qself, . path, . ns, . span, . source.defer_to_typeck(), . crate_lint, . ) { 23,820 ( 0.00%) Ok(Some(partial_res)) if partial_res.unresolved_segments() == 0 => { 27,321 ( 0.00%) if source.is_expected(partial_res.base_res()) || partial_res.base_res() == Res::Err . { 23,418 ( 0.00%) partial_res . } else { . report_errors(self, Some(partial_res.base_res())) . } . } . 1,005 ( 0.00%) Ok(Some(partial_res)) if source.defer_to_typeck() => { . // Not fully resolved associated item `T::A::B` or `::A::B` . // or `::A::B`. If `B` should be resolved in value namespace then . // it needs to be added to the trait map. 201 ( 0.00%) if ns == ValueNS { 975 ( 0.00%) let item_name = path.last().unwrap().ident; . let traits = self.traits_in_scope(item_name, ns); . self.r.trait_map.insert(id, traits); . } . 1,011 ( 0.00%) if PrimTy::from_name(path[0].ident.name).is_some() { . let mut std_path = Vec::with_capacity(1 + path.len()); . . std_path.push(Segment::from_ident(Ident::with_dummy_span(sym::std))); . std_path.extend(path); . if let PathResult::Module(_) | PathResult::NonModule(_) = . self.resolve_path(&std_path, Some(ns), false, span, CrateLint::No) . { . // Check if we wrote `str::from_utf8` instead of `std::str::from_utf8` -- line 2058 ---------------------------------------- -- line 2059 ---------------------------------------- . let item_span = . path.iter().last().map_or(span, |segment| segment.ident.span); . . self.r.confused_type_with_std_module.insert(item_span, span); . self.r.confused_type_with_std_module.insert(span, span); . } . } . 1,206 ( 0.00%) partial_res . } . . Err(err) => { . if let Some(err) = report_errors_for_call(self, err) { . self.report_error(err.span, err.node); . } . . PartialRes::new(Res::Err) . } . . _ => report_errors(self, None), . }; . 8,208 ( 0.00%) if !matches!(source, PathSource::TraitItem(..)) { . // Avoid recording definition of `A::B` in `::B::C`. 16,416 ( 0.00%) self.r.record_partial_res(id, partial_res); . } . . partial_res 32,832 ( 0.00%) } . . fn self_type_is_available(&mut self, span: Span) -> bool { . let binding = self.resolve_ident_in_lexical_scope( . Ident::with_dummy_span(kw::SelfUpper), . TypeNS, . None, . span, . ); -- line 2095 ---------------------------------------- -- line 2113 ---------------------------------------- . . #[inline] . /// If we're actually rustdoc then avoid giving a name resolution error for `cfg()` items. . fn should_report_errs(&self) -> bool { . !(self.r.session.opts.actually_rustdoc && self.in_func_body) . } . . // Resolve in alternative namespaces if resolution in the primary namespace fails. 53,352 ( 0.00%) fn resolve_qpath_anywhere( . &mut self, . id: NodeId, . qself: Option<&QSelf>, . path: &[Segment], . primary_ns: Namespace, . span: Span, . defer_to_typeck: bool, . crate_lint: CrateLint, . ) -> Result, Spanned>> { . let mut fin_res = None; . 28,728 ( 0.00%) for (i, &ns) in [primary_ns, TypeNS, ValueNS].iter().enumerate() { 8,208 ( 0.00%) if i == 0 || ns != primary_ns { 16,416 ( 0.00%) match self.resolve_qpath(id, qself, path, ns, span, crate_lint)? { . Some(partial_res) 25,026 ( 0.00%) if partial_res.unresolved_segments() == 0 || defer_to_typeck => . { 49,248 ( 0.00%) return Ok(Some(partial_res)); . } . partial_res => { . if fin_res.is_none() { . fin_res = partial_res; . } . } . } . } -- line 2147 ---------------------------------------- -- line 2155 ---------------------------------------- . if let Ok((_, res)) = . self.r.resolve_macro_path(&path, None, &self.parent_scope, false, false) . { . return Ok(Some(PartialRes::new(res))); . } . } . . Ok(fin_res) 32,832 ( 0.00%) } . . /// Handles paths that may refer to associated items. . fn resolve_qpath( . &mut self, . id: NodeId, . qself: Option<&QSelf>, . path: &[Segment], . ns: Namespace, -- line 2171 ---------------------------------------- -- line 2172 ---------------------------------------- . span: Span, . crate_lint: CrateLint, . ) -> Result, Spanned>> { . debug!( . "resolve_qpath(id={:?}, qself={:?}, path={:?}, ns={:?}, span={:?})", . id, qself, path, ns, span, . ); . 4,104 ( 0.00%) if let Some(qself) = qself { . if qself.position == 0 { . // This is a case like `::B`, where there is no . // trait to resolve. In that case, we leave the `B` . // segment to be resolved by type-check. . return Ok(Some(PartialRes::with_unresolved_segments( . Res::Def(DefKind::Mod, DefId::local(CRATE_DEF_INDEX)), . path.len(), . ))); -- line 2188 ---------------------------------------- -- line 2216 ---------------------------------------- . // have to be resolved by type-check, since that requires doing . // trait resolution. . return Ok(Some(PartialRes::with_unresolved_segments( . partial_res.base_res(), . partial_res.unresolved_segments() + path.len() - qself.position - 1, . ))); . } . 25,390 ( 0.00%) let result = match self.resolve_path(&path, Some(ns), true, span, crate_lint) { 48,373 ( 0.00%) PathResult::NonModule(path_res) => path_res, 1,532 ( 0.00%) PathResult::Module(ModuleOrUniformRoot::Module(module)) if !module.is_normal() => { . PartialRes::new(module.res().unwrap()) . } . // In `a(::assoc_item)*` `a` cannot be a module. If `a` does resolve to a module we . // don't report an error right away, but try to fallback to a primitive type. . // So, we are still able to successfully resolve something like . // . // use std::u8; // bring module u8 in scope . // fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8 . // u8::max_value() // OK, resolves to associated function ::max_value, . // // not to non-existent std::u8::max_value . // } . // . // Such behavior is required for backward compatibility. . // The same fallback is used when `a` resolves to nothing. . PathResult::Module(ModuleOrUniformRoot::Module(_)) | PathResult::Failed { .. } 26 ( 0.00%) if (ns == TypeNS || path.len() > 1) 104 ( 0.00%) && PrimTy::from_name(path[0].ident.name).is_some() => . { 52 ( 0.00%) let prim = PrimTy::from_name(path[0].ident.name).unwrap(); . PartialRes::with_unresolved_segments(Res::PrimTy(prim), path.len() - 1) . } . PathResult::Module(ModuleOrUniformRoot::Module(module)) => { . PartialRes::new(module.res().unwrap()) . } . PathResult::Failed { is_error_from_last_segment: false, span, label, suggestion } => { . return Err(respan(span, ResolutionError::FailedToResolve { label, suggestion })); . } . PathResult::Module(..) | PathResult::Failed { .. } => return Ok(None), . PathResult::Indeterminate => bug!("indeterminate path result in resolve_qpath"), 20,494 ( 0.00%) }; . 10,176 ( 0.00%) if path.len() > 1 . && result.base_res() != Res::Err 1,204 ( 0.00%) && path[0].ident.name != kw::PathRoot . && path[0].ident.name != kw::DollarCrate . { . let unqualified_result = { 1,660 ( 0.00%) match self.resolve_path( 1,660 ( 0.00%) &[*path.last().unwrap()], . Some(ns), . false, . span, . CrateLint::No, . ) { 545 ( 0.00%) PathResult::NonModule(path_res) => path_res.base_res(), 9 ( 0.00%) PathResult::Module(ModuleOrUniformRoot::Module(module)) => { . module.res().unwrap() . } 856 ( 0.00%) _ => return Ok(Some(result)), . } . }; 590 ( 0.00%) if result.base_res() == unqualified_result { . let lint = lint::builtin::UNUSED_QUALIFICATIONS; . self.r.lint_buffer.buffer_lint(lint, id, span, "unnecessary qualification") . } . } . 15,560 ( 0.00%) Ok(Some(result)) . } . . fn with_resolved_label(&mut self, label: Option