diff options
author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-06 13:30:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-06 13:30:06 +0200 |
commit | 3cb1a4676a62eaa60c74a56c5e389aa1b258b3aa (patch) | |
tree | 5e511705860d6af7a0fdec308dce5ee49ff026c2 /tests/rustdoc-js-std/parser-errors.js | |
parent | 83b29ec743924dc3944ca2a50312ecbdef153588 (diff) | |
parent | 2a1ef34223a17dbe6192ccba13d2ec4bd57a56b9 (diff) | |
download | rust-3cb1a4676a62eaa60c74a56c5e389aa1b258b3aa.tar.gz |
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
Diffstat (limited to 'tests/rustdoc-js-std/parser-errors.js')
0 files changed, 0 insertions, 0 deletions