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

Rework ty::Clause, use it more #112714

Closed
wants to merge 6 commits into from

Conversation

compiler-errors
Copy link
Member

r? @ghost

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative labels Jun 16, 2023
@compiler-errors
Copy link
Member Author

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

bors commented Jun 16, 2023

⌛ Trying commit 33d064467cb760d1f2ddf1c8b3dfb8c822dcf2c7 with merge 602bf9cd7c2d90af7c3c308fa13e82e4eb49688d...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 16, 2023

☀️ Try build successful - checks-actions
Build commit: 602bf9cd7c2d90af7c3c308fa13e82e4eb49688d (602bf9cd7c2d90af7c3c308fa13e82e4eb49688d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (602bf9cd7c2d90af7c3c308fa13e82e4eb49688d): comparison URL.

Overall result: ✅ improvements - no 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.

@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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-1.7%, -0.2%] 13
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.4%] 3
All ❌✅ (primary) -0.8% [-1.7%, -0.2%] 13

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.8% [-2.8%, -2.8%] 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)
- - 0
Improvements ✅
(primary)
-3.2% [-5.0%, -0.9%] 10
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) -3.2% [-5.0%, -0.9%] 10

Binary size

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

Bootstrap: 648.664s -> 647.897s (-0.12%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 17, 2023
@compiler-errors
Copy link
Member Author

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

bors commented Jun 17, 2023

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout clause (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self clause --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging src/tools/clippy/clippy_lints/src/dereference.rs
Auto-merging src/librustdoc/clean/mod.rs
Auto-merging compiler/rustc_traits/src/chalk/lowering.rs
Auto-merging compiler/rustc_trait_selection/src/traits/wf.rs
Auto-merging compiler/rustc_trait_selection/src/traits/select/mod.rs
Auto-merging compiler/rustc_trait_selection/src/traits/select/confirmation.rs
Auto-merging compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
Auto-merging compiler/rustc_trait_selection/src/traits/project.rs
Auto-merging compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Auto-merging compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Auto-merging compiler/rustc_trait_selection/src/traits/coherence.rs
Auto-merging compiler/rustc_trait_selection/src/solve/trait_goals.rs
CONFLICT (content): Merge conflict in compiler/rustc_trait_selection/src/solve/trait_goals.rs
Auto-merging compiler/rustc_trait_selection/src/solve/project_goals.rs
CONFLICT (content): Merge conflict in compiler/rustc_trait_selection/src/solve/project_goals.rs
Auto-merging compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
Auto-merging compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs
Auto-merging compiler/rustc_trait_selection/src/solve/assembly/mod.rs
CONFLICT (content): Merge conflict in compiler/rustc_trait_selection/src/solve/assembly/mod.rs
Auto-merging compiler/rustc_privacy/src/lib.rs
Auto-merging compiler/rustc_middle/src/ty/sty.rs
Auto-merging compiler/rustc_middle/src/ty/print/pretty.rs
Auto-merging compiler/rustc_middle/src/ty/mod.rs
CONFLICT (content): Merge conflict in compiler/rustc_middle/src/ty/mod.rs
Auto-merging compiler/rustc_middle/src/ty/flags.rs
Auto-merging compiler/rustc_middle/src/ty/context.rs
Auto-merging compiler/rustc_middle/src/query/mod.rs
Auto-merging compiler/rustc_lint/src/builtin.rs
Auto-merging compiler/rustc_infer/src/infer/error_reporting/mod.rs
Auto-merging compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
Auto-merging compiler/rustc_hir_typeck/src/closure.rs
Auto-merging compiler/rustc_hir_analysis/src/hir_wf_check.rs
Auto-merging compiler/rustc_hir_analysis/src/collect/item_bounds.rs
Auto-merging compiler/rustc_hir_analysis/src/check/wfcheck.rs
Auto-merging compiler/rustc_hir_analysis/src/astconv/mod.rs
Automatic merge failed; fix conflicts and then commit the result.

@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 17, 2023

⌛ Trying commit adf0acb147adf30f627fdd069edc66de96d198fc with merge ce16d8558d8c00f1f1d266d9acdbe86c29495ab7...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 17, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ce16d8558d8c00f1f1d266d9acdbe86c29495ab7): comparison URL.

Overall result: ✅ improvements - no 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.

@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.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-1.1%, -0.2%] 10
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.3%] 2
All ❌✅ (primary) -0.6% [-1.1%, 0.4%] 11

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)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
-3.2% [-3.6%, -2.1%] 4
All ❌✅ (primary) -2.6% [-2.6%, -2.6%] 1

