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

implement deep normalization via the new solver #113086

Merged
merged 10 commits into from
Jul 3, 2023
Merged

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jun 27, 2023

together with #112869 this should remove all uses of the old solver with -Ztrait-solver=next.

see rust-lang/rustc-dev-guide#1731 for a description of this PR.

r? @compiler-errors

@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 Jun 27, 2023
@lcnr lcnr marked this pull request as ready for review June 27, 2023 14:53
@rustbot
Copy link
Collaborator

rustbot commented Jun 27, 2023

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in engine.rs, potentially modifying the public API of ObligationCtxt.

cc @lcnr, @compiler-errors

Some changes occurred to the core trait solver

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

@lcnr
Copy link
Contributor Author

lcnr commented Jun 27, 2023

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 27, 2023
@bors
Copy link
Contributor

bors commented Jun 27, 2023

⌛ Trying commit e45487d2496207e818a168c19c8dec3adb225d31 with merge 6af9e55186a60a213d3a1dbda6c55404e4ccc68d...

Comment on lines +430 to +431
let Ok(wf_tys) = ocx.assumed_wf_types(param_env, body_def_id)
else {
Copy link
Contributor

Choose a reason for hiding this comment

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

🤣

@@ -72,3 +83,28 @@ fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Ty<'_>> {
| DefKind::Generator => ty::List::empty(),
}
}

fn fn_sig_spans(tcx: TyCtxt<'_>, def_id: LocalDefId) -> impl Iterator<Item = Span> + '_ {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be added as a method and then re-used in opaque_types_defined_by, which does the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, could be added as a method on hir::Map probably

@bors
Copy link
Contributor

bors commented Jun 27, 2023

☀️ Try build successful - checks-actions
Build commit: 6af9e55186a60a213d3a1dbda6c55404e4ccc68d (6af9e55186a60a213d3a1dbda6c55404e4ccc68d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6af9e55186a60a213d3a1dbda6c55404e4ccc68d): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.8% [0.3%, 2.1%] 8
Regressions ❌
(secondary)
0.6% [0.5%, 1.1%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.6%] 1
All ❌✅ (primary) 0.8% [0.3%, 2.1%] 8

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.1% [2.0%, 2.2%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [2.0%, 2.2%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 661.852s -> 662.454s (0.09%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 27, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jun 27, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@lcnr lcnr force-pushed the rust8 branch 2 times, most recently from f30cb8f to 5d4229a Compare June 27, 2023 21:14
// compile-flags: -Ztrait-solver=next
// known-bug: unknown

// FIXME(-Ztrait-solver=next): what is this testing and why did we add this test.
Copy link
Member

Choose a reason for hiding this comment

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

This was supposed to be testing <?0 as Trait>::Assoc = ?0 hitting the occurs check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, broke because of variance for some reason 😅 change it to force the infer var to be invariant

compiler/rustc_trait_selection/src/solve/normalize.rs Outdated Show resolved Hide resolved
}
}

fn deeply_normalize<T: TypeFoldable<TyCtxt<'tcx>>>(
Copy link
Member

Choose a reason for hiding this comment

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

Naming thought: Should this perhaps just be called fully_normalize? since it basically does what that does.

Copy link
Member

Choose a reason for hiding this comment

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

And I think calls to fully_normalize should get migrated to this one, probably.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added comments for that. didn't rename this yet to not make the confusion worse

compiler/rustc_trait_selection/src/traits/project.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/solve/normalize.rs Outdated Show resolved Hide resolved
@lcnr
Copy link
Contributor Author

lcnr commented Jul 3, 2023

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jul 3, 2023

📌 Commit be6a344 has been approved by compiler-errors

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 Jul 3, 2023
@bors
Copy link
Contributor

bors commented Jul 3, 2023

⌛ Testing commit be6a344 with merge 737b461...

@bors
Copy link
Contributor

bors commented Jul 3, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 737b461 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 3, 2023
@bors bors merged commit 737b461 into rust-lang:master Jul 3, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jul 3, 2023
@lcnr lcnr deleted the rust8 branch July 3, 2023 10:29
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (737b461): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.1% [2.9%, 3.2%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.5% [-1.5%, -1.5%] 1
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.5% [2.5%, 2.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 670.62s -> 670.769s (0.02%)

@rustbot rustbot removed the perf-regression Performance regression. label Jul 3, 2023
@lcnr lcnr mentioned this pull request Jul 4, 2023
11 tasks
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 7, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 7, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 7, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jul 8, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 8, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

8 participants