-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Error on recursive opaque ty in HIR typeck #139419
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
base: master
Are you sure you want to change the base?
Error on recursive opaque ty in HIR typeck #139419
Conversation
@bors try |
This comment was marked as off-topic.
This comment was marked as off-topic.
…<try> Just error on recursive opaque ty in HIR typeck Opening just to gauge fallout. r? `@ghost`
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (f45c1ab): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (secondary -2.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 775.534s -> 775.663s (0.02%) |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
all spurious, can you think of a test case which actually compiled before this PR? I would expect us to error for them already, just after rustc_borrowck |
This is a breaking change, see #139406. We should very much break this, explaining what's going on in that issue |
…que type values" This reverts commit b08e9c2.
99e7ce9
to
dd14f34
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
Some changes occurred in exhaustiveness checking cc @Nadrieril |
I mentioned in the description but I'll say it again -- no crater regressions AFAICT. @rfcbot fcp merge |
Team member @compiler-errors has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
"Non-trivially recursive" opaques are opaques whose hidden types are inferred to be equal to something other than themselves. For example, if we have a TAIT like
type TAIT = impl Sized
, if we infer the hidden type to beTAIT := (TAIT,)
, that would be a non-trivial recursive definition. We don't want to support opaques that are non-trivially recursive, since they will (almost!! -- see caveat below) always result in borrowck errors, and are generally a pain to deal with.On the contrary, trivially recursive opaques may occur today because the old solver overagerly uses
replace_opaque_types_with_inference_vars
. This infer var can then later be constrained to be equal to the opaque itself. These cases will not necessarily result in borrow-checker errors, since other uses of the opaque may properly constrain the opaque. If there are no other uses we may instead fall back to()
today.The only weird case that we have to unfortunately deal with was discovered in #139406:
I think it's pretty obvious that this is not desirable behavior, and according to the crater run there were no regressions, so let's break this so that we don't have any inference hazards in the new solver.
In the future
what2
may end up compiling again by also falling back to()
. However, that is not yet guaranteed and the transition to this state is made significantly harder by not temporarily breaking it on the way. It is also concerning to change the inferred hidden type like this without any notification to the user, even if likely not an issue in this concrete case.