Skip to content

Only prefer param-env candidates if they remain non-global after norm - #140260

Merged
bors merged 3 commits into
rust-lang:masterfrom
compiler-errors:only-global-post-norm
May 8, 2025
Merged

Only prefer param-env candidates if they remain non-global after norm#140260
bors merged 3 commits into
rust-lang:masterfrom
compiler-errors:only-global-post-norm

Conversation

@compiler-errors

@compiler-errorscompiler-errors commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

Introduce CandidateSource::GlobalParamEnv, and dynamically compute the CandidateSource based on whether the predicate contains params post-normalization.

This code needs some cleanup and documentation. I'm just putting this up for review.

cc rust-lang/trait-system-refactor-initiative#179

r? lcnr

@rustbotrustbot 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Apr 24, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_next_trait_solver/src/solve/assembly/mod.rs Outdated
@lcnr

lcnr commented Apr 25, 2025

Copy link
Copy Markdown
Contributor

pls add test

traitWith{typeAssoc;}impl<T>WithforT{typeAssoc = T;}traitIncomplete<T>{}impl<T>Incomplete<T>for(){}fnimpls_incomplete<T:Incomplete<U>,U>(){}fnfoo<T>()whereu32:With<Assoc = T>,():Incomplete<<u32asWith>::Assoc>,{impls_incomplete::<(),_>();}fnmain(){}

edit: actually, added as part of #140313

@bors

