Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bf7a745

Browse files
Inherited -> TypeckRootCtxt
1 parent 536606b commit bf7a745

File tree

11 files changed

+32
-33
lines changed

11 files changed

+32
-33
lines changed

‎compiler/rustc_hir_typeck/src/_match.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
243243
let can_coerce_to_return_ty = match self.ret_coercion.as_ref() {
244244
Some(ret_coercion) => {
245245
let ret_ty = ret_coercion.borrow().expected_ty();
246-
let ret_ty = self.inh.infcx.shallow_resolve(ret_ty);
246+
let ret_ty = self.infcx.shallow_resolve(ret_ty);
247247
self.can_coerce(arm_ty, ret_ty)
248248
&& prior_arm.map_or(true, |(_, ty, _)| self.can_coerce(ty, ret_ty))
249249
// The match arms need to unify for the case of `impl Trait`.

‎compiler/rustc_hir_typeck/src/closure.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
848848
bound_vars,
849849
);
850850

851-
let c_result = self.inh.infcx.canonicalize_response(result);
851+
let c_result = self.infcx.canonicalize_response(result);
852852
self.typeck_results.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result);
853853

854854
// Normalize only after registering in `user_provided_sigs`.

‎compiler/rustc_hir_typeck/src/fallback.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
347347
.any(|n| roots_reachable_from_non_diverging.visited(n));
348348

349349
let infer_var_infos: UnordBag<_> = self
350-
.inh
351350
.infer_var_info
352351
.borrow()
353352
.items()

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
526526
pub(in super::super) fn resolve_rvalue_scopes(&self, def_id: DefId) {
527527
let scope_tree = self.tcx.region_scope_tree(def_id);
528528
let rvalue_scopes = { rvalue_scopes::resolve_rvalue_scopes(self, scope_tree, def_id) };
529-
let mut typeck_results = self.inh.typeck_results.borrow_mut();
529+
let mut typeck_results = self.typeck_results.borrow_mut();
530530
typeck_results.rvalue_scopes = rvalue_scopes;
531531
}
532532

‎compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod suggestions;
77
use crate::coercion::DynamicCoerceMany;
88
use crate::fallback::DivergingFallbackBehavior;
99
use crate::fn_ctxt::checks::DivergingBlockBehavior;
10-
use crate::{CoroutineTypes, Diverges, EnclosingBreakables, Inherited};
10+
use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt};
1111
use hir::def_id::CRATE_DEF_ID;
1212
use rustc_errors::{DiagCtxt, ErrorGuaranteed};
1313
use rustc_hir as hir;
@@ -108,7 +108,7 @@ pub struct FnCtxt<'a, 'tcx> {
108108

109109
pub(super) enclosing_breakables: RefCell<EnclosingBreakables<'tcx>>,
110110

111-
pub(super) inh: &'a Inherited<'tcx>,
111+
pub(super) root_ctxt: &'a TypeckRootCtxt<'tcx>,
112112

113113
pub(super) fallback_has_occurred: Cell<bool>,
114114

@@ -118,12 +118,12 @@ pub struct FnCtxt<'a, 'tcx> {
118118

119119
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
120120
pub fn new(
121-
inh: &'a Inherited<'tcx>,
121+
root_ctxt: &'a TypeckRootCtxt<'tcx>,
122122
param_env: ty::ParamEnv<'tcx>,
123123
body_id: LocalDefId,
124124
) -> FnCtxt<'a, 'tcx> {
125125
let (diverging_fallback_behavior, diverging_block_behavior) =
126-
parse_never_type_options_attr(inh.tcx);
126+
parse_never_type_options_attr(root_ctxt.tcx);
127127
FnCtxt {
128128
body_id,
129129
param_env,
@@ -137,7 +137,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
137137
stack: Vec::new(),
138138
by_id: Default::default(),
139139
}),
140-
inh,
140+
root_ctxt,
141141
fallback_has_occurred: Cell::new(false),
142142
diverging_fallback_behavior,
143143
diverging_block_behavior,
@@ -206,9 +206,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
206206
}
207207

208208
impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> {
209-
type Target = Inherited<'tcx>;
209+
type Target = TypeckRootCtxt<'tcx>;
210210
fn deref(&self) -> &Self::Target {
211-
self.inh
211+
self.root_ctxt
212212
}
213213
}
214214

‎compiler/rustc_hir_typeck/src/gather_locals.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
9595
Some(ref ty) => {
9696
let o_ty = self.fcx.lower_ty(ty);
9797

98-
let c_ty =
99-
self.fcx.inh.infcx.canonicalize_user_type_annotation(UserType::Ty(o_ty.raw));
98+
let c_ty = self.fcx.infcx.canonicalize_user_type_annotation(UserType::Ty(o_ty.raw));
10099
debug!("visit_local: ty.hir_id={:?} o_ty={:?} c_ty={:?}", ty.hir_id, o_ty, c_ty);
101100
self.fcx
102101
.typeck_results

‎compiler/rustc_hir_typeck/src/lib.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ pub mod expr_use_visitor;
3131
mod fallback;
3232
mod fn_ctxt;
3333
mod gather_locals;
34-
mod inherited;
3534
mod intrinsicck;
3635
mod mem_categorization;
3736
mod method;
3837
mod op;
3938
mod pat;
4039
mod place_op;
4140
mod rvalue_scopes;
41+
mod typeck_root_ctxt;
4242
mod upvar;
4343
mod writeback;
4444

4545
pub use fn_ctxt::FnCtxt;
46-
pub use inherited::Inherited;
46+
pub use typeck_root_ctxt::TypeckRootCtxt;
4747

4848
use crate::check::check_fn;
4949
use crate::coercion::DynamicCoerceMany;
@@ -170,11 +170,11 @@ fn typeck_with_fallback<'tcx>(
170170

171171
let param_env = tcx.param_env(def_id);
172172

173-
let inh = Inherited::new(tcx, def_id);
173+
let root_ctxt = TypeckRootCtxt::new(tcx, def_id);
174174
if let Some(inspector) = inspector {
175-
inh.infcx.attach_obligation_inspector(inspector);
175+
root_ctxt.infcx.attach_obligation_inspector(inspector);
176176
}
177-
let mut fcx = FnCtxt::new(&inh, param_env, def_id);
177+
let mut fcx = FnCtxt::new(&root_ctxt, param_env, def_id);
178178

179179
if let Some(hir::FnSig { header, decl, .. }) = fn_sig {
180180
let fn_sig = if decl.output.get_infer_ret_ty().is_some() {

‎compiler/rustc_hir_typeck/src/pat.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
388388

389389
if !pat_adjustments.is_empty() {
390390
debug!("default binding mode is now {:?}", def_bm);
391-
self.inh
392-
.typeck_results
391+
self.typeck_results
393392
.borrow_mut()
394393
.pat_adjustments_mut()
395394
.insert(pat.hir_id, pat_adjustments);
@@ -614,7 +613,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
614613
_ => BindingMode::convert(ba),
615614
};
616615
// ...and store it in a side table:
617-
self.inh.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);
616+
self.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);
618617

619618
debug!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
620619

‎compiler/rustc_hir_typeck/src/inherited.rs‎ renamed to ‎compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ use rustc_trait_selection::traits::{self, PredicateObligation, TraitEngine, Trai
1616
use std::cell::RefCell;
1717
use std::ops::Deref;
1818

19-
/// Closures defined within the function. For example:
19+
// Data shared between a "typeck root" and its nested bodies,
20+
/// e.g. closures defined within the function. For example:
2021
/// ```ignore (illustrative)
2122
/// fn foo() {
2223
/// bar(move|| { ... })
2324
/// }
2425
/// ```
2526
/// Here, the function `foo()` and the closure passed to
2627
/// `bar()` will each have their own `FnCtxt`, but they will
27-
/// share the inherited fields.
28-
pub struct Inherited<'tcx> {
28+
/// share the inference context, will process obligations together,
29+
/// can access each other's local types (scoping permitted), etc.
30+
pub struct TypeckRootCtxt<'tcx> {
2931
pub(super) infcx: InferCtxt<'tcx>,
3032

3133
pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,
@@ -65,14 +67,14 @@ pub struct Inherited<'tcx> {
6567
pub(super) infer_var_info: RefCell<UnordMap<ty::TyVid, ty::InferVarInfo>>,
6668
}
6769

68-
impl<'tcx> Deref for Inherited<'tcx> {
70+
impl<'tcx> Deref for TypeckRootCtxt<'tcx> {
6971
type Target = InferCtxt<'tcx>;
7072
fn deref(&self) -> &Self::Target {
7173
&self.infcx
7274
}
7375
}
7476

75-
impl<'tcx> Inherited<'tcx> {
77+
impl<'tcx> TypeckRootCtxt<'tcx> {
7678
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
7779
let hir_owner = tcx.local_def_id_to_hir_id(def_id).owner;
7880

@@ -83,7 +85,7 @@ impl<'tcx> Inherited<'tcx> {
8385
.build();
8486
let typeck_results = RefCell::new(ty::TypeckResults::new(hir_owner));
8587

86-
Inherited {
88+
TypeckRootCtxt {
8789
typeck_results,
8890
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(&infcx)),
8991
infcx,

‎src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_errors::Applicability;
1212
use rustc_hir::def::{DefKind, Res};
1313
use rustc_hir::def_id::DefId;
1414
use rustc_hir::{BorrowKind, Expr, ExprKind, ItemKind, LangItem, Node};
15-
use rustc_hir_typeck::{FnCtxt, Inherited};
15+
use rustc_hir_typeck::{FnCtxt, TypeckRootCtxt};
1616
use rustc_infer::infer::TyCtxtInferExt;
1717
use rustc_lint::LateContext;
1818
use rustc_middle::mir::Mutability;
@@ -438,8 +438,8 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
438438
Node::Item(item) => {
439439
if let ItemKind::Fn(_, _, body_id) = &item.kind
440440
&& let output_ty = return_ty(cx, item.owner_id)
441-
&& let inherited = Inherited::new(cx.tcx, item.owner_id.def_id)
442-
&& let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, item.owner_id.def_id)
441+
&& let root_ctxt = TypeckRootCtxt::new(cx.tcx, item.owner_id.def_id)
442+
&& let fn_ctxt = FnCtxt::new(&root_ctxt, cx.param_env, item.owner_id.def_id)
443443
&& fn_ctxt.can_coerce(ty, output_ty)
444444
{
445445
if has_lifetime(output_ty) && has_lifetime(ty) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /