Skip to content

Commit 9dd3d29

Browse files
committed
Auto merge of rust-lang#103601 - compiler-errors:no-opaque-probe-in-nll-relate, r=oli-obk
Remove `commit_if_ok` probe from NLL type relation It was not really necessary to add the `commit_if_ok` in rust-lang#100092 -- I added it to protect us against weird inference error messages due to recursive RPIT calls, but we are always on the error path when this happens anyways, and I can't come up with an example that makes this manifest. Fixes rust-lang#103599 r? `@oli-obk` since you reviewed rust-lang#100092, feel free to re-roll. :b: :loudspeaker: beta-nominating this since it's on beta (which forks in ~a week~ two days :fearful:) -- worst case we could revert the original PR on beta and land this on nightly, to give it some extra soak time...
2 parents 44fcfb0 + 901649e commit 9dd3d29

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

compiler/rustc_infer/src/infer/nll_relate/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ where
592592
(&ty::Infer(ty::TyVar(vid)), _) => self.relate_ty_var((vid, b)),
593593

594594
(&ty::Opaque(a_def_id, _), &ty::Opaque(b_def_id, _)) if a_def_id == b_def_id => {
595-
infcx.commit_if_ok(|_| infcx.super_combine_tys(self, a, b)).or_else(|err| {
595+
infcx.super_combine_tys(self, a, b).or_else(|err| {
596596
self.tcx().sess.delay_span_bug(
597597
self.delegate.span(),
598598
"failure to relate an opaque to itself should result in an error later on",
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
trait T {}
4+
5+
fn wrap(x: impl T) -> impl T {
6+
//~^ WARN function cannot return without recursing
7+
wrap(wrap(x))
8+
}
9+
10+
fn main() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: function cannot return without recursing
2+
--> $DIR/issue-103599.rs:5:1
3+
|
4+
LL | fn wrap(x: impl T) -> impl T {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
6+
LL |
7+
LL | wrap(wrap(x))
8+
| ------- recursive call site
9+
|
10+
= help: a `loop` may express intention better if this is on purpose
11+
= note: `#[warn(unconditional_recursion)]` on by default
12+
13+
warning: 1 warning emitted
14+

0 commit comments

Comments
 (0)