Skip to content

Commit 6fb52c2

Browse files
authored
Unrolled build for rust-lang#121002
Rollup merge of rust-lang#121002 - lcnr:cleanup-commit_if_ok, r=oli-obk remove unnecessary calls to `commit_if_ok` we propagate the error outwards, so anything which wants to discard the error should do so itself. r? types
2 parents 37b6533 + ae92334 commit 6fb52c2

File tree

4 files changed

+60
-70
lines changed

4 files changed

+60
-70
lines changed

compiler/rustc_infer/src/infer/at.rs

+20-28
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,11 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
285285
T: Relate<'tcx>,
286286
{
287287
let Trace { at, trace, a_is_expected } = self;
288-
at.infcx.commit_if_ok(|_| {
289-
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
290-
fields
291-
.sub(a_is_expected)
292-
.relate(a, b)
293-
.map(move |_| InferOk { value: (), obligations: fields.obligations })
294-
})
288+
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
289+
fields
290+
.sub(a_is_expected)
291+
.relate(a, b)
292+
.map(move |_| InferOk { value: (), obligations: fields.obligations })
295293
}
296294

297295
/// Makes `a == b`; the expectation is set by the call to
@@ -302,13 +300,11 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
302300
T: Relate<'tcx>,
303301
{
304302
let Trace { at, trace, a_is_expected } = self;
305-
at.infcx.commit_if_ok(|_| {
306-
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
307-
fields
308-
.equate(a_is_expected)
309-
.relate(a, b)
310-
.map(move |_| InferOk { value: (), obligations: fields.obligations })
311-
})
303+
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
304+
fields
305+
.equate(a_is_expected)
306+
.relate(a, b)
307+
.map(move |_| InferOk { value: (), obligations: fields.obligations })
312308
}
313309

314310
#[instrument(skip(self), level = "debug")]
@@ -317,13 +313,11 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
317313
T: Relate<'tcx>,
318314
{
319315
let Trace { at, trace, a_is_expected } = self;
320-
at.infcx.commit_if_ok(|_| {
321-
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
322-
fields
323-
.lub(a_is_expected)
324-
.relate(a, b)
325-
.map(move |t| InferOk { value: t, obligations: fields.obligations })
326-
})
316+
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
317+
fields
318+
.lub(a_is_expected)
319+
.relate(a, b)
320+
.map(move |t| InferOk { value: t, obligations: fields.obligations })
327321
}
328322

329323
#[instrument(skip(self), level = "debug")]
@@ -332,13 +326,11 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
332326
T: Relate<'tcx>,
333327
{
334328
let Trace { at, trace, a_is_expected } = self;
335-
at.infcx.commit_if_ok(|_| {
336-
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
337-
fields
338-
.glb(a_is_expected)
339-
.relate(a, b)
340-
.map(move |t| InferOk { value: t, obligations: fields.obligations })
341-
})
329+
let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types);
330+
fields
331+
.glb(a_is_expected)
332+
.relate(a, b)
333+
.map(move |t| InferOk { value: t, obligations: fields.obligations })
342334
}
343335
}
344336

compiler/rustc_infer/src/infer/canonical/query_response.rs

+32-34
Original file line numberDiff line numberDiff line change
@@ -620,42 +620,40 @@ impl<'tcx> InferCtxt<'tcx> {
620620
variables1: &OriginalQueryValues<'tcx>,
621621
variables2: impl Fn(BoundVar) -> GenericArg<'tcx>,
622622
) -> InferResult<'tcx, ()> {
623-
self.commit_if_ok(|_| {
624-
let mut obligations = vec![];
625-
for (index, value1) in variables1.var_values.iter().enumerate() {
626-
let value2 = variables2(BoundVar::new(index));
627-
628-
match (value1.unpack(), value2.unpack()) {
629-
(GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
630-
obligations.extend(
631-
self.at(cause, param_env)
632-
.eq(DefineOpaqueTypes::Yes, v1, v2)?
633-
.into_obligations(),
634-
);
635-
}
636-
(GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
637-
if re1.is_erased() && re2.is_erased() =>
638-
{
639-
// no action needed
640-
}
641-
(GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => {
642-
obligations.extend(
643-
self.at(cause, param_env)
644-
.eq(DefineOpaqueTypes::Yes, v1, v2)?
645-
.into_obligations(),
646-
);
647-
}
648-
(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
649-
let ok = self.at(cause, param_env).eq(DefineOpaqueTypes::Yes, v1, v2)?;
650-
obligations.extend(ok.into_obligations());
651-
}
652-
_ => {
653-
bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,);
654-
}
623+
let mut obligations = vec![];
624+
for (index, value1) in variables1.var_values.iter().enumerate() {
625+
let value2 = variables2(BoundVar::new(index));
626+
627+
match (value1.unpack(), value2.unpack()) {
628+
(GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
629+
obligations.extend(
630+
self.at(cause, param_env)
631+
.eq(DefineOpaqueTypes::Yes, v1, v2)?
632+
.into_obligations(),
633+
);
634+
}
635+
(GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
636+
if re1.is_erased() && re2.is_erased() =>
637+
{
638+
// no action needed
639+
}
640+
(GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => {
641+
obligations.extend(
642+
self.at(cause, param_env)
643+
.eq(DefineOpaqueTypes::Yes, v1, v2)?
644+
.into_obligations(),
645+
);
646+
}
647+
(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
648+
let ok = self.at(cause, param_env).eq(DefineOpaqueTypes::Yes, v1, v2)?;
649+
obligations.extend(ok.into_obligations());
650+
}
651+
_ => {
652+
bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,);
655653
}
656654
}
657-
Ok(InferOk { value: (), obligations })
658-
})
655+
}
656+
Ok(InferOk { value: (), obligations })
659657
}
660658
}
661659

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
192192
&mut obligations,
193193
);
194194

195-
obligations.extend(self.infcx.commit_if_ok(|_| {
195+
obligations.extend(
196196
self.infcx
197197
.at(&obligation.cause, obligation.param_env)
198198
.sup(DefineOpaqueTypes::No, placeholder_trait_predicate, candidate)
199199
.map(|InferOk { obligations, .. }| obligations)
200-
.map_err(|_| Unimplemented)
201-
})?);
200+
.map_err(|_| Unimplemented)?,
201+
);
202202

203203
// FIXME(compiler-errors): I don't think this is needed.
204204
if let ty::Alias(ty::Projection, alias_ty) = placeholder_self_ty.kind() {
@@ -532,13 +532,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
532532
&mut nested,
533533
);
534534

535-
nested.extend(self.infcx.commit_if_ok(|_| {
535+
nested.extend(
536536
self.infcx
537537
.at(&obligation.cause, obligation.param_env)
538538
.sup(DefineOpaqueTypes::No, obligation_trait_ref, upcast_trait_ref)
539539
.map(|InferOk { obligations, .. }| obligations)
540-
.map_err(|_| Unimplemented)
541-
})?);
540+
.map_err(|_| Unimplemented)?,
541+
);
542542

543543
// Check supertraits hold. This is so that their associated type bounds
544544
// will be checked in the code below.

tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | |
99
LL | | });
1010
| |______^ expected due to this
1111
|
12-
= note: expected closure signature `fn(_, _) -> _`
13-
found closure signature `fn(u32, i32) -> _`
12+
= note: expected closure signature `fn(_, u32) -> _`
13+
found closure signature `fn(_, i32) -> _`
1414
note: required by a bound in `with_closure`
1515
--> $DIR/expect-infer-var-appearing-twice.rs:2:14
1616
|

0 commit comments

Comments
 (0)