Don't fix builtin index when Where clause is found#100598
Merged
bors merged 1 commit intorust-lang:masterfrom Aug 19, 2022
Merged
Don't fix builtin index when Where clause is found#100598bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Contributor
compiler-errors
left a comment
There was a problem hiding this comment.
Left a few style nits
src/test/mir-opt/issue-91633.rs
Outdated
Comment on lines
2
to
30
Contributor
There was a problem hiding this comment.
nit: the index operation is getting compiled out of some of these, try making these return -> &T or T instead?
Comment on lines
206
to
213
Contributor
There was a problem hiding this comment.
Actually... it might be wrong to use expr_ty_adjusted here. The un-adjusted expr should be &T, so maybe try:
Suggested change
| if let Some(elem_ty) = base_ty.builtin_index() { | |
| let exp_ty = typeck_results.expr_ty_adjusted(e); | |
| let resolved_exp_ty = self.resolve(exp_ty, &e.span); | |
| elem_ty == resolved_exp_ty && index_ty == self.fcx.tcx.types.usize | |
| } else { | |
| false | |
| } | |
| let Some(expected_elem_ty) = base_ty.builtin_index() else { return false; }; | |
| let Some(exp_ty) = typeck_results.expr_ty_opt(e) else { return false; }; | |
| let ty::Ref(_, found_elem_ty, _) = self.resolve(exp_ty, &e.span).kind() else { return false; }; | |
| expected_elem_ty == found_elem_ty && index_ty == self.fcx.tcx.types.usize |
This comment has been minimized.
This comment has been minimized.
Contributor
|
Thanks so much for this fix! Can you squash this into one or two commits? Then r=me. @bors delegate+ |
Collaborator
|
✌️ @ouz-a can now approve this pull request |
Contributor
Author
Contributor
|
@bors r+ |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 19, 2022
Rollup of 9 pull requests Successful merges: - rust-lang#99576 (Do not allow `Drop` impl on foreign fundamental types) - rust-lang#100081 (never consider unsafe blocks unused if they would be required with deny(unsafe_op_in_unsafe_fn)) - rust-lang#100208 (make NOP dyn casts not require anything about the vtable) - rust-lang#100494 (Cleanup rustdoc themes) - rust-lang#100522 (Only check the `DefId` for the recursion check in MIR inliner.) - rust-lang#100592 (Manually implement Debug for ImportKind.) - rust-lang#100598 (Don't fix builtin index when Where clause is found) - rust-lang#100721 (Add diagnostics lints to `rustc_type_ir` module) - rust-lang#100731 (rustdoc: count deref and non-deref as same set of used methods) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Where clause shadows blanket impl for
Indexwhich causes normalization to not occur, which causes ICE to happen when we typeck.r? @compiler-errors
Fixes #91633