Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove commit_if_ok probe from NLL type relation #103601

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ where
(&ty::Infer(ty::TyVar(vid)), _) => self.relate_ty_var((vid, b)),

(&ty::Opaque(a_def_id, _), &ty::Opaque(b_def_id, _)) if a_def_id == b_def_id => {
infcx.commit_if_ok(|_| infcx.super_combine_tys(self, a, b)).or_else(|err| {
infcx.super_combine_tys(self, a, b).or_else(|err| {
self.tcx().sess.delay_span_bug(
self.delegate.span(),
"failure to relate an opaque to itself should result in an error later on",
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/impl-trait/issue-103599.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass

trait T {}

fn wrap(x: impl T) -> impl T {
//~^ WARN function cannot return without recursing
wrap(wrap(x))
}

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/impl-trait/issue-103599.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
warning: function cannot return without recursing
--> $DIR/issue-103599.rs:5:1
|
LL | fn wrap(x: impl T) -> impl T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
LL |
LL | wrap(wrap(x))
| ------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
= note: `#[warn(unconditional_recursion)]` on by default

warning: 1 warning emitted