-
Notifications
You must be signed in to change notification settings - Fork 13.9k
add TypingMode::Borrowck
#138785
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
add TypingMode::Borrowck
#138785
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
add `TypingMode::Borrowck` Still not quite ready Based on rust-lang#138492 and rust-lang#138719 r? `@compiler-errors` `@oli-obk`
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
increment depth of nested obligations properly fixes the root cause of rust-lang#109268. While we didn't get hangs here before, I ended up encountering its root cause again with rust-lang#138785. r? types
78732a8 to
9b611a3
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
increment depth of nested obligations properly fixes the root cause of rust-lang#109268. While we didn't get hangs here before, I ended up encountering its root cause again with rust-lang#138785. r? types
increment depth of nested obligations properly fixes the root cause of rust-lang#109268. While we didn't get hangs here before, I ended up encountering its root cause again with rust-lang#138785. r? types
0b44108 to
d7cf428
Compare
we already collect opaque types from nested items during `mir_borrowck` of the root, checking that they are consistent this way.
815679b to
509a144
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes all sense to me
| hidden_ty.ty | ||
| } else { | ||
| hir_opaque_ty = Some(concrete_type); | ||
| let hir_ty = tcx.type_of_opaque_hir_typeck(def_id).instantiate_identity(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do we go down this route? If borrowck was tainted, we don't get here. If borrowck didn't find the opaque constraint because it was only in typeck, that's allowed for RPIT, but shouldn't we have gotten the HIR type in borrowck now that all the HIR types are seeding the borrowck table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this is reachable if neither -Ztyping-mode-borrowck or -Znext-solver=globally are enabled, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not seeding the borrowck table anymore, we only seed the default value when encountering an opaque. If the only uses of the opaque are in dead code, we still don't have any opaque in the opaque type storage in the old solver. cc #112417
I think the new solver may actually never reach this as we should try to eagerly normalize the fn sig which defines the opaque? But for now having only uses in dead code does reach this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me,oli-obk
| pub tainted_by_errors: Option<ErrorGuaranteed>, | ||
|
|
||
| /// All the opaque types that have hidden types set by this function. | ||
| /// We also store the type here, so that the compiler can use it as a hint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update comment slightly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually just fold this into ur next pr, there's no reason to block this pr
|
@bors r=compiler-errors,oli-obk rollup=never |
|
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 5337252 (parent) -> 17ffbc8 (this PR) Test differencesShow 158 test diffsStage 1
Stage 2
Additionally, 134 doctest diffs were found. These are ignored, as they are noisy. Job group index
Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (17ffbc8): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -2.3%, secondary 3.5%)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.
CyclesResults (secondary 3.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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 779.508s -> 780.342s (0.11%) |
|
@craterbot run mode=check-only start=master#5337252b9952fdd9482ed6a4add17254e5bd2c40 end=master#17ffbc81a30c094193836a5d7f90dff273b5df93 |
|
👌 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
|
Shares the first commit with #138499, doesn't really matter which PR to land first 😊 😁
Introduces
TypingMode::Borrowckwhich unlikeTypingMode::Analysis, uses the hidden type computed by HIR typeck as the initial value of opaques instead of an unconstrained infer var. This is a part of rust-lang/types-team#129.Using this new
TypingModeis unfortunately a breaking change for now, see tests/ui/impl-trait/non-defining-uses/as-projection-term.rs. Using an inference variable as the initial value results in non-defining uses in the defining scope. We therefore only enable it if with-Znext-solver=globallyor-Ztyping-mode-borrowckTo do that the PR contains the following changes:
TypeckResults::concrete_opaque_typeare already mapped to the definition of the opaque typefn check_opaque_type_parameter_validis moved fromrustc_borrowcktorustc_trait_selectionquery type_of_opaque_hir_typeckwhich, using the same visitors as MIR typeck, attempts to merge the hidden types from HIR typeck from all defining scopesDefiningScopeKindflag to toggle between using borrowck and HIR typeckTypingMode::Borrowck, but adding it to the new structure is annoying and it's not soundness critical, so I intend to not add it back.TypingMode::Borrowckwhich behaves just likeTypingMode::Analysisexcept when normalizing opaque typestype_of_opaque_hir_typeck(opaque)as the initial value after replacing its regions with new inference varsfixes #112201, fixes #132335, fixes #137751
r? @compiler-errors @oli-obk