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

Include type of missing trait methods in error #37370

Merged
merged 1 commit into from
Nov 9, 2016

Conversation

estebank
Copy link
Contributor

Provide either a span pointing to the original definition of missing
trait items, or a message with the inferred definitions.

Fixes #24626. Follow up to PR #36371.

If PR #37369 lands, missing trait items that present a multiline span will be able to show the entirety of the item definition on the error itself, instead of just the first line.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@estebank estebank force-pushed the signature-2-empire-strikes-back branch 2 times, most recently from 22479b0 to 77d6892 Compare October 24, 2016 02:50
@nikomatsakis
Copy link
Contributor

@emilio would you mind converting the affected tests to ui tests? or at least some representative set? It's a bit hard for me to visualize the formatting currently =)

@estebank
Copy link
Contributor Author

@nikomatsakis will do. Should I duplicate the tests, adding UI tests that match the current ones, or just replace the current tests with the new ones?

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Oct 24, 2016

@estebank any tests you move to ui tests can be removed from compile-fail

@estebank estebank force-pushed the signature-2-empire-strikes-back branch 3 times, most recently from 395bed6 to 02209f9 Compare October 26, 2016 19:54
@estebank
Copy link
Contributor Author

@nikomatsakis I've moved the tests from compile-fail to ui.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Looks good @estebank -- think you could add a few more tests (see comments)?

@@ -0,0 +1,56 @@
error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>`
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this PR, I think, but this text "<FooConstForMethod as Foo>" seems pretty funny to me; I expect to see just Foo... is there an open issue on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After going through the open tickets, I don't think there's one for this, so I opened one.

30 | impl Deref for Thing {
| ^ missing `Target` in implementation
|
= note: `Target` from trait: `type Target;`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you create a test case where the item from the other trait is a fn with a non-trivial signature?

Probably worth testing the constant case too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added test/run-make/missing-items covering all three cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait...why did you make it a run-make test? (Those are generally frowned upon, since they don't fit the usual scheme.) But in particular, this all seems like a good candidate for a ui test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Duly noted, I didn't know they were frowned upon.

In order for this codepath to be executed the trait shouldn't have a span available, which as far as I know only happens when compiling against an extern crate. I hadn't noticed that test/ui/cross-crate-macro-backtrace does exactly that. I'll change this to a ui test.

Provide either a span pointing to the original definition of missing
trait items, or a message with the inferred definitions.
@estebank estebank force-pushed the signature-2-empire-strikes-back branch from 02209f9 to 40c2c0f Compare November 5, 2016 20:26
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 8, 2016

📌 Commit 40c2c0f has been approved by nikomatsakis

@nikomatsakis
Copy link
Contributor

Nice work @estebank =)

eddyb added a commit to eddyb/rust that referenced this pull request Nov 9, 2016
…-back, r=nikomatsakis

Include type of missing trait methods in error

Provide either a span pointing to the original definition of missing
trait items, or a message with the inferred definitions.

Fixes rust-lang#24626. Follow up to PR rust-lang#36371.

If PR rust-lang#37369 lands, missing trait items that present a multiline span will be able to show the entirety of the item definition on the error itself, instead of just the first line.
bors added a commit that referenced this pull request Nov 9, 2016
Rollup of 15 pull requests

- Successful merges: #36868, #37134, #37229, #37250, #37370, #37428, #37432, #37472, #37524, #37614, #37622, #37627, #37636, #37644, #37654
- Failed merges: #37463, #37542, #37645
@bors bors merged commit 40c2c0f into rust-lang:master Nov 9, 2016
@alexcrichton
Copy link
Member

Hm looks like the run-make test here is failing on nightly, preventing nightlies.

Still investigating why.

@alexcrichton
Copy link
Member

cc @brson

@pmarcelll
Copy link
Contributor

pmarcelll commented Nov 12, 2016

I tried to reproduce what the Makefile does,

$ rustc m1.rs -C prefer-dynamic
$ rustc m2.rs

gives the folloving error:

error[E0463]: can't find crate for `m1`

So I thought it's a linking error. And indeed, rustc m2.rs -L ./ gives the right error message.

EDIT: Or the stuff in tools.mk should take care of this somehow?
EDIT2: The real error:

$ make
rustc m1.rs -C prefer-dynamic
rustc m2.rs -L ./ 2>&1 | grep "error\[E0046\]: not all trait items implemented, missing: .*"
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
rustc m2.rs -L ./ 2>&1 | grep "  --> m2.rs:18:1"
  --> m2.rs:18:1
rustc m2.rs -L ./ 2>&1 | grep "   | ^ missing .CONSTANT., .Type., .method. in implementation"
   | ^ missing `CONSTANT`, `Type`, `method` in implementation
rustc m2.rs -L ./ 2>&1 | grep "   = note: .CONSTANT. from trait: .const CONSTANT: u32;."
make: *** [Makefile:8: all] Error 1

The note is missing.

@estebank estebank deleted the signature-2-empire-strikes-back branch November 9, 2023 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants