Skip to content

fix(ty_utils): try normalize earsing regions#111259

Closed
bvanjoi wants to merge 1 commit into
rust-lang:masterfrom
bvanjoi:fix-110630
Closed

fix(ty_utils): try normalize earsing regions#111259
bvanjoi wants to merge 1 commit into
rust-lang:masterfrom
bvanjoi:fix-110630

Conversation

@bvanjoi

@bvanjoi bvanjoi commented May 5, 2023

Copy link
Copy Markdown
Contributor

close #110630

#105561 introduces normalize_erasing_regions for the substs in resolve_instance, this is quite general and can apply to any type. However, it poses a problem for issue #110630, where I as Concat will trigger a bug because Concat is not implemented for I.

In order to solve #110630, this PR:

  • had raised normalize function call, which requires that we now use the normalized substs when necessary.
  • attempting to normalize the substs before resolve during const_eval_resolve_for_typeck, if it failed, we will return TooGeneric error

@rustbot

rustbot commented May 5, 2023

Copy link
Copy Markdown
Collaborator

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 5, 2023

@compiler-errors compiler-errors left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR description really needs more information about:

  1. Why it happens
  2. Why this fix is correct

Comment thread compiler/rustc_ty_utils/src/instance.rs Outdated
Comment thread compiler/rustc_ty_utils/src/instance.rs Outdated
@compiler-errors compiler-errors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2023
@compiler-errors compiler-errors self-assigned this May 5, 2023
@bvanjoi

bvanjoi commented May 6, 2023

Copy link
Copy Markdown
Contributor Author

This PR description really needs more information about:

  1. Why it happens
  2. Why this fix is correct

Thanks for your advice, I will try to add more descriptions

@rustbot

rustbot commented May 6, 2023

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

impl LateLintPass<'_> for QueryStability {
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
let Some((span, def_id, substs)) = typeck_results_of_method_fn(cx, expr) else { return };
let substs = cx.tcx.normalize_erasing_regions(cx.param_env, substs);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for #105561

impl LateLintPass<'_> for Diagnostics {
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
let Some((span, def_id, substs)) = typeck_results_of_method_fn(cx, expr) else { return };
let substs = cx.tcx.normalize_erasing_regions(cx.param_env, substs);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for #105561

@bvanjoi

bvanjoi commented May 6, 2023

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 6, 2023
@BoxyUwU

BoxyUwU commented May 11, 2023

Copy link
Copy Markdown
Member

generic_const_exprs currently evaluates constants without their where clauses holding, resulting in us attempting to do things like this on not-wf code. I do not think this PR is the correct solution to the linked issue, we really ought to be ensuring that ConstKind::Unevaluated is wf before attempting to evaluate it. Replacing infallible stuff with fallible stuff just to mask ICEs caused by this bug doesn't seem desirable to me.

Unfortunately it is not possible right now to "just" check ConstKind::Unevaluated is wf before evaluating it so I do not think it is possible to fix the linked issue in a satisfactory way. The bug here is tracked in rust-lang/project-const-generics#37 and there are a fair amount of issues open with the F-generic_const_exprs label caused by it.

@oli-obk oli-obk added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 12, 2023
@bors

bors commented Jul 14, 2023

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #113591) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC

Copy link
Copy Markdown
Member

@bvanjoi any updates on this? thanks

@bvanjoi

bvanjoi commented Aug 10, 2023

Copy link
Copy Markdown
Contributor Author

Closed this as it is invalid.

@bvanjoi bvanjoi closed this Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: failed to normalize, generic_const_exprs

8 participants