|
1 | 1 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
2 | 2 | use rustc_errors::ErrorGuaranteed;
|
| 3 | +use rustc_hir::def::DefKind; |
3 | 4 | use rustc_hir::def_id::LocalDefId;
|
4 | 5 | use rustc_hir::OpaqueTyOrigin;
|
5 | 6 | use rustc_infer::infer::InferCtxt;
|
@@ -308,20 +309,19 @@ fn check_opaque_type_well_formed<'tcx>(
|
308 | 309 | return Ok(definition_ty);
|
309 | 310 | };
|
310 | 311 | let param_env = tcx.param_env(def_id);
|
311 |
| - // HACK This bubble is required for this tests to pass: |
312 |
| - // nested-return-type2-tait2.rs |
313 |
| - // nested-return-type2-tait3.rs |
| 312 | + |
| 313 | + let mut parent_def_id = def_id; |
| 314 | + while tcx.def_kind(parent_def_id) == DefKind::OpaqueTy { |
| 315 | + parent_def_id = tcx.local_parent(parent_def_id); |
| 316 | + } |
| 317 | + |
314 | 318 | // FIXME(-Ztrait-solver=next): We probably should use `DefiningAnchor::Error`
|
315 | 319 | // and prepopulate this `InferCtxt` with known opaque values, rather than
|
316 | 320 | // using the `Bind` anchor here. For now it's fine.
|
317 | 321 | let infcx = tcx
|
318 | 322 | .infer_ctxt()
|
319 | 323 | .with_next_trait_solver(next_trait_solver)
|
320 |
| - .with_opaque_type_inference(if next_trait_solver { |
321 |
| - DefiningAnchor::Bind(def_id) |
322 |
| - } else { |
323 |
| - DefiningAnchor::Bubble |
324 |
| - }) |
| 324 | + .with_opaque_type_inference(DefiningAnchor::Bind(parent_def_id)) |
325 | 325 | .build();
|
326 | 326 | let ocx = ObligationCtxt::new(&infcx);
|
327 | 327 | let identity_args = GenericArgs::identity_for_item(tcx, def_id);
|
|
0 commit comments