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

Consider return type when giving various method suggestions #106607

Merged

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jan 8, 2023

  1. Fix a bug in method probe where we weren't normalizing xform_ret_ty for non-impl method candidates. This shouldn't affect happy-path code, since we only use xform_ret_ty when probing methods for diagnostics (I think).
  2. Pass the return type expectation down to lookup_probe/probe_for_name usages in diagnostics. Added a few UI tests to gate against bad suggestions.
  3. Make a FnCtxt::lookup_probe_for_diagnostic which properly passes down IsSuggestion(true). Should help suppress other weird notes in some corner cases.

@rustbot
Copy link
Collaborator

rustbot commented Jan 8, 2023

r? @oli-obk

(rustbot has picked a reviewer for you, use r? to override)

@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@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. labels Jan 8, 2023
@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 Jan 8, 2023
@bors
Copy link
Contributor

bors commented Jan 8, 2023

⌛ Trying commit 1bac9237061cb0a72a3b28afb1a719f548c0bc96 with merge 1d2a326a511b803db2092b2da40e17f0608e3975...

@bors
Copy link
Contributor

bors commented Jan 9, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Jan 9, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1d2a326a511b803db2092b2da40e17f0608e3975): comparison URL.

Overall result: ❌ regressions - 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.4% [0.4%, 0.5%] 2
Regressions ❌
(secondary)
2.0% [0.7%, 4.4%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) 0.4% [0.4%, 0.5%] 2

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

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.8% [0.9%, 3.9%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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

@estebank estebank left a comment

Choose a reason for hiding this comment

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

I'm really surprised by the perf results (although they are quite localized).

@compiler-errors
Copy link
Member Author

Tempted to believe that it's 1f92d5cca52572b08556620ba339365f485166bb causing the problem. Gonna try an experiment...

@compiler-errors
Copy link
Member Author

Interestingly, due to 1f92d5c, this code also now compiles successfully:

use std::ops::Deref;

trait Foo {
    fn foo(&self) -> &Self::Target where Self: Deref { &**self }
}

trait Bar {
    fn foo(&self) {}
}

fn test(i: impl Foo + Bar) {
    i.foo();
}

... becuase we now unconditionally normalize the xform_ret_ty, not only for impl candidates, but for trait and param method probe candidates as well.

@compiler-errors
Copy link
Member Author

This should revert that behavior, which is a bit disappointing IMO, but should help with the perf regression..?

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

bors commented Jan 9, 2023

⌛ Trying commit d85ba523ed961ce6da31dd1885a9766dc92ee8d2 with merge 9c64170fab1f1e34ba27072f0151d06e2bfe0131...

@bors

This comment was marked as off-topic.

@rust-timer

This comment was marked as off-topic.

1 similar comment
@rust-timer

This comment was marked as off-topic.

@bors
Copy link
Contributor

bors commented Jan 9, 2023

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

@bors
Copy link
Contributor

bors commented Jan 9, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9c64170fab1f1e34ba27072f0151d06e2bfe0131): 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
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.5%] 1
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)
- - 0
Improvements ✅
(primary)
-1.0% [-1.2%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.0% [-1.2%, -0.9%] 2

Cycles

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

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jan 9, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Jan 9, 2023

r=me after a rebase.

I recently dug around in this code and am very happy about the new _for_diagnostics function.

@compiler-errors compiler-errors force-pushed the be-more-accurate-abt-method-suggestions branch from d85ba52 to 4f15034 Compare January 9, 2023 17:48
@compiler-errors
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jan 9, 2023

📌 Commit 4f15034 has been approved by oli-obk

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

bors commented Jan 10, 2023

⌛ Testing commit 4f15034 with merge 0442fba...

@bors
Copy link
Contributor

bors commented Jan 10, 2023

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 0442fba to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Jan 10, 2023

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 0442fba to master...

@bors bors added merged-by-bors This PR was explicitly merged by bors. labels Jan 10, 2023
@bors bors merged commit 0442fba into rust-lang:master Jan 10, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 10, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0442fba): 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)

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.5% [2.5%, 2.5%] 1
Regressions ❌
(secondary)
1.5% [1.3%, 1.8%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.5% [2.5%, 2.5%] 1

Cycles

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

@compiler-errors compiler-errors deleted the be-more-accurate-abt-method-suggestions branch August 11, 2023 19:55
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants