Skip to content

Commit

Permalink
add tests and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ouz-a committed Jul 27, 2022
1 parent 4a0473c commit 8716eae
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_traits/src/evaluate_obligation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ fn evaluate_obligation<'tcx>(
canonical_goal: CanonicalPredicateGoal<'tcx>,
) -> Result<EvaluationResult, OverflowError> {
debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal);
// HACK This bubble is required for this tests to pass:
// impl-trait/issue99642.rs
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_with_canonical(
DUMMY_SP,
&canonical_goal,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_traits/src/type_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ fn type_op_prove_predicate<'tcx>(
tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
// HACK This bubble is required for this test to pass:
// impl-trait/issue-99642.rs
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
&canonicalized,
|infcx, fulfill_cx, key| {
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/impl-trait/issue-99642-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// check-pass

#![feature(type_alias_impl_trait)]
type Opq = impl Sized;
fn test() -> impl Iterator<Item = Opq> {
Box::new(0..) as Box<dyn Iterator<Item = _>>
}
fn main(){}
7 changes: 7 additions & 0 deletions src/test/ui/impl-trait/issue-99642.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// check-pass

fn test() -> impl Iterator<Item = impl Sized> {
Box::new(0..) as Box<dyn Iterator<Item = _>>
}

fn main() {}

0 comments on commit 8716eae

Please sign in to comment.