Skip to content

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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Apr 24, 2025

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

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

rustbot commented Apr 24, 2025

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.

@lcnr
Copy link
Contributor

lcnr commented Apr 25, 2025

pls add test

trait With {
    type Assoc;
}
impl<T> With for T {
    type Assoc = T;
}

trait Incomplete<T> {}
impl<T> Incomplete<T> for () {}
fn impls_incomplete<T: Incomplete<U>, U>() {}
fn foo<T>()
where
    u32: With<Assoc = T>,
    (): Incomplete<<u32 as With>::Assoc>,
{
    impls_incomplete::<(), _>();
}

fn main() {}

edit: actually, added as part of #140313

@bors
Copy link
Collaborator

bors commented Apr 26, 2025

☔ 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-errors force-pushed the only-global-post-norm branch 2 times, most recently from c20c569 to 4750eaf Compare May 6, 2025 20:24
@rust-log-analyzer

This comment has been minimized.

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.

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`
@compiler-errors compiler-errors force-pushed the only-global-post-norm branch from 4750eaf to 454f6c6 Compare May 7, 2025 16:27
@compiler-errors compiler-errors force-pushed the only-global-post-norm branch from 454f6c6 to 8a21d1b Compare May 7, 2025 16:29
@lcnr
Copy link
Contributor

lcnr commented May 7, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 7, 2025

📌 Commit 8a21d1b 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 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
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
matthiaskrgr added a commit to matthiaskrgr/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
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
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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants