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

Use ObligationCtxt in custom type ops #111741

Merged
merged 1 commit into from
May 25, 2023

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented May 18, 2023

We already make one when evaluating the CustomTypeOp, so it's simpler to just pass it to the user. Removes a redundant ObligationCtxt::new_in_snapshot usage and simplifies some other code.

This makes several refactorings related to opaque types in the new solver simpler, but those are not included in this PR.

@rustbot
Copy link
Collaborator

rustbot commented May 18, 2023

r? @TaKO8Ki

(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 18, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member Author

r? @lcnr feel free to reassign (maybe to oli)

@rustbot rustbot assigned lcnr and unassigned TaKO8Ki May 22, 2023
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

r=me after nits

// delay more bugs than accidentally not delay a bug at all.
self.type_checker.tcx().sess.delay_span_bug(
self.locations.span(self.type_checker.body),
format!("errors selecting obligation during MIR typeck"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
format!("errors selecting obligation during MIR typeck"),
"errors selecting obligation during MIR typeck",

when can we hit that case, given that we previously used unwrap here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Happens because if we hit an error while processing the region obligations, we return Err(NoSolution) instead of just Ok. Shouldn't matter anyways because we delay a bug both here and within scrape, but it's probably better to migrate to returning ErrorGuaranteed like you said below. I'll do it in a quick follow-up to avoid having re-review 😅

Comment on lines +78 to +81
infcx.tcx.sess.delay_span_bug(
DUMMY_SP,
format!("errors selecting obligation during MIR typeck: {:?}", errors),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we may want to move that delay span bug out of the commit_if_ok and change scrape_region_constraints to return ErrorGuaranteed, think that may be more involved though so it doesn't have to be in this PR

@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented May 24, 2023

📌 Commit 521a0bc has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 24, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 25, 2023
…earth

Rollup of 5 pull requests

Successful merges:

 - rust-lang#111741 (Use `ObligationCtxt` in custom type ops)
 - rust-lang#111840 (Expose more information in `get_body_with_borrowck_facts`)
 - rust-lang#111876 (Roll compiler_builtins to 0.1.92)
 - rust-lang#111912 (Use `Option::is_some_and` and `Result::is_ok_and` in the compiler  )
 - rust-lang#111915 (libtest: Improve error when missing `-Zunstable-options`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a9a4c9b into rust-lang:master May 25, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 25, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this pull request May 26, 2023
…r, r=lcnr

Use `ErrorGuaranteed` more in MIR type ops

Delay bugs more eagerly and pass them through type op infra instead of delaying them at all the usage-sites.

Follow up to: rust-lang#111741 (comment)

r? `@lcnr`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2023
… r=lcnr

Use `ErrorGuaranteed` more in MIR type ops

Delay bugs more eagerly and pass them through type op infra instead of delaying them at all the usage-sites.

Follow up to: rust-lang#111741 (comment)

r? `@lcnr`
saethlin pushed a commit to saethlin/miri that referenced this pull request May 26, 2023
Use `ErrorGuaranteed` more in MIR type ops

Delay bugs more eagerly and pass them through type op infra instead of delaying them at all the usage-sites.

Follow up to: rust-lang/rust#111741 (comment)

r? `@lcnr`
@compiler-errors compiler-errors deleted the custom-type-op branch August 11, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants