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

Avoid describing a method as 'not found' when bounds are unsatisfied #81149

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

Aaron1011
Copy link
Member

Fixes #76267

When there is a single applicable method candidate, but its trait bounds
are not satisfied, we avoid saying that the method is "not found".
Insted, we update the error message to directly mention which bounds are
not satisfied, rather than mentioning them in a note.

@rust-highfive
Copy link
Collaborator

r? @ecstatic-morse

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 18, 2021
@Aaron1011
Copy link
Member Author

This makes the primary error message multi-line. I'm open to any suggestions for a better way of showing this information.

@Aaron1011
Copy link
Member Author

r? @estebank

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.

What do you think of the proposed output?

Comment on lines 1 to 10
error[E0599]: the method `f` exists for type `u32`, but the following trait bounds were not satisfied:
`<u32 as X<'b>>::U: Clone`
which is required by `u32: X`
--> $DIR/hr-associated-type-bound-2.rs:19:10
|
LL | 1u32.f("abc");
| ^ method not found in `u32`
|
= note: the method `f` exists but the following trait bounds were not satisfied:
`<u32 as X<'b>>::U: Clone`
which is required by `u32: X`

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think if we instead output:

error[E0599]: the method `f` exists for type `u32`, but its trait bounds were not satisfied
  --> $DIR/hr-associated-type-bound-2.rs:19:10
   |
LL |     1u32.f("abc");
   |          ^ method not found in `u32` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `<u32 as X<'b>>::U: Clone`
           which is required by `u32: X`

Copy link
Member Author

Choose a reason for hiding this comment

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

That looks good, except for the usage of 'not found' in "method not found in u32 due to unsatisfied trait bounds". I think it should say something like "method cannot be called on u32 due to unsatisfied trait bounds".

@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)
configure: rust.channel         := nightly
configure: rust.debug-assertions := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 

@Aaron1011 Aaron1011 force-pushed the feature/better-no-method-found-err branch 3 times, most recently from fe85c83 to bb4f70c Compare January 18, 2021 03:08
@Aaron1011
Copy link
Member Author

@estebank I've updated the error message.

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 27, 2021

📌 Commit bb4f70c has been approved by estebank

@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 27, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jan 27, 2021
…found-err, r=estebank

Avoid describing a method as 'not found' when bounds are unsatisfied

Fixes rust-lang#76267

When there is a single applicable method candidate, but its trait bounds
are not satisfied, we avoid saying that the method is "not found".
Insted, we update the error message to directly mention which bounds are
not satisfied, rather than mentioning them in a note.
@Dylan-DPC-zz
Copy link

failed in rollup

@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 Jan 27, 2021
Fixes rust-lang#76267

When there is a single applicable method candidate, but its trait bounds
are not satisfied, we avoid saying that the method is "not found".
Insted, we update the error message to directly mention which bounds are
not satisfied, rather than mentioning them in a note.
@Aaron1011 Aaron1011 force-pushed the feature/better-no-method-found-err branch from bb4f70c to dea8a16 Compare January 27, 2021 05:00
@Aaron1011
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jan 27, 2021

📌 Commit dea8a16 has been approved by estebank

@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 Jan 27, 2021
@jonas-schievink
Copy link
Contributor

@bors r- failed in #81449 (comment)

@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 Jan 27, 2021
@Aaron1011
Copy link
Member Author

@bors rollup=never

@Aaron1011
Copy link
Member Author

Failed due to #81351 adding a new error to a test. I'll rebase this PR once that PR lands in the current rollup.

@Aaron1011
Copy link
Member Author

The rollup for #81351 failed, so let's try to get this PR in ahead of it.

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jan 28, 2021

📌 Commit dea8a16 has been approved by estebank

@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 Jan 28, 2021
@bors
Copy link
Contributor

bors commented Jan 28, 2021

⌛ Testing commit dea8a16 with merge e46baecedb47431e475b87aadf0bc1ffed28a0c5...

@bors
Copy link
Contributor

bors commented Jan 28, 2021

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 28, 2021
@Aaron1011
Copy link
Member Author

@bors retry

@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 28, 2021
@bors
Copy link
Contributor

bors commented Jan 28, 2021

⌛ Testing commit dea8a16 with merge 643a79a...

@bors
Copy link
Contributor

bors commented Jan 28, 2021

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 643a79a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 28, 2021
@bors bors merged commit 643a79a into rust-lang:master Jan 28, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 28, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid 'not found' terminology when there is only one potentially applicable method.
9 participants