]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #99449 - compiler-errors:assoc-const-missing-item, r=lcnr
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 23 Jul 2022 21:34:30 +0000 (23:34 +0200)
committerGitHub <noreply@github.com>
Sat, 23 Jul 2022 21:34:30 +0000 (23:34 +0200)
commit3648dd552a850eb57119faa9c85a811676799b2c
tree7f560dab9c7c59debd017c1e5816cb2b7abbac5e
parent93f58b6b0de3fff04fd0011af36a5d3b4a9ae883
parent22b2aae73720b8928859d3500119c9a47ff7bdb0
Rollup merge of #99449 - compiler-errors:assoc-const-missing-item, r=lcnr

Do not resolve associated const when there is no provided value

Fixes #98629, since now we just delay a bug when we're not able to evaluate a const item due to the value not actually being provided by anything. This means compilation proceeds forward to where the "missing item in impl" error is emitted.

----

The root issue here is that when we're looking for the defining `LeafDef` in `resolve_associated_item`, we end up getting the trait's AssocItem instead of the impl's AssocItem (which does not exist). This resolution "succeeds" even if the trait's item has no default value, and then since this item has no value to evaluate, it turns into a const eval error.

This root issue becomes problematic (as in #98629) when this const eval error happens in wfcheck (for example, due to normalizing the param-env of something that references this const). Since this happens sooner than the check that an impl actually provides all of the items that a trait requires (which happens during later typecheck), we end up aborting compilation early with only this un-informative message.

I'm not exactly sure _why_ this bug arises due to #96591 -- perhaps valtrees are evaluated more eagerly than in the old system?

r? ``@oli-obk`` or ``@lcnr`` since y'all are familiar with const eval and reviewed #96591, though feel free to reassign.

This is a regression from stable to beta, so I would be open to considering this for beta backport. It seems correct to me, especially given the improvements in the other UI tests this PR touches, but may have some side-effects that I'm unaware of...?