diff options
| -rw-r--r-- | compiler/rustc_infer/src/infer/opaque_types.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/example-calendar.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/example-calendar.stderr | 19 |
3 files changed, 10 insertions, 21 deletions
diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index 35104c71bfc..46420fbe0c3 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -82,7 +82,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() { ty::Opaque(def_id, substs) => { if let ty::Opaque(did2, _) = *b.kind() { - if self.opaque_type_origin(did2, cause.span).is_some() { + // We could accept this, but there are various ways to handle this situation, and we don't + // want to make a decision on it right now. Likely this case is so super rare anyway, that + // no one encounters it in practice. + // It does occur however in `fn fut() -> impl Future<Output = i32> { async { 42 } }`, + // where it is of no concern, so we only check for TAITs. + if let Some(OpaqueTyOrigin::TyAlias) = + self.opaque_type_origin(did2, cause.span) + { self.tcx .sess .struct_span_err( diff --git a/src/test/ui/impl-trait/example-calendar.rs b/src/test/ui/impl-trait/example-calendar.rs index 26618eec1d7..45dcb74a6e0 100644 --- a/src/test/ui/impl-trait/example-calendar.rs +++ b/src/test/ui/impl-trait/example-calendar.rs @@ -1,3 +1,4 @@ +// run-pass // ignore-compare-mode-chalk #