Skip to content

Commit

Permalink
Rollup merge of #107888 - lcnr:opaque-ty-validate, r=wesleywiser
Browse files Browse the repository at this point in the history
revert #107074, add regression test

fixes #107346
  • Loading branch information
Dylan-DPC authored Feb 11, 2023
2 parents dfc2422 + 3a72238 commit 745361d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion compiler/rustc_const_eval/src/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_middle::mir::{
RetagKind, RuntimePhase, Rvalue, SourceScope, Statement, StatementKind, Terminator,
TerminatorKind, UnOp, START_BLOCK,
};
use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt};
use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt, TypeVisitable};
use rustc_mir_dataflow::impls::MaybeStorageLive;
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_mir_dataflow::{Analysis, ResultsCursor};
Expand Down Expand Up @@ -231,6 +231,15 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
return true;
}

// We sometimes have to use `defining_opaque_types` for subtyping
// to succeed here and figuring out how exactly that should work
// is annoying. It is harmless enough to just not validate anything
// in that case. We still check this after analysis as all opque
// types have been revealed at this point.
if (src, dest).has_opaque_types() {
return true;
}

crate::util::is_subtype(self.tcx, self.param_env, src, dest)
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/impl-trait/nested-return-type2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// check-pass
// compile-flags: -Zvalidate-mir

// Using -Zvalidate-mir as a regression test for #107346.

trait Duh {}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/nested-return-type2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds
--> $DIR/nested-return-type2.rs:25:24
--> $DIR/nested-return-type2.rs:28:24
|
LL | type Assoc: Duh;
| --- this associated type bound is unsatisfied for `impl Send`
Expand Down

0 comments on commit 745361d

Please sign in to comment.