-
Notifications
You must be signed in to change notification settings - Fork 13.5k
de-duplicate condition scoping logic between AST→HIR lowering and ScopeTree
construction
#143213
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -24,7 +24,6 @@ use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS; | |
use rustc_session::parse::feature_err; | ||
use rustc_span::edit_distance::find_best_match_for_name; | ||
use rustc_span::edition::Edition; | ||
use rustc_span::hygiene::DesugaringKind; | ||
use rustc_span::source_map::Spanned; | ||
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, kw, sym}; | ||
use rustc_trait_selection::infer::InferCtxtExt; | ||
|
@@ -902,16 +901,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
// then that's equivalent to there existing a LUB. | ||
let cause = self.pattern_cause(ti, span); | ||
if let Err(err) = self.demand_suptype_with_origin(&cause, expected, pat_ty) { | ||
err.emit_unless( | ||
ti.span | ||
.filter(|&s| { | ||
// In the case of `if`- and `while`-expressions we've already checked | ||
// that `scrutinee: bool`. We know that the pattern is `true`, | ||
// so an error here would be a duplicate and from the wrong POV. | ||
s.is_desugaring(DesugaringKind::CondTemporary) | ||
}) | ||
.is_some(), | ||
); | ||
err.emit(); | ||
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. Can this be moved into 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. There are other still other uses of |
||
} | ||
|
||
pat_ty | ||
|
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.
Do you have ideas how to remove
DropTemps
completely? In a follow-up pr ofc.Uh oh!
There was an error while loading. Please reload this page.
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.
In short, no. It could easily be removed from
for
loop desugaring, but afaict it can only easily be removed from async desugaring in Editions 2024 and newer.for pat in expr { .. }
, it's to keep theexpr
's temps from living into the enclosing expression (which means an even longer lifetime forfor
in block tail expressions in old Editions). The difference can be seen here. If we wanted to removeDropTemps
in a cross-Edition-compatible way without a breaking change, we could use a block with one statement and no tail expression, since for loops always return()
. That said, as long asDropTemps
still exists, it's probably the easiest way to get the current behavior.DropTemps
around for it, but I'm admittedly not too familiar with async desugaring.