-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't require intercrate mode for negative coherence #117992
Don't require intercrate mode for negative coherence #117992
Conversation
don't believe this to require an FCP @bors r+ rollup |
…lete, r=lcnr Don't require intercrate mode for negative coherence Negative coherence needs to be *sound*, but does not need to be *complete*, since it's looking for the *existence* of a negative goal, not the non-existence of a positive goal. This removes some trivial and annoying ambiguities when a negative impl has region constraints. r? lcnr idk if this needs an fcp but if it does, pls kick it off
…lete, r=lcnr Don't require intercrate mode for negative coherence Negative coherence needs to be *sound*, but does not need to be *complete*, since it's looking for the *existence* of a negative goal, not the non-existence of a positive goal. This removes some trivial and annoying ambiguities when a negative impl has region constraints. r? lcnr idk if this needs an fcp but if it does, pls kick it off
…lete, r=lcnr Don't require intercrate mode for negative coherence Negative coherence needs to be *sound*, but does not need to be *complete*, since it's looking for the *existence* of a negative goal, not the non-existence of a positive goal. This removes some trivial and annoying ambiguities when a negative impl has region constraints. r? lcnr idk if this needs an fcp but if it does, pls kick it off
This pull request may have caused this error. |
Gonna re-approve this one first @bors r=lcnr |
// N.B. We don't need to use intercrate mode here because we're trying to prove | ||
// the *existence* of a negative goal, not the non-existence of a positive goal. | ||
// Without this, we over-eagerly register coherence ambiguity candidates when | ||
// impl candidates do exist. | ||
let ref infcx = tcx.infer_ctxt().with_next_trait_solver(true).build(); |
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.
I believe the intercrate mode must be enabled when equating impl headers in order to not over constrain the common type (e.g. disallow equating alias substs). It can then, and only then, be safely disabled in try_prove_negated_where_clause
.
I think this is only a theoretical unsoundness for now because we currently ignore the obligations of equate_impl_headers
and because infcx.eq
does not have intercrate-specfic behavior (in the new solver mode that is. for the old solver, there is 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.
Yeah, that makes sense. I can leave a comment clarifying that next to the line where we currently throw away these obligations.
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.
can't we just disable it in try_prove_negated_where_clause
? the fact that we rely on infcx.eq
to not have intercrate-specific behavior is a bit scary.
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.
I don't think we have facilities to set the intercrate mode currently, but I guess I could add it to fork
, probably the best way to do it.
@bors r- so i dont forget to leave this comment |
ae62ebe
to
348c9c2
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.
Looks good now. You can r=me unless you want lcnr to review.
348c9c2
to
506ec26
Compare
Yeah, I'll r=lcnr,aliemjay once #117994 lands. Just fixed up some comments. |
506ec26
to
253f502
Compare
19a5e1d is necessary for soundness. We emit region requirements when plugging region inference vars with placeholders, which are necessary to keep around, otherwise code like this passes:
@bors r=lcnr,aliemjay |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#117327 (Add documentation for some queries) - rust-lang#117835 (Note about object lifetime defaults in does not live long enough error) - rust-lang#117851 (Uplift `InferConst` to `rustc_type_ir`) - rust-lang#117973 (test: Add test for async-move in 2015 Rust proc macro) - rust-lang#117992 (Don't require intercrate mode for negative coherence) - rust-lang#118010 (Typeck break expr even if break is illegal) - rust-lang#118026 (Don't consider regions in `deref_into_dyn_supertrait` lint) - rust-lang#118089 (intercrate_ambiguity_causes: handle self ty infer + reservation impls) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#117327 (Add documentation for some queries) - rust-lang#117835 (Note about object lifetime defaults in does not live long enough error) - rust-lang#117851 (Uplift `InferConst` to `rustc_type_ir`) - rust-lang#117973 (test: Add test for async-move in 2015 Rust proc macro) - rust-lang#117992 (Don't require intercrate mode for negative coherence) - rust-lang#118010 (Typeck break expr even if break is illegal) - rust-lang#118026 (Don't consider regions in `deref_into_dyn_supertrait` lint) - rust-lang#118089 (intercrate_ambiguity_causes: handle self ty infer + reservation impls) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#117327 (Add documentation for some queries) - rust-lang#117835 (Note about object lifetime defaults in does not live long enough error) - rust-lang#117851 (Uplift `InferConst` to `rustc_type_ir`) - rust-lang#117973 (test: Add test for async-move in 2015 Rust proc macro) - rust-lang#117992 (Don't require intercrate mode for negative coherence) - rust-lang#118010 (Typeck break expr even if break is illegal) - rust-lang#118026 (Don't consider regions in `deref_into_dyn_supertrait` lint) - rust-lang#118089 (intercrate_ambiguity_causes: handle self ty infer + reservation impls) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#117992 - compiler-errors:sound-but-not-complete, r=lcnr,aliemjay Don't require intercrate mode for negative coherence Negative coherence needs to be *sound*, but does not need to be *complete*, since it's looking for the *existence* of a negative goal, not the non-existence of a positive goal. This removes some trivial and annoying ambiguities when a negative impl has region constraints. r? lcnr idk if this needs an fcp but if it does, pls kick it off
Negative coherence needs to be sound, but does not need to be complete, since it's looking for the existence of a negative goal, not the non-existence of a positive goal.
This removes some trivial and annoying ambiguities when a negative impl has region constraints.
r? lcnr idk if this needs an fcp but if it does, pls kick it off