Adjust and slightly generalize operator error suggestion#101424
Merged
bors merged 5 commits intorust-lang:masterfrom Sep 8, 2022
Merged
Adjust and slightly generalize operator error suggestion#101424bors merged 5 commits intorust-lang:masterfrom
bors merged 5 commits intorust-lang:masterfrom
Conversation
Contributor
|
r? @TaKO8Ki (rust-highfive has picked a reviewer for you, use r? to override) |
compiler-errors
commented
Sep 4, 2022
311410d to
dadef26
Compare
compiler-errors
commented
Sep 4, 2022
Contributor
Author
There was a problem hiding this comment.
Peeling the type here is actually wrong -- when we have /* &&i32 */ + /* i32 */ and we deref the LHS, we are adding &i32 and i32, not i32 and i32.
TaKO8Ki
reviewed
Sep 6, 2022
Member
TaKO8Ki
left a comment
There was a problem hiding this comment.
Looks good to me. r=me after a nit is addressed or not.
Member
There was a problem hiding this comment.
nit: Option::and_then can simplify this.
Suggested change
| let output_def_id = trait_def_id.map_or(None, |def_id| { | |
| let output_def_id = trait_def_id.and_then(|def_id| { |
Contributor
Author
There was a problem hiding this comment.
Do you mean is_some_and?
edit: I was looking at the wrong map_or in that file... 🤦 you're right!
Collaborator
|
☔ The latest upstream changes (presumably #101432) made this pull request unmergeable. Please resolve the merge conflicts. |
dadef26 to
48281b0
Compare
Contributor
Author
|
@bors r=TaKO8Ki |
Collaborator
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Sep 8, 2022
… r=TaKO8Ki
Adjust and slightly generalize operator error suggestion
(in no particular order)
* Stop passing around a whole extra `ProjectionPredicate`
* Add spaces around `=` in `Trait<..., Output = Ty>` suggestion
* Some code clean-ups, including
* add `lang_item_for_op` to turn a `Op` into a `DefId`
* avoid `SourceMap` because we don't really need to render an expr
* Remove `TypeParamVisitor` in favor of just checking `ty.has_param_types_or_consts` -- this acts a bit differently, but shouldn't cause erroneous suggestions (actually might generalize them a bit)
* We now suggest `Output = Ty` in the `where` clause suggestion when we fail to add `Struct<T>` and `T`.
I can split this out into more PRs if needed, but they're all just miscellaneous generalizations, changes, and nitpicks I saw when messing with this operator code.
This was referenced Sep 8, 2022
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 8, 2022
Rollup of 7 pull requests Successful merges: - rust-lang#98933 (Opaque types' generic params do not imply anything about their hidden type's lifetimes) - rust-lang#101041 (translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Pt. 2) - rust-lang#101424 (Adjust and slightly generalize operator error suggestion) - rust-lang#101496 (Allow lower_lifetime_binder receive a closure) - rust-lang#101501 (Allow lint passes to be bound by `TyCtxt`) - rust-lang#101515 (Recover from typo where == is used in place of =) - rust-lang#101545 (Remove unnecessary `PartialOrd` and `Ord`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Oct 6, 2022
Rollup of 7 pull requests Successful merges: - rust-lang#98933 (Opaque types' generic params do not imply anything about their hidden type's lifetimes) - rust-lang#101041 (translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Pt. 2) - rust-lang#101424 (Adjust and slightly generalize operator error suggestion) - rust-lang#101496 (Allow lower_lifetime_binder receive a closure) - rust-lang#101501 (Allow lint passes to be bound by `TyCtxt`) - rust-lang#101515 (Recover from typo where == is used in place of =) - rust-lang#101545 (Remove unnecessary `PartialOrd` and `Ord`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(in no particular order)
ProjectionPredicate=inTrait<..., Output = Ty>suggestionlang_item_for_opto turn aOpinto aDefIdSourceMapbecause we don't really need to render an exprTypeParamVisitorin favor of just checkingty.has_param_types_or_consts-- this acts a bit differently, but shouldn't cause erroneous suggestions (actually might generalize them a bit)Output = Tyin thewhereclause suggestion when we fail to addStruct<T>andT.I can split this out into more PRs if needed, but they're all just miscellaneous generalizations, changes, and nitpicks I saw when messing with this operator code.