-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Don't pass lint back out of lint decorator #118727
Conversation
|
Some changes occurred in src/tools/cargo cc @ehuss Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
633ffad
to
432d52d
Compare
Sorry, fixed submodules. |
This comment has been minimized.
This comment has been minimized.
432d52d
to
0d28b09
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
decorate: impl for<'a, 'b> FnOnce( | ||
&'b mut DiagnosticBuilder<'a, ()>, | ||
) -> &'b mut DiagnosticBuilder<'a, ()>, | ||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a comment at the top of this method that points to a long comment on struct_lint_level
that explains why the return value is present, which @WaffleLapkin wrote, so I will forward the review to them.
Though I will say that I wonder if the comment is correct, because as written the change seems like an improvement, shortening the code a little. And any function of the form f(..., &mut T) -> &mut T
is really weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, well, I guess I missed that. I'm not necessarily convinced by either of the arguments, but yeah, I'll leave it up to waffle to weigh in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I will say that I wonder if the comment is correct, because as written the change seems like an improvement, shortening the code a little. And any function of the form
f(..., &mut T) -> &mut T
is really weird.
The shortening comment refers to is the |lint| { lint.span_note(""); }
(which auto-formats to 3 lines) vs |lint| lint.span_note("")
(auto-formats to one). I think I overestimated how common this is.
I don't personally find &mut T -> &mut T
a weird interface though, it's just the usual builder function (just like span_note
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&mut self -> &mut Self
is one of the typical builder patterns, right? So this is similar but not quite the same. Not as weird as I first thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
☔ The latest upstream changes (presumably #118900) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do kinda still agree with my comment about accidental use of .emit()
, but I'm not sure that this bug is common enough for us to have an interface like that.
I'm ok with this change, it looks like it slightly improves things.
(please update my comments on struct_lint_level
and lookup_with_diagnostics
(maybe other places?) so that they mention you don't need .emit()
but don't mention the weird signature)
0d28b09
to
252d99a
Compare
@bors r=WaffleLapkin |
…kingjubilee Rollup of 5 pull requests Successful merges: - rust-lang#118396 (Collect lang items from AST, get rid of `GenericBound::LangItemTrait`) - rust-lang#118727 (Don't pass lint back out of lint decorator) - rust-lang#118956 (Make CStr documentation consistent ("nul" instead of "null")) - rust-lang#118981 (Remove an unneeded allocation) - rust-lang#118998 (Link to is_benchmark from the Ipv6Addr::is_global documentation) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#118727 - compiler-errors:lint-decorate, r=WaffleLapkin Don't pass lint back out of lint decorator Change the decorator function in the signature of the `emit_lint`/`span_lint`/etc family of methods from `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` to `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)`. I consider it easier to read this way, especially when there's control flow involved. r? nnethercote though feel free to reassign
…r=WaffleLapkin Simplify lint decorator derive too See last commit, since this is stacked on top of rust-lang#118727. r? WaffleLapkin
Rollup merge of rust-lang#118989 - compiler-errors:lint-decorator-2, r=WaffleLapkin Simplify lint decorator derive too See last commit, since this is stacked on top of rust-lang#118727. r? WaffleLapkin
…affleLapkin Don't pass lint back out of lint decorator Change the decorator function in the signature of the `emit_lint`/`span_lint`/etc family of methods from `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` to `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)`. I consider it easier to read this way, especially when there's control flow involved. r? nnethercote though feel free to reassign
Change the decorator function in the signature of the
emit_lint
/span_lint
/etc family of methods fromimpl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
toimpl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)
. I consider it easier to read this way, especially when there's control flow involved.r? nnethercote though feel free to reassign