rust/compiler
León Orell Valerian Liehr 55a16a4803
Rollup merge of #125454 - mu001999-contrib:master, r=oli-obk
Improve the doc of query associated_item

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

This query also maps from a impl item to the impl item "descriptor". So it's a bit confused, I skipped it cause it doesn't say it contains impl items.

```rust
fn associated_item(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AssocItem {
    let id = tcx.local_def_id_to_hir_id(def_id);
    let parent_def_id = tcx.hir().get_parent_item(id);
    let parent_item = tcx.hir().expect_item(parent_def_id.def_id);
    match parent_item.kind {
        hir::ItemKind::Impl(impl_) => {
            if let Some(impl_item_ref) = impl_.items.iter().find(|i| i.id.owner_id.def_id == def_id)
            {
                let assoc_item = associated_item_from_impl_item_ref(impl_item_ref);
                debug_assert_eq!(assoc_item.def_id.expect_local(), def_id);
                return assoc_item;
            }
        }

        hir::ItemKind::Trait(.., trait_item_refs) => {
            if let Some(trait_item_ref) =
                trait_item_refs.iter().find(|i| i.id.owner_id.def_id == def_id)
            {
                let assoc_item = associated_item_from_trait_item_ref(trait_item_ref);
                debug_assert_eq!(assoc_item.def_id.expect_local(), def_id);
                return assoc_item;
            }
        }

        _ => {}
    }

    span_bug!(
        parent_item.span,
        "unexpected parent of trait or impl item or item not found: {:?}",
        parent_item.kind
    )
}
```
2024-05-23 20:09:10 +02:00
..
rustc Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=... 2024-05-02 19:48:29 +02:00
rustc_abi Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable 2024-05-18 11:27:29 +03:00
rustc_arena
rustc_ast Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov 2024-05-23 07:41:18 +02:00
rustc_ast_ir Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
rustc_ast_lowering Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
rustc_ast_passes Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
rustc_ast_pretty Add some comments. 2024-05-23 06:03:17 +10:00
rustc_attr Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
rustc_baked_icu_data
rustc_borrowck Uplift OutlivesPredicate, remove a bunch of unnecessary associated types from Interner 2024-05-21 17:00:45 -04:00
rustc_builtin_macros Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov 2024-05-23 07:41:18 +02:00
rustc_codegen_cranelift Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikic 2024-05-21 12:47:06 +02:00
rustc_codegen_gcc Stop using to_hir_binop in codegen 2024-05-22 01:34:26 -07:00
rustc_codegen_llvm Stop using to_hir_binop in codegen 2024-05-22 01:34:26 -07:00
rustc_codegen_ssa Rollup merge of #125438 - tbu-:pr_rm_to_string_lossy, r=jieyouxu 2024-05-23 14:09:26 +02:00
rustc_const_eval Allow const eval failures if the cause is a type layout issue 2024-05-23 10:51:52 +00:00
rustc_data_structures Rollup merge of #124818 - compiler-errors:ena, r=Mark-Simulacrum 2024-05-11 08:00:15 +02:00
rustc_driver
rustc_driver_impl PR feedback 2024-05-21 20:12:30 -04:00
rustc_error_codes Remove a stray backtick in an error explanation. 2024-05-13 07:53:38 +10:00
rustc_error_messages
rustc_errors Auto merge of #125335 - compiler-errors:binder, r=lcnr 2024-05-22 08:33:34 +00:00
rustc_expand Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov 2024-05-23 07:41:18 +02:00
rustc_feature Auto merge of #125326 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors 2024-05-22 04:14:08 +00:00
rustc_fluent_macro
rustc_fs_util Stabilize std::path::absolute 2024-04-24 14:35:02 +00:00
rustc_graphviz
rustc_hir Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
rustc_hir_analysis Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, r=Nilstrieb 2024-05-23 07:41:17 +02:00
rustc_hir_pretty Rollup merge of #125158 - Nilstrieb:block-indent, r=compiler-errors 2024-05-21 00:47:02 +02:00
rustc_hir_typeck Rollup merge of #124297 - oli-obk:define_opaque_types13, r=jackh726 2024-05-23 14:09:22 +02:00
rustc_incremental PR feedback 2024-05-21 20:12:30 -04:00
rustc_index Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_index_macros rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
rustc_infer Rollup merge of #125210 - fmease:fix-up-some-diags, r=davidtwco 2024-05-23 14:09:24 +02:00
rustc_interface rustc: Use tcx.used_crates(()) more 2024-05-22 18:02:51 +03:00
rustc_lexer Improved the compiler code with clippy 2024-04-24 09:41:44 +02:00
rustc_lint Rollup merge of #125416 - compiler-errors:param-env-missing-copy, r=lcnr 2024-05-23 14:09:25 +02:00
rustc_lint_defs Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
rustc_llvm Update cc crate to v1.0.97 2024-05-08 15:06:35 +00:00
rustc_log Use Backtrace::force_capture instead of Backtrace::capture in rustc_log 2024-05-21 10:54:36 +02:00
rustc_macros Rollup merge of #125391 - nnethercote:serialize-rs-tweaks, r=compiler-errors 2024-05-22 23:41:13 +02:00
rustc_metadata Rollup merge of #125409 - tbu-:pr_raw_dylib_only_windows, r=lcnr 2024-05-23 14:09:24 +02:00
rustc_middle Improve the doc of query associated_item 2024-05-23 23:50:39 +08:00
rustc_mir_build Rollup merge of #125210 - fmease:fix-up-some-diags, r=davidtwco 2024-05-23 14:09:24 +02:00
rustc_mir_dataflow Remove Rvalue::CheckedBinaryOp 2024-05-17 20:33:02 -07:00
rustc_mir_transform interpret: make overflowing binops just normal binops 2024-05-21 14:50:09 +02:00
rustc_monomorphize Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes 2024-05-19 11:10:56 -03:00
rustc_next_trait_solver Uplift binder 2024-05-21 17:00:45 -04:00
rustc_parse Rollup merge of #125049 - dtolnay:castbrace, r=compiler-errors 2024-05-22 19:04:44 +02:00
rustc_parse_format Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_passes Rollup merge of #122382 - mu001999:dead_code/enhance, r=petrochenkov 2024-05-23 20:09:07 +02:00
rustc_pattern_analysis Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
rustc_privacy split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
rustc_query_impl Remove extern crate rustc_middle from rustc_query_impl. 2024-05-13 08:20:18 +10:00
rustc_query_system Add a footer in FileEncoder and check for it in MemDecoder 2024-05-21 20:12:29 -04:00
rustc_resolve Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, r=Nilstrieb 2024-05-23 07:41:17 +02:00
rustc_sanitizers Fix typos (taking into account review comments) 2024-05-18 18:12:18 +02:00
rustc_serialize PR feedback 2024-05-21 20:12:30 -04:00
rustc_session Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
rustc_smir Rollup merge of #125336 - momvart:smir-77-intrinsic, r=celinval 2024-05-23 20:09:09 +02:00
rustc_span Remove #[macro_use] extern crate tracing from rustc_span`. 2024-05-22 16:03:48 +10:00
rustc_symbol_mangling Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
rustc_target Auto merge of #124676 - djkoloski:relax_multiple_sanitizers, r=cuviper,rcvalle 2024-05-21 15:35:29 +00:00
rustc_trait_selection Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obk 2024-05-22 19:04:45 +02:00
rustc_traits split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
rustc_transmute Align: add bytes_usize and bits_usize 2024-05-01 15:57:33 +02:00
rustc_ty_utils Rollup merge of #125173 - scottmcm:never-checked, r=davidtwco 2024-05-20 18:13:48 +02:00
rustc_type_ir Uplift OutlivesPredicate, remove a bunch of unnecessary associated types from Interner 2024-05-21 17:00:45 -04:00
rustc_type_ir_macros Uplift TraitPredicate 2024-05-11 18:20:00 -04:00
stable_mir Rollup merge of #125336 - momvart:smir-77-intrinsic, r=celinval 2024-05-23 20:09:09 +02:00