Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 68d860f

Browse files
committed
remove DesugaringKind::CondTemporary
1 parent fc557bc commit 68d860f

File tree

3 files changed

+1
-24
lines changed

3 files changed

+1
-24
lines changed

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5151
};
5252

5353
match span.desugaring_kind() {
54-
// If span arose from a desugaring of `if` or `while`, then it is the condition
55-
// itself, which diverges, that we are about to lint on. This gives suboptimal
56-
// diagnostics. Instead, stop here so that the `if`- or `while`-expression's
57-
// block is linted instead.
58-
Some(DesugaringKind::CondTemporary) => return,
59-
6054
// Don't lint if the result of an async block or async function is `!`.
6155
// This does not affect the unreachable lints *within* the body.
6256
Some(DesugaringKind::Async) => return,

‎compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
2424
use rustc_session::parse::feature_err;
2525
use rustc_span::edit_distance::find_best_match_for_name;
2626
use rustc_span::edition::Edition;
27-
use rustc_span::hygiene::DesugaringKind;
2827
use rustc_span::source_map::Spanned;
2928
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, kw, sym};
3029
use rustc_trait_selection::infer::InferCtxtExt;
@@ -902,16 +901,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
902901
// then that's equivalent to there existing a LUB.
903902
let cause = self.pattern_cause(ti, span);
904903
if let Err(err) = self.demand_suptype_with_origin(&cause, expected, pat_ty) {
905-
err.emit_unless(
906-
ti.span
907-
.filter(|&s| {
908-
// In the case of `if`- and `while`-expressions we've already checked
909-
// that `scrutinee: bool`. We know that the pattern is `true`,
910-
// so an error here would be a duplicate and from the wrong POV.
911-
s.is_desugaring(DesugaringKind::CondTemporary)
912-
})
913-
.is_some(),
914-
);
904+
err.emit();
915905
}
916906

917907
pat_ty

‎compiler/rustc_span/src/hygiene.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,11 +1191,6 @@ impl AstPass {
11911191
/// The kind of compiler desugaring.
11921192
#[derive(Clone, Copy, PartialEq, Debug, Encodable, Decodable, HashStable_Generic)]
11931193
pub enum DesugaringKind {
1194-
/// We desugar `if c { i } else { e }` to `match $ExprKind::Use(c) { true => i, _ => e }`.
1195-
/// However, we do not want to blame `c` for unreachability but rather say that `i`
1196-
/// is unreachable. This desugaring kind allows us to avoid blaming `c`.
1197-
/// This also applies to `while` loops.
1198-
CondTemporary,
11991194
QuestionMark,
12001195
TryBlock,
12011196
YeetExpr,
@@ -1230,7 +1225,6 @@ impl DesugaringKind {
12301225
/// The description wording should combine well with "desugaring of {}".
12311226
pub fn descr(self) -> &'static str {
12321227
match self {
1233-
DesugaringKind::CondTemporary => "`if` or `while` condition",
12341228
DesugaringKind::Async => "`async` block or function",
12351229
DesugaringKind::Await => "`await` expression",
12361230
DesugaringKind::QuestionMark => "operator `?`",
@@ -1253,7 +1247,6 @@ impl DesugaringKind {
12531247
/// like `from_desugaring = "QuestionMark"`
12541248
pub fn matches(&self, value: &str) -> bool {
12551249
match self {
1256-
DesugaringKind::CondTemporary => value == "CondTemporary",
12571250
DesugaringKind::Async => value == "Async",
12581251
DesugaringKind::Await => value == "Await",
12591252
DesugaringKind::QuestionMark => value == "QuestionMark",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /