-
Notifications
You must be signed in to change notification settings - Fork 13k
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 keep {Closure,Generator}Substs synthetics in an Instance. #74341
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,13 +177,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { | |
|
||
Node::Field(field) => icx.to_ty(&field.ty), | ||
|
||
Node::Expr(&Expr { kind: ExprKind::Closure(.., gen), .. }) => { | ||
let substs = InternalSubsts::identity_for_item(tcx, def_id); | ||
if let Some(movability) = gen { | ||
tcx.mk_generator(def_id, substs, movability) | ||
} else { | ||
tcx.mk_closure(def_id, substs) | ||
} | ||
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => { | ||
tcx.typeck_tables_of(def_id.expect_local()).node_type(hir_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels wrong to me. We basically undid a move much like this for generators, though partly it was to avoid those type error problems you were referring to with your other change. But also it is just surprising to me to have Anyway, what is the exact motivation here? It's confusing to me :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok, I see, the point is that you want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do land this, I feel like we need some kind of comment..somewhere...that explains this rather subtle point. I guess it would be best to document it on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Me neither, I think I'd prefer if we could implement e.g.
All the wins are incremental, so it probably only makes sense if a closure changes its capture set/types, although that would still imply codegen is needed? Or maybe non-generic closures are involved, which would now result in an |
||
} | ||
|
||
Node::AnonConst(_) => { | ||
|
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 removed this line to make 29 UI tests pass - their only failure mode was missing some of the errors.
I believe what's happening is that this would now trigger type-checking the body of the closure, before bodies are normally type-checked, and so it trips on an "abort if any errors" check.
Can we start removing those "checkpoints" that turn regular errors into fatal ones, given how on-demand some of the various checks are nowadays? cc @estebank
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 there are only a handful of
FatalError.raise()
s left, and the ones that do remain do so because they'd require a much larger refactor to get rid of them.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.
If they're because of having to return a value, I suspect using
Result<T, ErrorReported>
could work well.(But I meant "abort if there were any errors" "checkpoints", which we can just remove)