Skip to content

Commit 39fdb4c

Browse files
Auto merge of #142802 - compiler-errors:dedup-analyses, r=<try>
Collapse Analysis|Borrowck|PostBorrowckAnalysis when there are no opaques r? lcnr
2 parents 9c4ff56 + 582c2df commit 39fdb4c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

compiler/rustc_type_ir/src/infer_ctxt.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,20 @@ impl<I: Interner> TypingMode<I> {
117117
}
118118

119119
pub fn borrowck(cx: I, body_def_id: I::LocalDefId) -> TypingMode<I> {
120-
TypingMode::Borrowck { defining_opaque_types: cx.opaque_types_defined_by(body_def_id) }
120+
let defining_opaque_types = cx.opaque_types_defined_by(body_def_id);
121+
if defining_opaque_types.is_empty() {
122+
TypingMode::non_body_analysis()
123+
} else {
124+
TypingMode::Borrowck { defining_opaque_types }
125+
}
121126
}
122127

123128
pub fn post_borrowck_analysis(cx: I, body_def_id: I::LocalDefId) -> TypingMode<I> {
124-
TypingMode::PostBorrowckAnalysis {
125-
defined_opaque_types: cx.opaque_types_defined_by(body_def_id),
129+
let defined_opaque_types = cx.opaque_types_defined_by(body_def_id);
130+
if defined_opaque_types.is_empty() {
131+
TypingMode::non_body_analysis()
132+
} else {
133+
TypingMode::PostBorrowckAnalysis { defined_opaque_types }
126134
}
127135
}
128136
}

0 commit comments

Comments
 (0)