Skip to content

Commit b37b39d

Browse files
authored
Rollup merge of rust-lang#99709 - lcnr:rm-MaybeTypeckResults, r=compiler-errors
`Inherited` always has `TypeckResults` available
2 parents 5bbdf65 + 0c6c69f commit b37b39d

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

compiler/rustc_typeck/src/check/inherited.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::callee::DeferredCallResolution;
2-
use super::MaybeInProgressTables;
32

43
use rustc_data_structures::fx::FxHashSet;
54
use rustc_hir as hir;
@@ -29,7 +28,7 @@ use std::ops::Deref;
2928
pub struct Inherited<'a, 'tcx> {
3029
pub(super) infcx: InferCtxt<'a, 'tcx>,
3130

32-
pub(super) typeck_results: super::MaybeInProgressTables<'a, 'tcx>,
31+
pub(super) typeck_results: &'a RefCell<ty::TypeckResults<'tcx>>,
3332

3433
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
3534

@@ -110,11 +109,11 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
110109
let tcx = infcx.tcx;
111110
let item_id = tcx.hir().local_def_id_to_hir_id(def_id);
112111
let body_id = tcx.hir().maybe_body_owned_by(item_id);
112+
let typeck_results =
113+
infcx.in_progress_typeck_results.expect("building `FnCtxt` without typeck results");
113114

114115
Inherited {
115-
typeck_results: MaybeInProgressTables {
116-
maybe_typeck_results: infcx.in_progress_typeck_results,
117-
},
116+
typeck_results,
118117
infcx,
119118
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
120119
locals: RefCell::new(Default::default()),

compiler/rustc_typeck/src/check/mod.rs

+1-28
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ use rustc_target::spec::abi::Abi;
128128
use rustc_trait_selection::traits;
129129
use rustc_trait_selection::traits::error_reporting::recursive_type_with_infinite_size_error;
130130
use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
131-
132-
use std::cell::{Ref, RefCell, RefMut};
131+
use std::cell::RefCell;
133132

134133
use crate::require_c_abi_if_c_variadic;
135134
use crate::util::common::indenter;
@@ -900,32 +899,6 @@ enum TupleArgumentsFlag {
900899
TupleArguments,
901900
}
902901

903-
/// A wrapper for `InferCtxt`'s `in_progress_typeck_results` field.
904-
#[derive(Copy, Clone)]
905-
struct MaybeInProgressTables<'a, 'tcx> {
906-
maybe_typeck_results: Option<&'a RefCell<ty::TypeckResults<'tcx>>>,
907-
}
908-
909-
impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> {
910-
fn borrow(self) -> Ref<'a, ty::TypeckResults<'tcx>> {
911-
match self.maybe_typeck_results {
912-
Some(typeck_results) => typeck_results.borrow(),
913-
None => bug!(
914-
"MaybeInProgressTables: inh/fcx.typeck_results.borrow() with no typeck results"
915-
),
916-
}
917-
}
918-
919-
fn borrow_mut(self) -> RefMut<'a, ty::TypeckResults<'tcx>> {
920-
match self.maybe_typeck_results {
921-
Some(typeck_results) => typeck_results.borrow_mut(),
922-
None => bug!(
923-
"MaybeInProgressTables: inh/fcx.typeck_results.borrow_mut() with no typeck results"
924-
),
925-
}
926-
}
927-
}
928-
929902
fn typeck_item_bodies(tcx: TyCtxt<'_>, (): ()) {
930903
tcx.hir().par_body_owners(|body_owner_def_id| tcx.ensure().typeck(body_owner_def_id));
931904
}

0 commit comments

Comments
 (0)