Skip to content

Commit a3fbae5

Browse files
committed
Merge match and if
1 parent c6c58e3 commit a3fbae5

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

compiler/rustc_hir_typeck/src/opaque_types.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,24 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
128128
}
129129
}
130130

131-
if let UsageKind::HasDefiningUse(first_use) = usage_kind {
131+
if let UsageKind::HasDefiningUse(ty) = usage_kind {
132132
for &(opaque_type_key, hidden_type) in opaque_types {
133133
if opaque_type_key.def_id != def_id {
134134
continue;
135135
}
136136

137-
let expected =
138-
EarlyBinder::bind(first_use.ty).instantiate(tcx, opaque_type_key.args);
137+
let expected = EarlyBinder::bind(ty.ty).instantiate(tcx, opaque_type_key.args);
139138
self.demand_eqtype(hidden_type.span, expected, hidden_type.ty);
140139
}
141-
}
142140

143-
match usage_kind {
144-
UsageKind::HasDefiningUse(hidden_type) => {
145-
let prev =
146-
self.typeck_results.borrow_mut().hidden_types.insert(def_id, hidden_type);
141+
let prev = self.typeck_results.borrow_mut().hidden_types.insert(def_id, ty);
147142

148-
// We do want to insert opaque types the first pass, because
149-
// we want to equate them. So, the second pass (where we
150-
// report errors) may have a hidden type inserted.
151-
if first_pass {
152-
assert!(prev.is_none());
153-
}
143+
// We do want to insert opaque types the first pass, because
144+
// we want to equate them. So, the second pass (where we
145+
// report errors) may have a hidden type inserted.
146+
if first_pass {
147+
assert!(prev.is_none());
154148
}
155-
_ => {}
156149
}
157150

158151
// If this the first pass (`try_handle_opaque_type_uses_next`),

tests/ui/traits/next-solver/opaques/hidden-types-equate-before-fallback.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Regression test for trait-system-refactor-initiative#240. Hidden types should
77
// equate *before* inference var fallback, otherwise we can get mismatched types.
88

9-
109
#[derive(Clone, Copy)]
1110
struct FileSystem;
1211
impl FileSystem {

0 commit comments

Comments
 (0)