Cycles

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

Binary size

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

Bootstrap: 656.882s -> 655.883s (-0.15%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 17, 2023
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking pin-utils v0.1.0
    Checking unicode-ident v1.0.5
   Compiling syn v1.0.102
    Checking getopts v0.2.21
error[E0271]: expected `Iter<'_, (Clause<'_>, Span)>` to be an iterator that yields `&(Predicate<'_>, Span)`, but it yields `&(Clause<'_>, Span)`
    |
    |
566 | pub fn all_predicates_of(tcx: TyCtxt<'_>, id: DefId) -> impl Iterator<Item = &(Predicate<'_>, Span)> {
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&(Clause<'_>, Span)`, found `&(Predicate<'_>, Span)`
    |
    = note: expected reference `&(rustc_middle::ty::Clause<'_>, Span)`
               found reference `&(rustc_middle::ty::Predicate<'_>, Span)`
    Checking idna v0.2.0
   Compiling tokio v1.28.2
   Compiling quote v1.0.26
error[E0308]: mismatched types
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:29:17
   |
28 |               match predicate.kind().skip_binder() {
   |                     ------------------------------ this expression has type `ClauseKind<'_>`
29 | /                 ty::PredicateKind::Clause(
30 | |                     ty::ClauseKind::RegionOutlives(_)
31 | |                     | ty::ClauseKind::TypeOutlives(_)
32 | |                     | ty::ClauseKind::Projection(_)
33 | |                     | ty::ClauseKind::Trait(..)
34 | |                     | ty::ClauseKind::ConstArgHasType(..),
35 | |                 )
   | |_________________^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:36:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
36 |                 | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:37:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
37 |                 | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:38:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
38 |                 | ty::PredicateKind::ConstEquate(..)
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:39:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
39 |                 | ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:40:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
40 |                 ty::PredicateKind::AliasRelate(..) => panic!("alias relate predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:41:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
41 |                 ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:42:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
42 |                 ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:43:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
43 |                 ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:44:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
44 |                 ty::PredicateKind::Coerce(_) => panic!("coerce predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:45:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
45 |                 ty::PredicateKind::Ambiguous => panic!("ambiguous predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
    Checking clap_lex v0.4.1
    Checking strsim v0.10.0
   Compiling compiletest_rs v0.10.0
   Compiling heck v0.4.0
   Compiling heck v0.4.0
error[E0271]: type mismatch resolving `<&List<Clause<'_>> as IntoIterator>::Item == Predicate<'_>`
    |
    |
691 |             _ => sig_for_projection(cx, proj).or_else(|| sig_from_bounds(cx, ty, cx.param_env.caller_bounds(), None)),
    |                                                          ---------------         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Predicate<'_>`, found `Clause<'_>`
    |                                                          required by a bound introduced by this call
    |
note: required by a bound in `sig_from_bounds`
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
    |
698 | fn sig_from_bounds<'tcx>(
...
701 |     predicates: impl IntoIterator<Item = Predicate<'tcx>>,
    |                                   ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `sig_from_bounds`


error[E0271]: type mismatch resolving `<&List<Clause<'_>> as IntoIterator>::Item == Predicate<'_>`
    |
    |
693 |         ty::Param(_) => sig_from_bounds(cx, ty, cx.param_env.caller_bounds(), None),
    |                         ---------------         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Predicate<'_>`, found `Clause<'_>`
    |                         required by a bound introduced by this call
    |
note: required by a bound in `sig_from_bounds`
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
    |
698 | fn sig_from_bounds<'tcx>(
...
701 |     predicates: impl IntoIterator<Item = Predicate<'tcx>>,
    |                                   ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `sig_from_bounds`


    Checking diff v0.1.13
    Checking bytes v1.0.1
    Checking concolor-query v0.3.3
error[E0308]: mismatched types
    --> src/tools/clippy/clippy_utils/src/lib.rs:1359:83
     |
1359 | ...                   ty_is_fn_once_param(cx.tcx, ty.skip_binder(), predicates).then_some(())
     |                       -------------------                           ^^^^^^^^^^ expected `&[Predicate<'_>]`, found `&List<Clause<'_>>`
     |                       arguments to this function are incorrect
     |
     |
     = note: expected reference `&[rustc_middle::ty::Predicate<'_>]`
                found reference `&rustc_middle::ty::List<rustc_middle::ty::Clause<'_>>`
    --> src/tools/clippy/clippy_utils/src/ty.rs:940:8
     |
     |
940  | pub fn ty_is_fn_once_param<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, predicates: &'tcx [Predicate<'_>]) -> bool {

    Checking anstyle-wincon v0.2.0
error[E0308]: mismatched types
    --> src/tools/clippy/clippy_utils/src/lib.rs:1368:65
    --> src/tools/clippy/clippy_utils/src/lib.rs:1368:65
     |
1368 | ...                   ty_is_fn_once_param(cx.tcx, ty, cx.tcx.param_env(id).caller_bounds()).then_some(())
     |                       -------------------             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[Predicate<'_>]`, found `&List<Clause<'_>>`
     |                       arguments to this function are incorrect
     |
     |
     = note: expected reference `&[rustc_middle::ty::Predicate<'_>]`
                found reference `&rustc_middle::ty::List<rustc_middle::ty::Clause<'_>>`
    --> src/tools/clippy/clippy_utils/src/ty.rs:940:8
     |
     |
940  | pub fn ty_is_fn_once_param<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, predicates: &'tcx [Predicate<'_>]) -> bool {

    Checking tempfile v3.5.0
    Checking filetime v0.2.20
Some errors have detailed explanations: E0271, E0308.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking unicode-script v0.5.5
   Compiling syn v1.0.102
    Checking quine-mc_cluskey v0.2.4
    Checking getopts v0.2.21
error[E0271]: expected `Iter<'_, (Clause<'_>, Span)>` to be an iterator that yields `&(Predicate<'_>, Span)`, but it yields `&(Clause<'_>, Span)`
    |
    |
566 | pub fn all_predicates_of(tcx: TyCtxt<'_>, id: DefId) -> impl Iterator<Item = &(Predicate<'_>, Span)> {
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&(Clause<'_>, Span)`, found `&(Predicate<'_>, Span)`
    |
    = note: expected reference `&(rustc_middle::ty::Clause<'_>, Span)`
               found reference `&(rustc_middle::ty::Predicate<'_>, Span)`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:29:17
   |
   |
28 |               match predicate.kind().skip_binder() {
   |                     ------------------------------ this expression has type `ClauseKind<'_>`
29 | /                 ty::PredicateKind::Clause(
30 | |                     ty::ClauseKind::RegionOutlives(_)
31 | |                     | ty::ClauseKind::TypeOutlives(_)
32 | |                     | ty::ClauseKind::Projection(_)
33 | |                     | ty::ClauseKind::Trait(..)
34 | |                     | ty::ClauseKind::ConstArgHasType(..),
35 | |                 )
   | |_________________^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:36:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
36 |                 | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:37:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
37 |                 | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:38:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
38 |                 | ty::PredicateKind::ConstEquate(..)
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:39:19
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
39 |                 | ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:40:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
40 |                 ty::PredicateKind::AliasRelate(..) => panic!("alias relate predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:41:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
41 |                 ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:42:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
42 |                 ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:43:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
43 |                 ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:44:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
44 |                 ty::PredicateKind::Coerce(_) => panic!("coerce predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
error[E0308]: mismatched types
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:45:17
   |
   |
28 |             match predicate.kind().skip_binder() {
   |                   ------------------------------ this expression has type `ClauseKind<'_>`
...
45 |                 ty::PredicateKind::Ambiguous => panic!("ambiguous predicate on function: {predicate:#?}"),
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ClauseKind<'_>`, found `PredicateKind<'_>`
    Checking idna v0.2.0
   Compiling tokio v1.28.2
   Compiling quote v1.0.26
    Checking strsim v0.10.0
    Checking strsim v0.10.0
    Checking clap_lex v0.4.1
error[E0271]: type mismatch resolving `<&List<Clause<'_>> as IntoIterator>::Item == Predicate<'_>`
    |
    |
691 |             _ => sig_for_projection(cx, proj).or_else(|| sig_from_bounds(cx, ty, cx.param_env.caller_bounds(), None)),
    |                                                          ---------------         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Predicate<'_>`, found `Clause<'_>`
    |                                                          required by a bound introduced by this call
    |
note: required by a bound in `sig_from_bounds`
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
    |
698 | fn sig_from_bounds<'tcx>(
...
701 |     predicates: impl IntoIterator<Item = Predicate<'tcx>>,
    |                                   ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `sig_from_bounds`


error[E0271]: type mismatch resolving `<&List<Clause<'_>> as IntoIterator>::Item == Predicate<'_>`
    |
    |
693 |         ty::Param(_) => sig_from_bounds(cx, ty, cx.param_env.caller_bounds(), None),
    |                         ---------------         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Predicate<'_>`, found `Clause<'_>`
    |                         required by a bound introduced by this call
    |
note: required by a bound in `sig_from_bounds`
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
   --> src/tools/clippy/clippy_utils/src/ty.rs:701:35
    |
698 | fn sig_from_bounds<'tcx>(
...
701 |     predicates: impl IntoIterator<Item = Predicate<'tcx>>,
    |                                   ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `sig_from_bounds`


   Compiling heck v0.4.0
   Compiling compiletest_rs v0.10.0
    Checking diff v0.1.13
error[E0308]: mismatched types
    --> src/tools/clippy/clippy_utils/src/lib.rs:1359:83
     |
1359 | ...                   ty_is_fn_once_param(cx.tcx, ty.skip_binder(), predicates).then_some(())
     |                       -------------------                           ^^^^^^^^^^ expected `&[Predicate<'_>]`, found `&List<Clause<'_>>`
     |                       arguments to this function are incorrect
     |
     |
     = note: expected reference `&[rustc_middle::ty::Predicate<'_>]`
                found reference `&rustc_middle::ty::List<rustc_middle::ty::Clause<'_>>`
    --> src/tools/clippy/clippy_utils/src/ty.rs:940:8
     |
     |
940  | pub fn ty_is_fn_once_param<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, predicates: &'tcx [Predicate<'_>]) -> bool {

error[E0308]: mismatched types
    --> src/tools/clippy/clippy_utils/src/lib.rs:1368:65
     |
     |
1368 | ...                   ty_is_fn_once_param(cx.tcx, ty, cx.tcx.param_env(id).caller_bounds()).then_some(())
     |                       -------------------             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[Predicate<'_>]`, found `&List<Clause<'_>>`
     |                       arguments to this function are incorrect
     |
     |
     = note: expected reference `&[rustc_middle::ty::Predicate<'_>]`
                found reference `&rustc_middle::ty::List<rustc_middle::ty::Clause<'_>>`
    --> src/tools/clippy/clippy_utils/src/ty.rs:940:8
     |
     |
940  | pub fn ty_is_fn_once_param<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, predicates: &'tcx [Predicate<'_>]) -> bool {

    Checking bytes v1.0.1
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.

@bors
Copy link
Contributor

bors commented Jun 19, 2023

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

compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jun 20, 2023
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`

Does two basic things before I put up a more delicate set of PRs (along the lines of rust-lang#112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`).

1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`.
2. Add a new `Clause` type which is parallel to `Predicate`.
    * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸

The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...

r? `@lcnr` or `@oli-obk`

[^1]: rust-lang#112714 (comment)
Nilstrieb added a commit to Nilstrieb/rust that referenced this pull request Jun 21, 2023
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`

Does two basic things before I put up a more delicate set of PRs (along the lines of rust-lang#112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`).

1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`.
2. Add a new `Clause` type which is parallel to `Predicate`.
    * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸

The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...

r? ``@lcnr`` or ``@oli-obk``

[^1]: rust-lang#112714 (comment)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Jun 29, 2023
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`

Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`).

1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`.
2. Add a new `Clause` type which is parallel to `Predicate`.
    * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸

The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...

r? ``@lcnr`` or ``@oli-obk``

[^1]: rust-lang/rust#112714 (comment)
@compiler-errors compiler-errors deleted the clause branch August 11, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants