Skip to content

Commit e03edd2

Browse files
committed
Inline a function that is only ever used in one place
1 parent 2247778 commit e03edd2

File tree

1 file changed

+2
-68
lines changed

1 file changed

+2
-68
lines changed

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -71,43 +71,6 @@ pub struct OpaqueHiddenType<'tcx> {
7171
}
7272

7373
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
74-
/// Links the opaque type with the given hidden type
75-
/// and creates appropriate obligations. For example, given the input:
76-
///
77-
/// opaque = impl Iterator<Item = impl Debug>
78-
/// hidden = std::vec::IntoIter<i32>
79-
///
80-
/// this method would register the opaque type `impl Iterator` to have
81-
/// the hidden type `std::vec::IntoIter<i32>` and create the type variable
82-
/// `?1` but also the obligations:
83-
///
84-
/// std::vec::IntoIter<i32>: Iterator<Item = ?1>
85-
/// ?1: Debug
86-
///
87-
/// Moreover, it returns an `OpaqueTypeMap` that would map `?0` to
88-
/// info about the `impl Iterator<..>` type and `?1` to info about
89-
/// the `impl Debug` type.
90-
///
91-
/// # Parameters
92-
///
93-
/// - `parent_def_id` -- the `DefId` of the function in which the opaque type
94-
/// is defined
95-
/// - `body_id` -- the body-id with which the resulting obligations should
96-
/// be associated
97-
/// - `param_env` -- the in-scope parameter environment to be used for
98-
/// obligations
99-
/// - `value` -- the value within which we are instantiating opaque types
100-
/// - `value_span` -- the span where the value came from, used in error reporting
101-
pub fn instantiate_opaque_types(
102-
&self,
103-
ty: Ty<'tcx>,
104-
opaque: Ty<'tcx>,
105-
cause: ObligationCause<'tcx>,
106-
param_env: ty::ParamEnv<'tcx>,
107-
) -> Option<InferResult<'tcx, ()>> {
108-
Instantiator { infcx: self, cause, param_env }.fold_opaque_ty_new(opaque, |_, _| ty)
109-
}
110-
11174
pub fn handle_opaque_type(
11275
&self,
11376
a: Ty<'tcx>,
@@ -123,7 +86,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12386
if !matches!(a.kind(), ty::Opaque(..)) {
12487
return None;
12588
}
126-
self.instantiate_opaque_types(b, a, cause.clone(), param_env)
89+
Instantiator { infcx: self, cause: cause.clone(), param_env }
90+
.fold_opaque_ty_new(a, |_, _| b)
12791
};
12892
if let Some(res) = process(a, b) {
12993
res
@@ -298,36 +262,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
298262
/// but this is not necessary, because the opaque type we
299263
/// create will be allowed to reference `T`. So we only generate a
300264
/// constraint that `'0: 'a`.
301-
///
302-
/// # The `free_region_relations` parameter
303-
///
304-
/// The `free_region_relations` argument is used to find the
305-
/// "minimum" of the regions supplied to a given opaque type.
306-
/// It must be a relation that can answer whether `'a <= 'b`,
307-
/// where `'a` and `'b` are regions that appear in the "substs"
308-
/// for the opaque type references (the `<'a>` in `Foo1<'a>`).
309-
///
310-
/// Note that we do not impose the constraints based on the
311-
/// generic regions from the `Foo1` definition (e.g., `'x`). This
312-
/// is because the constraints we are imposing here is basically
313-
/// the concern of the one generating the constraining type C1,
314-
/// which is the current function. It also means that we can
315-
/// take "implied bounds" into account in some cases:
316-
///
317-
/// ```text
318-
/// trait SomeTrait<'a, 'b> { }
319-
/// fn foo<'a, 'b>(_: &'a &'b u32) -> impl SomeTrait<'a, 'b> { .. }
320-
/// ```
321-
///
322-
/// Here, the fact that `'b: 'a` is known only because of the
323-
/// implied bounds from the `&'a &'b u32` parameter, and is not
324-
/// "inherent" to the opaque type definition.
325-
///
326-
/// # Parameters
327-
///
328-
/// - `opaque_types` -- the map produced by `instantiate_opaque_types`
329-
/// - `free_region_relations` -- something that can be used to relate
330-
/// the free regions (`'a`) that appear in the impl trait.
331265
#[instrument(level = "debug", skip(self))]
332266
pub fn register_member_constraints(
333267
&self,

0 commit comments

Comments
 (0)