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

Add E0790 as more specific variant of E0283 #98028

Merged
merged 2 commits into from
Jul 19, 2022
Merged

Conversation

aticu
Copy link
Contributor

@aticu aticu commented Jun 12, 2022

Fixes #81701

I think this should be good to go, there are only two things where I am somewhat unsure:

  • Is there a better way to get the fully-qualified path for the suggestion? I tried self.tcx.def_path_str, but that didn't seem to always give a correct path for the context.
  • Should all this be extracted into it's own method or is it fine where it is?

r? @estebank

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 12, 2022
@rust-highfive
Copy link
Collaborator

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 12, 2022
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 14, 2022

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

@bors
Copy link
Contributor

bors commented Jun 28, 2022

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

@rustbot
Copy link
Collaborator

rustbot commented Jul 2, 2022

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

The error explanation looks good to me. Let's wait for @estebank for the approval on the compiler change.

@bors
Copy link
Contributor

bors commented Jul 5, 2022

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

@bors
Copy link
Contributor

bors commented Jul 8, 2022

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

@aticu
Copy link
Contributor Author

aticu commented Jul 10, 2022

I've slightly changed the structure of the code now in hope to make the diff simpler, but nothing fundamentally changed in case you already started looking into this @estebank

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 18, 2022

📌 Commit 3bec67f has been approved by estebank

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 18, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 19, 2022
Add E0789 as more specific variant of E0283

Fixes rust-lang#81701

I think this should be good to go, there are only two things where I am somewhat unsure:
- Is there a better way to get the fully-qualified path for the suggestion? I tried `self.tcx.def_path_str`, but that didn't seem to always give a correct path for the context.
- Should all this be extracted into it's own method or is it fine where it is?

r? `@estebank`
@Dylan-DPC
Copy link
Member

failed in rollup ci

@Dylan-DPC
Copy link
Member

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 19, 2022
@aticu
Copy link
Contributor Author

aticu commented Jul 19, 2022

Rebased and changed the error code to E0790.

@aticu aticu changed the title Add E0789 as more specific variant of E0283 Add E0790 as more specific variant of E0283 Jul 19, 2022
@Dylan-DPC
Copy link
Member

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jul 19, 2022

📌 Commit 38ea235 has been approved by estebank

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 19, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 19, 2022
…askrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#98028 (Add E0790 as more specific variant of E0283)
 - rust-lang#99384 (use body's param-env when checking if type needs drop)
 - rust-lang#99401 (Avoid `Symbol` to `&str` conversions)
 - rust-lang#99419 (Stabilize `core::task::ready!`)
 - rust-lang#99435 (Revert "Stabilize $$ in Rust 1.63.0")
 - rust-lang#99438 (Improve suggestions for `NonZeroT` <- `T` coercion error)
 - rust-lang#99441 (Update mdbook)
 - rust-lang#99453 (:arrow_up: rust-analyzer)
 - rust-lang#99457 (use `par_for_each_in` in `par_body_owners` and `collect_crate_mono_items`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit bfefd58 into rust-lang:master Jul 19, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 19, 2022
if let (Some(body_id), Some(ty::subst::GenericArgKind::Type(_))) =
(body_id, subst.map(|subst| subst.unpack()))
{
struct FindExprBySpan<'hir> {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could introduce a new ObligationCauseCode that stores the hir id of the ExprKind::Path that this obligation comes from, so we wouldn't need to use this span-based search method.

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds like a good idea.

|
= note: cannot satisfy `_: Generator`
LL | let cont: u32 = <::Impl as Generator>::create();
Copy link
Member

Choose a reason for hiding this comment

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

This ::Impl path is kinda funky, is there a reason we used to_string_no_crate_verbose instead of just tcx.def_path_str?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't recall exactly anymore, but if I remember correctly I tried that and got paths as a result that didn't make sense in the context where they were suggested. But I could have made a mistake then. If you'd like I could try it again when I find the time and make a follow-up PR with that or at least find out why it didn't work in this case.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, either put up a follow up or I can also look into it.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I was involved in the development of this PR)
I think it was along the lines of it returning Impl instead of the context-sensitive value inner::Impl in the case of nested modules.

@compiler-errors
Copy link
Member

@aticu, does this fix address #98938 as well?

@aticu
Copy link
Contributor Author

aticu commented Jul 19, 2022

@compiler-errors Yes, this does fix #98938 as well, I just double checked. The resulting error message in that case is

error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:6:5
  |
2 |     fn bar() {}
  |     ----------- `Foo::bar` defined here
...
6 |     Foo::bar();
  |     ^^^^^^^^ cannot call associated function of trait

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E0283 could be better for calls to associated functions on the trait itself