bors commented Apr 26, 2025

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #140324) made this pull request unmergeable. Please resolve the merge conflicts.

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
~~[top 100 most downloaded crates on crates.io compile](rust-lang#133502 (comment)
[top 1000 most downloaded crates on crates.io compile](rust-lang#133502 (comment))
[first perf run](rust-lang#133502 (comment)) 👻
### in-flight changes
- rust-lang#124852, unsure whether I actually want to land this PR for now
- rust-lang#139587
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140302
- rust-lang#140276
- rust-lang#140260
- rust-lang#140405
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 29, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
~~[top 100 most downloaded crates on crates.io compile](rust-lang#133502 (comment)
[top 1000 most downloaded crates on crates.io compile](rust-lang#133502 (comment))
[first perf run](rust-lang#133502 (comment)) 👻
### in-flight changes
- rust-lang#124852, unsure whether I actually want to land this PR for now
- rust-lang#139587
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140302
- rust-lang#140276
- rust-lang#140260
- rust-lang#140405
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
~~[top 100 most downloaded crates on crates.io compile](rust-lang#133502 (comment)
[top 1000 most downloaded crates on crates.io compile](rust-lang#133502 (comment))
[first perf run](rust-lang#133502 (comment)) 👻
### in-flight changes
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
~~[top 100 most downloaded crates on crates.io compile](rust-lang#133502 (comment)
[top 1000 most downloaded crates on crates.io compile](rust-lang#133502 (comment))
[first perf run](rust-lang#133502 (comment)) 👻
### in-flight changes
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 1, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
### in-flight changes
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 3, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
[^1]: a complete crater run
### in-flight changes
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 3, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
[^1]: a complete crater run
### in-flight changes
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
- double recursion limit in the new solver
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 5, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
[^1]: a complete crater run
### in-flight changes
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
- double recursion limit in the new solver
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 5, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
| 2025.05.05 | 8964[^2] | 931 |
[^1]: a complete crater run
[^2]: only testing crates which may have regressed from the above run
### in-flight changes
- rust-lang#140561
- rust-lang#140672
- rust-lang#140678
- rust-lang#136997
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
- double recursion limit in the new solver
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 6, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
| 2025.05.05 | 8964[^2] | 931 |
[^1]: a complete crater run
[^2]: only testing crates which may have regressed from the above run
### in-flight changes
- rust-lang#140561
- rust-lang#140672
- rust-lang#140678
- rust-lang#136997
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
- double recursion limit in the new solver
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 6, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
| 2025.05.05 | 8964[^2] | 931 |
| 2025.05.06 | 4401[^2] | 726 |
[^1]: a complete crater run
[^2]: only testing crates which may have regressed from the above run
### in-flight changes
- rust-lang#140561
- rust-lang#140672
- rust-lang#140678
- rust-lang#136997
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
- double recursion limit in the new solver
r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 6, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
| 2025.05.05 | 8964[^2] | 931 |
| 2025.05.06 | 4401[^2] | 726 |
[^1]: a complete crater run
[^2]: only testing crates which may have regressed from the above run
### in-flight changes
- rust-lang#140561
- rust-lang#140672
- rust-lang#140678
- rust-lang#136997
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- rust-lang#140496
- double recursion limit in the new solver
r? `@ghost`
@compiler-errors
compiler-errorsforce-pushed the only-global-post-norm branch 2 times, most recently from c20c569 to 4750eafCompareMay 6, 2025 20:24
@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_next_trait_solver/src/solve/assembly/mod.rs Outdated
Comment threadcompiler/rustc_next_trait_solver/src/solve/assembly/mod.rs Outdated
Comment threadcompiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Comment threadcompiler/rustc_next_trait_solver/src/solve/effect_goals.rs Outdated
Comment threadcompiler/rustc_next_trait_solver/src/solve/assembly/mod.rs Outdated
Comment threadcompiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs Outdated
Comment threadcompiler/rustc_type_ir/src/solve/mod.rs

@lcnrlcnr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nits, then r=me

bors added a commit to rust-lang-ci/rust that referenced this pull request May 7, 2025
[DO NOT MERGE] bootstrap with `-Znext-solver=globally`
A revival of rust-lang#124812.
Current status:
~~`./x.py b --stage 2` passes 🎉~~
`try` builds succeed 🎉 🎉 🎉
[first perf run](rust-lang#133502 (comment)) 👻
### crater
This does not detect hangs or memory issues.
| date | #crates | #regressions |
| ---- | ------- | ------------ |
| 2025.04.11 | 100 | 2 |
| 2025.04.11 | 1000 | 27 |
| 2025.04.17 | 10000 | 456 |
| 2025.04.18 | 10000 | 437 |
| 2025.04.24 | 10000 | 164 |
| 2025.04.26 | 10000 | 108 |
| 2025.04.28 | 10000 | 91 |
| 2025.05.01 | 10000 | 145 woops |
| 2025.05.03 | 624228[^1] | 1585 |
| 2025.05.05 | 8964[^2] | 931 |
| 2025.05.06 | 4401[^2] | 726 |
[^1]: a complete crater run
[^2]: only testing crates which may have regressed from the above run
### in-flight changes
- rust-lang#140711
- rust-lang#140713
- rust-lang#140712
- rust-lang#136997
- rust-lang#139587
- rust-lang#140497
- rust-lang#124852, unsure whether I actually want to land this PR for now
- https://github.com/lcnr/rust/tree/opaque-type-method-call
- rust-lang#140260
- rust-lang#140375
- rust-lang#140405
- look into blanket impls for opaque type infer vars as well
- rust-lang#140496
- double recursion limit in the new solver
r? `@ghost`
@lcnr

lcnr commented May 7, 2025

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented May 7, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 8a21d1b has been approved by lcnr

It is now in the queue for this repository.

@borsbors 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 7, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request May 8, 2025
…orm, r=lcnr
Only prefer param-env candidates if they remain non-global after norm
Introduce `CandidateSource::GlobalParamEnv`, and dynamically compute the `CandidateSource` based on whether the predicate contains params *post-normalization*.
This code needs some cleanup and documentation. I'm just putting this up for review.
cc rust-lang/trait-system-refactor-initiative#179
r? lcnr
@ZalatharZalathar mentioned this pull request May 8, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2025
Rollup of 15 pull requests
Successful merges:
- rust-lang#138736 (Sanitizers target modificators)
- rust-lang#140260 (Only prefer param-env candidates if they remain non-global after norm)
- rust-lang#140523 (Better error message for late/early lifetime param mismatch)
- rust-lang#140579 (Remove estebank from automated review assignment)
- rust-lang#140641 (detect additional uses of opaques after writeback)
- rust-lang#140711 (Do not discard constraints on overflow if there was candidate ambiguity)
- rust-lang#140716 (Improve `-Zremap-path-scope` tests with dependency)
- rust-lang#140755 ([win][arm64] Disable various DebugInfo tests that don't work on Arm64 Windows)
- rust-lang#140756 ([arm64] Pointer auth test should link with C static library statically)
- rust-lang#140758 ([win][arm64] Disable MSVC Linker 'Arm Hazard' warning)
- rust-lang#140759 ([win][arm64] Disable std::fs tests that require symlinks)
- rust-lang#140762 (rustdoc-json: Remove newlines from attributes)
- rust-lang#140764 (style: Never break within a nullary function call `func()` or a unit literal `()`)
- rust-lang#140769 (Add `DefPathData::OpaqueLifetime` to avoid conflicts for remapped opaque lifetimes)
- rust-lang#140773 (triagebot: Better message for changes to `tests/rustdoc-json`)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2025
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#140260 (Only prefer param-env candidates if they remain non-global after norm)
- rust-lang#140523 (Better error message for late/early lifetime param mismatch)
- rust-lang#140579 (Remove estebank from automated review assignment)
- rust-lang#140641 (detect additional uses of opaques after writeback)
- rust-lang#140711 (Do not discard constraints on overflow if there was candidate ambiguity)
- rust-lang#140762 (rustdoc-json: Remove newlines from attributes)
- rust-lang#140764 (style: Never break within a nullary function call `func()` or a unit literal `()`)
- rust-lang#140769 (Add `DefPathData::OpaqueLifetime` to avoid conflicts for remapped opaque lifetimes)
- rust-lang#140773 (triagebot: Better message for changes to `tests/rustdoc-json`)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 8a3ab85 into rust-lang:masterMay 8, 2025
@rustbotrustbot added this to the 1.88.0 milestone May 8, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2025
Rollup merge of rust-lang#140260 - compiler-errors:only-global-post-norm, r=lcnr
Only prefer param-env candidates if they remain non-global after norm
Introduce `CandidateSource::GlobalParamEnv`, and dynamically compute the `CandidateSource` based on whether the predicate contains params *post-normalization*.
This code needs some cleanup and documentation. I'm just putting this up for review.
cc rust-lang/trait-system-refactor-initiative#179
r? lcnr
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@compiler-errors@rustbot@rust-log-analyzer@lcnr@bors