-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Suggest impl Iterator
when possible for _
return type
#106172
Conversation
r? @spastorino (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
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.
r=me with nits or not
let ty_var = infcx.next_ty_var(origin); | ||
let projection = ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::Projection( | ||
ty::ProjectionPredicate { | ||
projection_ty: tcx.mk_alias_ty(iterator_item, tcx.mk_substs([ret_ty.into()].iter())), | ||
term: ty_var.into(), | ||
}, | ||
))); | ||
// Add `<ret_ty as Iterator>::Item = _` obligation. | ||
ocx.register_obligation(crate::traits::Obligation::misc( | ||
tcx, | ||
span, | ||
hir_id, | ||
tcx.param_env(def_id), | ||
projection, | ||
)); |
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 think you can just construct a projection type then pass it to ocx.normalize
instead, should make the code a lot simpler
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 guess I'll fix this in a follow-up PR
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 tried making that change, but I must have done it incorrectly and it didn't work. Let's land this and clean it up soon.
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.
Don't worry about it at all, I got it working on a local branch in any case. I do wonder what was wrong, though.
@bors r=compiler-errors |
📌 Commit 96f37aff124d77c6b0355157cbddb0f6d36a3371 has been approved by It is now in the queue for this repository. |
@bors r- tests needs bless 😸 |
This comment has been minimized.
This comment has been minimized.
96f37af
to
b400bde
Compare
@bors r=compiler-errors |
…piler-errors Suggest `impl Iterator` when possible for `_` return type Address rust-lang#106096.
…piler-errors Suggest `impl Iterator` when possible for `_` return type Address rust-lang#106096.
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#106028 (docs/test: add UI test and long-form error docs for `E0461`) - rust-lang#106172 (Suggest `impl Iterator` when possible for `_` return type) - rust-lang#106173 (Deduplicate `op` methods) - rust-lang#106176 (Recover `fn` keyword as `Fn` trait in bounds) - rust-lang#106194 (rustdoc: combine common sidebar background color CSS rules) - rust-lang#106199 (Silence knock-down errors on `[type error]` bindings) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…, r=estebank Suggest `impl Fn*` and `impl Future` in `-> _` return suggestions Follow-up to rust-lang#106172, only the last commit is relevant. Can rebase once that PR is landed for easier review. Suggests `impl Future` and `impl Fn{,Mut,Once}` in `-> _` return suggestions. r? `@estebank`
Address #106096.