rust/compiler
Matthias Krüger 3cb1a4676a
Rollup merge of #111279 - compiler-errors:core-item-resolve, r=cjgillot
More robust debug assertions for `Instance::resolve` on built-in traits with non-standard trait items

In #111264, a user added a new item to the `Future` trait, but the code in [`resolve_associated_item`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ty_utils/instance/fn.resolve_associated_item.html) implicitly assumes that the `Future` trait is defined with only one method (`Future::poll`) and treats the generator body as the implementation of that method.

This PR adds some debug assertions to make sure that that new methods defined on `Future`/`Generator`/etc. don't accidentally resolve to the wrong item when they are added, and adds a helpful comment guiding a compiler dev (or curious `#![no_core]` user) to what must be done to support adding new associated items to these built-in implementations.

I am open to discuss whether a test should be added, but I chose against it because I opted to make these `bug!()`s instead of, e.g., diagnostics or fatal errors. Arguably it doesn't need a test because it's not a bug that can be triggered by an end user, and internal-facing misuses of core kind of touch on rust-lang/compiler-team#620 -- however, I think the assertions I added in this PR are still a very useful way to make sure this bug doesn't waste debugging resources down the line.

Fixes #111264
2023-05-06 13:30:06 +02:00
..
rustc
rustc_abi Reorder to keep duplicate checks in sync. 2023-05-05 16:30:32 -07:00
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 2023-05-05 18:40:33 +05:30
rustc_ast_lowering
rustc_ast_passes Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 2023-05-05 18:40:33 +05:30
rustc_ast_pretty Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 2023-05-05 18:40:33 +05:30
rustc_attr Improve check-cfg diagnostics (part 2) 2023-05-05 13:06:48 +02:00
rustc_baked_icu_data
rustc_borrowck Rollup merge of #111132 - lcnr:nll-generalize, r=b-naber 2023-05-05 12:46:27 +09:00
rustc_builtin_macros Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 2023-05-05 18:40:33 +05:30
rustc_codegen_cranelift
rustc_codegen_gcc
rustc_codegen_llvm Rollup merge of #111167 - cuviper:type-decl-disubprogram, r=michaelwoerister 2023-05-06 13:30:05 +02:00
rustc_codegen_ssa Rollup merge of #110985 - Amanieu:normalize_asm_spans, r=b-naber 2023-05-06 13:30:04 +02:00
rustc_const_eval
rustc_data_structures
rustc_driver
rustc_driver_impl Rollup merge of #110989 - jyn514:bug-report-url, r=WaffleLapkin 2023-05-06 13:30:04 +02:00
rustc_error_codes
rustc_error_messages
rustc_errors Mark ErrorGuaranteed constructor as deprecated so people don't use it 2023-05-05 17:58:46 +00:00
rustc_expand Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 2023-05-05 18:40:33 +05:30
rustc_feature Rollup merge of #109677 - dpaoliello:rawdylib, r=michaelwoerister,wesleywiser 2023-05-06 09:09:30 +09:00
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 2023-05-05 18:40:33 +05:30
rustc_hir_analysis Rollup merge of #110577 - compiler-errors:drop-impl-fulfill, r=lcnr 2023-05-06 13:30:03 +02:00
rustc_hir_pretty
rustc_hir_typeck Rollup merge of #111261 - compiler-errors:error-guaranteed-should-be-scarier-to-construct, r=BoxyUwU 2023-05-06 09:09:34 +09:00
rustc_incremental
rustc_index
rustc_infer Rollup merge of #110577 - compiler-errors:drop-impl-fulfill, r=lcnr 2023-05-06 13:30:03 +02:00
rustc_interface Rollup merge of #109677 - dpaoliello:rawdylib, r=michaelwoerister,wesleywiser 2023-05-06 09:09:30 +09:00
rustc_lexer
rustc_lint Improve check-cfg diagnostics (part 2) 2023-05-05 13:06:48 +02:00
rustc_lint_defs Improve check-cfg diagnostics (part 2) 2023-05-05 13:06:48 +02:00
rustc_llvm Rollup merge of #111167 - cuviper:type-decl-disubprogram, r=michaelwoerister 2023-05-06 13:30:05 +02:00
rustc_log
rustc_macros
rustc_metadata Rollup merge of #109677 - dpaoliello:rawdylib, r=michaelwoerister,wesleywiser 2023-05-06 09:09:30 +09:00
rustc_middle Rollup merge of #111279 - compiler-errors:core-item-resolve, r=cjgillot 2023-05-06 13:30:06 +02:00
rustc_mir_build Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors 2023-05-05 18:40:33 +05:30
rustc_mir_dataflow
rustc_mir_transform Reject borrows of projections in ConstProp. 2023-05-04 21:51:44 +00:00
rustc_monomorphize
rustc_parse Rollup merge of #111230 - zacklukem:eq-less-to-less-eq, r=compiler-errors 2023-05-06 13:30:05 +02:00
rustc_parse_format
rustc_passes Auto merge of #111014 - klensy:no-rc, r=WaffleLapkin 2023-05-04 20:49:23 +00:00
rustc_plugin_impl
rustc_privacy
rustc_query_impl
rustc_query_system
rustc_resolve Rollup merge of #110982 - cjgillot:elided-self-const, r=petrochenkov 2023-05-04 19:18:20 +02:00
rustc_serialize
rustc_session Rollup merge of #109677 - dpaoliello:rawdylib, r=michaelwoerister,wesleywiser 2023-05-06 09:09:30 +09:00
rustc_smir Add GeneratorDrop terminator to SMIR 2023-05-05 10:34:55 -03:00
rustc_span Rollup merge of #111279 - compiler-errors:core-item-resolve, r=cjgillot 2023-05-06 13:30:06 +02:00
rustc_symbol_mangling
rustc_target
rustc_trait_selection Rollup merge of #110577 - compiler-errors:drop-impl-fulfill, r=lcnr 2023-05-06 13:30:03 +02:00
rustc_traits
rustc_transmute
rustc_ty_utils Rollup merge of #111279 - compiler-errors:core-item-resolve, r=cjgillot 2023-05-06 13:30:06 +02:00
rustc_type_ir