Suggest impl Iterator when possible for _ return type#106172
Suggest impl Iterator when possible for _ return type#106172bors merged 3 commits intorust-lang:masterfrom
impl Iterator when possible for _ return type#106172Conversation
|
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
|
compiler-errors
left a comment
There was a problem hiding this comment.
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.
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.
I guess I'll fix this in a follow-up PR
There was a problem hiding this comment.
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.
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.