Rollup merge of #99709 - lcnr:rm-MaybeTypeckResults, r=compiler-errors
`Inherited` always has `TypeckResults` available
This commit is contained in:
commit
b37b39db82
2 changed files with 5 additions and 33 deletions
|
@ -1,5 +1,4 @@
|
||||||
use super::callee::DeferredCallResolution;
|
use super::callee::DeferredCallResolution;
|
||||||
use super::MaybeInProgressTables;
|
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -29,7 +28,7 @@ use std::ops::Deref;
|
||||||
pub struct Inherited<'a, 'tcx> {
|
pub struct Inherited<'a, 'tcx> {
|
||||||
pub(super) infcx: InferCtxt<'a, 'tcx>,
|
pub(super) infcx: InferCtxt<'a, 'tcx>,
|
||||||
|
|
||||||
pub(super) typeck_results: super::MaybeInProgressTables<'a, 'tcx>,
|
pub(super) typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
|
||||||
|
|
||||||
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
|
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
|
||||||
|
|
||||||
|
@ -110,11 +109,11 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
let item_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
let item_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||||
let body_id = tcx.hir().maybe_body_owned_by(item_id);
|
let body_id = tcx.hir().maybe_body_owned_by(item_id);
|
||||||
|
let typeck_results =
|
||||||
|
infcx.in_progress_typeck_results.expect("building `FnCtxt` without typeck results");
|
||||||
|
|
||||||
Inherited {
|
Inherited {
|
||||||
typeck_results: MaybeInProgressTables {
|
typeck_results,
|
||||||
maybe_typeck_results: infcx.in_progress_typeck_results,
|
|
||||||
},
|
|
||||||
infcx,
|
infcx,
|
||||||
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
|
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
|
||||||
locals: RefCell::new(Default::default()),
|
locals: RefCell::new(Default::default()),
|
||||||
|
|
|
@ -128,8 +128,7 @@ use rustc_target::spec::abi::Abi;
|
||||||
use rustc_trait_selection::traits;
|
use rustc_trait_selection::traits;
|
||||||
use rustc_trait_selection::traits::error_reporting::recursive_type_with_infinite_size_error;
|
use rustc_trait_selection::traits::error_reporting::recursive_type_with_infinite_size_error;
|
||||||
use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
|
use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
|
||||||
|
use std::cell::RefCell;
|
||||||
use std::cell::{Ref, RefCell, RefMut};
|
|
||||||
|
|
||||||
use crate::require_c_abi_if_c_variadic;
|
use crate::require_c_abi_if_c_variadic;
|
||||||
use crate::util::common::indenter;
|
use crate::util::common::indenter;
|
||||||
|
@ -900,32 +899,6 @@ enum TupleArgumentsFlag {
|
||||||
TupleArguments,
|
TupleArguments,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A wrapper for `InferCtxt`'s `in_progress_typeck_results` field.
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
struct MaybeInProgressTables<'a, 'tcx> {
|
|
||||||
maybe_typeck_results: Option<&'a RefCell<ty::TypeckResults<'tcx>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> {
|
|
||||||
fn borrow(self) -> Ref<'a, ty::TypeckResults<'tcx>> {
|
|
||||||
match self.maybe_typeck_results {
|
|
||||||
Some(typeck_results) => typeck_results.borrow(),
|
|
||||||
None => bug!(
|
|
||||||
"MaybeInProgressTables: inh/fcx.typeck_results.borrow() with no typeck results"
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn borrow_mut(self) -> RefMut<'a, ty::TypeckResults<'tcx>> {
|
|
||||||
match self.maybe_typeck_results {
|
|
||||||
Some(typeck_results) => typeck_results.borrow_mut(),
|
|
||||||
None => bug!(
|
|
||||||
"MaybeInProgressTables: inh/fcx.typeck_results.borrow_mut() with no typeck results"
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn typeck_item_bodies(tcx: TyCtxt<'_>, (): ()) {
|
fn typeck_item_bodies(tcx: TyCtxt<'_>, (): ()) {
|
||||||
tcx.hir().par_body_owners(|body_owner_def_id| tcx.ensure().typeck(body_owner_def_id));
|
tcx.hir().par_body_owners(|body_owner_def_id| tcx.ensure().typeck(body_owner_def_id));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue