Elaborate supertrait obligations when deducing closure signatures by compiler-errors · Pull Request #101834 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

compiler-errors

We elaborate the supertrait obligations of any registered predicates for a closure to see if we can infer a closure signature.

This is not as general of a fix as it could be, since we just elaborate supertrait bounds instead of doing a theoretical walk of all registered predicates that might cause us to deduce Fn trait information for a closure infer var. I don't even know how to come up with an example that fails here but would work with a more general system.

Fixes #23012
Also fixes the existing compile failure in #57611

r? @ghost for now until I do a perf run
cc @nikomatsakis since you commented on #23012 (comment)

@rustbot rustbot added the T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

label

Sep 15, 2022

@compiler-errors

@rust-timer

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@bors

⌛ Trying commit c3c07d99bee89f3577cb0d0a0e80acc162b5b850 with merge 4ca32f9e285911b5b8b447631fe27510e500238f...

@bors

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

@rust-timer

@rust-timer

Finished benchmarking commit (4ca32f9e285911b5b8b447631fe27510e500238f): comparison URL.

Overall result: no relevant changes - 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-review -S-waiting-on-perf -perf-regression

Instruction count

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

Max RSS (memory usage)

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

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.

mean1 range count2
Regressions ❌ (primary) - - 0
Regressions ❌ (secondary) - - 0
Improvements ✅ (primary) - - 0
Improvements ✅ (secondary) -2.1% [-2.1%, -2.1%] 1
All ❌✅ (primary) - - 0

Footnotes

  1. the arithmetic mean of the percent change
  2. number of relevant changes

@compiler-errors

r? types

I'd like an initial review here just for the code changes, then I'll need to open an FCP to see if the team is okay with the generalization of inference.

@rust-log-analyzer

This comment has been minimized.

@compiler-errors

@bors

@spastorino

@spastorino

@compiler-errors if you re-rolled it when it was assigned to @jackh726, I guess it's because we don't want to assign to Jack?.

@compiler-errors

@jackh726

agh sorry for no review here :(

I can try to give some comments this weekend

lcnr

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.

r=me on the impl, do you have a test impacted by e508304e8291c78bcae8784f4eaec5f81913d809? otherwise, please merge that commit with the previous one.

{
expected_kind = Some(
expected_kind
.map_or_else(| closure_kind,

Choose a reason for hiding this comment

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

| .map_or_else(|| closure_kind, | current| cmp::min(current, closure_kind)), | | --------------------------------------------------------------------- | ------------------------------------------- | | .map_or(closure_kind, |current| cmp::min(current, closure_kind)), | |

@rfcbot

🔔 This is now entering its final comment period, as per the review above. 🔔

@compiler-errors

@rfcbot

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@lcnr

@bors

📌 Commit bc3516d 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

Nov 3, 2022

@bors

@bors

@bors bors mentioned this pull request

Nov 4, 2022

@rust-timer

Finished benchmarking commit (6718ea1): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

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

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.2% [2.2%, 2.2%] 1
Improvements ✅ (primary) - - 0
Improvements ✅ (secondary) - - 0
All ❌✅ (primary) - - 0

This was referenced

Nov 6, 2022

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Nov 15, 2022

@matthiaskrgr

…e, r=oli-obk

Deduce closure signature from a type alias impl Trait's supertraits

r? @oli-obk

Basically pass the TAIT's bounds through the same method that we're using to deduce a signature from infer var closure bounds.

Does this need a new FCP? I see it as a logical extension of rust-lang#101834, but happy to rfcbot a new one if it does.

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request

Jan 27, 2023

@he32

Pkgsrc changes:

Upstream changes:

Version 1.67.0 (2023-01-26)

Language

Compiler

Added and removed targets:

Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These APIs are now stable in const contexts:

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Apr 8, 2023

@he32

Pkgsrc changes:

Upstream changes:

Version 1.68.2 (2023-03-28)

Version 1.68.1 (2023-03-23)

Version 1.68.0 (2023-03-09)

Language

Compiler

Libraries

Stabilized APIs

These APIs are now stable in const contexts:

Cargo

Misc

Compatibility Notes

nternal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

Version 1.67.0 (2023-01-26)

Language

Compiler

Added and removed targets:

Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These APIs are now stable in const contexts:

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

Labels

disposition-merge

This issue / PR is in PFCP or FCP with a disposition to merge it.

finished-final-comment-period

The final comment period is finished for this PR / Issue.

merged-by-bors

This PR was explicitly merged by bors.

needs-fcp

This change is insta-stable, so needs a completed FCP to proceed.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-types

Relevant to the types team, which will review and decide on the PR/issue.