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

Use trybuild and move to proc-macro-error #60

Merged
merged 4 commits into from
Jan 12, 2020
Merged

Use trybuild and move to proc-macro-error #60

merged 4 commits into from
Jan 12, 2020

Conversation

CreepySkeleton
Copy link
Contributor

@CreepySkeleton CreepySkeleton commented Nov 7, 2019

This PR is on top of #59

Deleted files

  • diag.rs: no need for it anymore

    I also got rid of emit_with_attr_note, in my opinion it's just useless noise. If people have made use of #[auto_impl] attribute they already know where it was requested, user wants to know where the error is.

  • spanned.rs: no need either. To be honest, your implementation was no better than the one from proc_macro2 (if not worse). Anyway, you don't need proc_macro::Span anymore - proc-macro-error works with proc-macro2::Span.

I also added helpful notes where applicable, made some refactoring here and there (not much), fixed some typos.

I didn't touch some panic! invocations - they look like bug catching and this is just the job of panic. Some other panics were replaced with abort!.

Btw, nightly feature from proc_macro2 doesn't really do anything, I suggest to remove it.

Also, I would like to propose not to use Trybuid::compile_pass - it literally executes a separate cargo build run for every each file which is slow.

src/attr.rs Outdated Show resolved Hide resolved
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Thanks for your PR!

I will review this in detail later. I just quickly looked over it now. A request up front: could you make multiple commits out of that? For example, three:

  • Refactoring/small fixes unrelated to the main goal of this PR
  • The main implementation of this PR (use proc-macro-error)
  • Adjusting the UI tests

But you can also create more commits if you think it makes sense.

And in general, please only include style changes that are justified by the official Rust styleguide (i.e. what rustfmt does).

examples/error_messages.rs Outdated Show resolved Hide resolved
examples/refs.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/proxy.rs Outdated Show resolved Hide resolved
src/proxy.rs Outdated
note = NOTE_TEXT
);

return Err(());
Copy link
Member

Choose a reason for hiding this comment

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

Please use the old extra-braces syntax: match _ { Ident(ident) => { match .... I doubt this change was made by rustfmt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rustfmt is the one to blame here. I would argue that the current approach is somewhat cleaner though, what do you think?

@CreepySkeleton
Copy link
Contributor Author

And in general, please only include style changes that are justified by the official Rust styleguide (i.e. what rustfmt does).

I didn't do any style adjustments except that one match () => if, the blame is on rustfmt entirely :)

@CreepySkeleton
Copy link
Contributor Author

Here's an attempt to integrate rustfmt and make it match your code style. Unfortunately, those options are nightly, but who cares?

Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Awesome work, thank you! And sorry for being so picky, especially regarding style :P

I'm pretty busy ATM, so I only managed to review ae0ce6c, but this is the "main" one.

As a general thing: in many places (especially gen and proxy) you write emit_error! where we immediately return Err(()) afterwards. In these cases it would make sense to just abort! instead, right? I just quickly checked and it seems like the Err value is never really used. So I think it might be possible to replace all emit_error!s in gen and proxy with abort and also make all of those functions return T instead of Result<T,()> (for whatever T...). I think that should simplify things even further.

Thanks again for your work. In this commit it sure looks worth it to switch to your crate!

src/attr.rs Outdated Show resolved Hide resolved
src/attr.rs Outdated Show resolved Hide resolved
src/attr.rs Outdated Show resolved Hide resolved
src/gen.rs Outdated Show resolved Hide resolved
src/gen.rs Outdated Show resolved Hide resolved
src/gen.rs Outdated Show resolved Hide resolved
src/gen.rs Outdated Show resolved Hide resolved
src/gen.rs Outdated Show resolved Hide resolved
@CreepySkeleton
Copy link
Contributor Author

Of course it would be fine to use abort! only but in most cases it's quite useful to keep working, looking for other errors to report. I tweaked the code in a way that functions return as late as possible, take a look.

@CreepySkeleton
Copy link
Contributor Author

knock knock @LukasKalbertodt

@LukasKalbertodt
Copy link
Member

@CreepySkeleton Please excuse the delay, I have plenty of other stuff to do :(
But I have not forgotten this and planned on completely reviewing this PR this week still!

Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Okay, I finally managed to get this reviewed. Sorry again for the delay.

Overall I'm pretty happy with this PR. I think it does indeed improve the code base and makes many parts of the code more readable. Not to mention that this PR removes 100 lines more than it adds, which is always a plus. I left a few inline comments still, that I'd like to see fixed.

One additional thing: could you please remove the two last commits (the ones about rustfmt) from this PR? I don't mind adding rustfmt, but I think it's pretty separate from the main concern of this PR, so we should keep PRs kind of atomic.

Oh, and thanks a bunch for separating all changes into multiple commits. That really made it way easier to review!

With my comments fixed, I think this can be merged.

src/gen.rs Show resolved Hide resolved
src/gen.rs Show resolved Hide resolved
src/attr.rs Outdated Show resolved Hide resolved
src/proxy.rs Outdated Show resolved Hide resolved
src/proxy.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
tests/compile-fail/attr_on_enum.stderr Show resolved Hide resolved
@CreepySkeleton
Copy link
Contributor Author

Ugh, I must admit I completely forgot about this PR, sorry about it @LukasKalbertodt :(
In my defense, nobody tried to ping me anyway.

I fixed all of the suggestions above If you sill have an appetite for this changes.

@LukasKalbertodt
Copy link
Member

No problem for the delay ;-)
Thanks for fixing everything! Great work with this PR.

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.

2 participants