rust/compiler/rustc_ty_utils/src
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
..
abi.rs Support TLS access into dylibs on Windows 2023-03-29 08:55:21 +02:00
assoc.rs Walk return-position impl trait in trait deeply in associated_item_def_ids 2023-03-29 11:19:48 -03:00
common_traits.rs remove some trait solver helpers 2023-03-21 09:57:20 +01:00
consts.rs Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin 2023-04-22 00:10:44 +00:00
errors.rs Fix typos in compiler 2023-04-10 22:02:52 +02:00
implied_bounds.rs rustc_middle: Remove trait DefIdTree 2023-03-02 23:46:44 +04:00
instance.rs More robust debug assertions for Instance::resolve on built-in traits with custom items 2023-05-06 05:58:04 +00:00
layout.rs Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
layout_sanity_check.rs Factor out checks in layout check and add helper inherent_size. 2023-05-05 16:11:03 -07:00
lib.rs Factor out checks in layout check and add helper inherent_size. 2023-05-05 16:11:03 -07:00
needs_drop.rs Restrict From<S> for {D,Subd}iagnosticMessage. 2023-05-03 08:44:39 +10:00
representability.rs Use local key in providers 2023-03-21 15:38:51 +00:00
structural_match.rs fix clippy::toplevel_ref_arg and ::manual_map 2023-04-16 13:28:13 +02:00
ty.rs Add new ToPredicate impls and TraitRef methods to remove some ty::Binber::dummy calls 2023-04-26 11:48:17 +00:00