Fix query cycle when encounter unevaluated const#148698
Conversation
|
I didn't do this for the |
|
r? @BoxyUwU |
|
|
|
|
||
| // Since there is no generic parameter, we can just drop the environment | ||
| // to prevent query cycle. | ||
| if !uv.args.has_non_region_param() { |
There was a problem hiding this comment.
I think you should be able to do this unconditionally because we early exit above if there are any generic parameters. can can you try always using the empty env. should also be able to get rid of the previous assignment to typing_env this way too
There was a problem hiding this comment.
If there is any region param / region infer in args, unconditionally doing this will empty everything in param_env though, is it ok?
There was a problem hiding this comment.
As discussed privately, it is ok because region will be erased later.
6e5c7f1 to
10fa334
Compare
|
@bors r+ rollup |
Rollup of 5 pull requests Successful merges: - #145610 (Stabilize `char_max_len`) - #148504 (Fix link in c_longlong documentation) - #148698 (Fix query cycle when encounter unevaluated const) - #148865 (move GAT inference prevention hack) - #149016 (Document the `let this = self;` idiom used in MIR building) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #148698 - tiif:const_query_cycle, r=BoxyUwU Fix query cycle when encounter unevaluated const Fixes rust-lang/trait-system-refactor-initiative#249 In this PR, the environment is dropped when evaluating const that does not have any generic parameter to fix the query cycle.
| .with_post_analysis_normalized(tcx); | ||
| // Since there is no generic parameter, we can just drop the environment | ||
| // to prevent query cycle. | ||
| let typing_env = infcx.typing_env(ty::ParamEnv::empty()); |
There was a problem hiding this comment.
that typing env is wrong 🤔 surprised this doesn't blow up. We should use ty::TypingEnv::post_analysis here
I expect us to currently not normalize opaques or default assoc items because of that
There was a problem hiding this comment.
yh it seemed kinda funny to me too, I was surprised we don't have a test for this
There was a problem hiding this comment.
oops will fix this soon. do y'all have any test in mind that could surface this issue in future?
There was a problem hiding this comment.
some use of a TAIT while evaluating the constant. I don't quite know what would cause it to fail 🤔 I guess maybe calling a method on the opaque?
There was a problem hiding this comment.
Fixed in #149183, didn't manage to craft a test that can make it fail :(
Rollup of 5 pull requests Successful merges: - rust-lang/rust#145610 (Stabilize `char_max_len`) - rust-lang/rust#148504 (Fix link in c_longlong documentation) - rust-lang/rust#148698 (Fix query cycle when encounter unevaluated const) - rust-lang/rust#148865 (move GAT inference prevention hack) - rust-lang/rust#149016 (Document the `let this = self;` idiom used in MIR building) r? `@ghost` `@rustbot` modify labels: rollup
Use `TypingMode::PostAnalysis` in `try_evaluate_const` As mentioned in rust-lang#148698 (comment), we should use ``TypingMode::PostAnalysis`` for that path. `@BoxyUwU` prefer the match in ``try_evaluate_const`` to be exhaustive, so I also included that in this PR :3
Use `TypingMode::PostAnalysis` in `try_evaluate_const` As mentioned in rust-lang#148698 (comment), we should use ``TypingMode::PostAnalysis`` for that path. ``@BoxyUwU`` prefer the match in ``try_evaluate_const`` to be exhaustive, so I also included that in this PR :3
Use `TypingMode::PostAnalysis` in `try_evaluate_const` As mentioned in rust-lang#148698 (comment), we should use ``TypingMode::PostAnalysis`` for that path. ```@BoxyUwU``` prefer the match in ``try_evaluate_const`` to be exhaustive, so I also included that in this PR :3
Use `TypingMode::PostAnalysis` in `try_evaluate_const` As mentioned in rust-lang#148698 (comment), we should use ``TypingMode::PostAnalysis`` for that path. ````@BoxyUwU```` prefer the match in ``try_evaluate_const`` to be exhaustive, so I also included that in this PR :3
Rollup merge of #149183 - tiif:typing_env_fix, r=BoxyUwU Use `TypingMode::PostAnalysis` in `try_evaluate_const` As mentioned in #148698 (comment), we should use ``TypingMode::PostAnalysis`` for that path. ````@BoxyUwU```` prefer the match in ``try_evaluate_const`` to be exhaustive, so I also included that in this PR :3
Use `TypingMode::PostAnalysis` in `try_evaluate_const` As mentioned in rust-lang/rust#148698 (comment), we should use ``TypingMode::PostAnalysis`` for that path. ````@BoxyUwU```` prefer the match in ``try_evaluate_const`` to be exhaustive, so I also included that in this PR :3
Fixes rust-lang/trait-system-refactor-initiative#249
In this PR, the environment is dropped when evaluating const that does not have any generic parameter to fix the query cycle.