Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ty_utils): try normalize earsing regions #111259

Closed
wants to merge 1 commit into from

Conversation

bvanjoi
Copy link
Contributor

@bvanjoi bvanjoi commented May 5, 2023

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
Copy link
Collaborator

rustbot commented May 5, 2023

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
Copy link
Member

@compiler-errors compiler-errors left a comment

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

compiler/rustc_ty_utils/src/instance.rs Outdated Show resolved Hide resolved
compiler/rustc_ty_utils/src/instance.rs Outdated Show resolved Hide resolved
@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
Copy link
Contributor Author

bvanjoi commented May 6, 2023

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
Copy link
Collaborator

rustbot commented May 6, 2023

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@@ -90,6 +90,7 @@ declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY]);
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
Contributor Author

Choose a reason for hiding this comment

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

for #105561

@@ -380,6 +381,7 @@ declare_lint_pass!(Diagnostics => [ UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSID
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
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
Copy link
Contributor Author

bvanjoi commented May 6, 2023

@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
Copy link
Member

BoxyUwU commented May 11, 2023

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: Marked as 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
Copy link
Contributor

bors commented Jul 14, 2023

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

@Dylan-DPC
Copy link
Member

@bvanjoi any updates on this? thanks

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Aug 10, 2023

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: Marked as 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