|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 | 11 | use rustc::infer::{self, InferOk, TypeOrigin};
|
| 12 | +use rustc::middle::free_region::FreeRegionMap; |
12 | 13 | use rustc::ty;
|
13 | 14 | use rustc::traits::{self, Reveal};
|
14 | 15 | use rustc::ty::error::{ExpectedFound, TypeError};
|
@@ -39,8 +40,10 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
39 | 40 | impl_m_body_id: ast::NodeId,
|
40 | 41 | trait_m: &ty::Method<'tcx>,
|
41 | 42 | impl_trait_ref: &ty::TraitRef<'tcx>,
|
42 |
| - trait_item_span: Option<Span>) { |
43 |
| - debug!("compare_impl_method(impl_trait_ref={:?})", impl_trait_ref); |
| 43 | + trait_item_span: Option<Span>, |
| 44 | + old_broken_mode: bool) { |
| 45 | + debug!("compare_impl_method(impl_trait_ref={:?})", |
| 46 | + impl_trait_ref); |
44 | 47 |
|
45 | 48 | debug!("compare_impl_method: impl_trait_ref (liberated) = {:?}",
|
46 | 49 | impl_trait_ref);
|
@@ -367,7 +370,7 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
367 | 370 | item_name: impl_m.name,
|
368 | 371 | impl_item_def_id: impl_m.def_id,
|
369 | 372 | trait_item_def_id: trait_m.def_id,
|
370 |
| - lint_id: Some(impl_m_body_id), |
| 373 | + lint_id: if !old_broken_mode { Some(impl_m_body_id) } else { None }, |
371 | 374 | },
|
372 | 375 | };
|
373 | 376 |
|
@@ -473,8 +476,20 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
473 | 476 |
|
474 | 477 | // Finally, resolve all regions. This catches wily misuses of
|
475 | 478 | // lifetime parameters.
|
476 |
| - let fcx = FnCtxt::new(&inh, tcx.types.err, impl_m_body_id); |
477 |
| - fcx.regionck_item(impl_m_body_id, impl_m_span, &[]); |
| 479 | + if old_broken_mode { |
| 480 | + // FIXME(#18937) -- this is how the code used to |
| 481 | + // work. This is buggy because the fulfillment cx creates |
| 482 | + // region obligations that get overlooked. The right |
| 483 | + // thing to do is the code below. But we keep this old |
| 484 | + // pass around temporarily. |
| 485 | + let mut free_regions = FreeRegionMap::new(); |
| 486 | + free_regions.relate_free_regions_from_predicates( |
| 487 | + &infcx.parameter_environment.caller_bounds); |
| 488 | + infcx.resolve_regions_and_report_errors(&free_regions, impl_m_body_id); |
| 489 | + } else { |
| 490 | + let fcx = FnCtxt::new(&inh, tcx.types.err, impl_m_body_id); |
| 491 | + fcx.regionck_item(impl_m_body_id, impl_m_span, &[]); |
| 492 | + } |
478 | 493 | });
|
479 | 494 |
|
480 | 495 | fn check_region_bounds_on_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|
0 commit comments