about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-01-27 14:31:24 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-02-02 15:40:11 +0000
commite03edd287e774e737add22fd957e1cf4c813e1ea (patch)
tree6df037f8030c2a69f0a95c01fa92e211ad3e85fc
parent22477784a72ab1e5b26f8cb555f02e691d066898 (diff)
downloadrust-e03edd287e774e737add22fd957e1cf4c813e1ea.tar.gz
rust-e03edd287e774e737add22fd957e1cf4c813e1ea.zip
Inline a function that is only ever used in one place
-rw-r--r--compiler/rustc_infer/src/infer/opaque_types.rs70
1 files changed, 2 insertions, 68 deletions
diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs
index 748fe1379cd..b455e7f149d 100644
--- a/compiler/rustc_infer/src/infer/opaque_types.rs
+++ b/compiler/rustc_infer/src/infer/opaque_types.rs
@@ -71,43 +71,6 @@ pub struct OpaqueHiddenType<'tcx> {
 }
 
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
-    /// Links the opaque type with the given hidden type
-    /// and creates appropriate obligations. For example, given the input:
-    ///
-    ///     opaque = impl Iterator<Item = impl Debug>
-    ///     hidden = std::vec::IntoIter<i32>
-    ///
-    /// this method would register the opaque type `impl Iterator` to have
-    /// the hidden type `std::vec::IntoIter<i32>` and create the type variable
-    /// `?1` but also the obligations:
-    ///
-    ///     std::vec::IntoIter<i32>: Iterator<Item = ?1>
-    ///     ?1: Debug
-    ///
-    /// Moreover, it returns an `OpaqueTypeMap` that would map `?0` to
-    /// info about the `impl Iterator<..>` type and `?1` to info about
-    /// the `impl Debug` type.
-    ///
-    /// # Parameters
-    ///
-    /// - `parent_def_id` -- the `DefId` of the function in which the opaque type
-    ///   is defined
-    /// - `body_id` -- the body-id with which the resulting obligations should
-    ///   be associated
-    /// - `param_env` -- the in-scope parameter environment to be used for
-    ///   obligations
-    /// - `value` -- the value within which we are instantiating opaque types
-    /// - `value_span` -- the span where the value came from, used in error reporting
-    pub fn instantiate_opaque_types(
-        &self,
-        ty: Ty<'tcx>,
-        opaque: Ty<'tcx>,
-        cause: ObligationCause<'tcx>,
-        param_env: ty::ParamEnv<'tcx>,
-    ) -> Option<InferResult<'tcx, ()>> {
-        Instantiator { infcx: self, cause, param_env }.fold_opaque_ty_new(opaque, |_, _| ty)
-    }
-
     pub fn handle_opaque_type(
         &self,
         a: Ty<'tcx>,
@@ -123,7 +86,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                 if !matches!(a.kind(), ty::Opaque(..)) {
                     return None;
                 }
-                self.instantiate_opaque_types(b, a, cause.clone(), param_env)
+                Instantiator { infcx: self, cause: cause.clone(), param_env }
+                    .fold_opaque_ty_new(a, |_, _| b)
             };
             if let Some(res) = process(a, b) {
                 res
@@ -298,36 +262,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     /// but this is not necessary, because the opaque type we
     /// create will be allowed to reference `T`. So we only generate a
     /// constraint that `'0: 'a`.
-    ///
-    /// # The `free_region_relations` parameter
-    ///
-    /// The `free_region_relations` argument is used to find the
-    /// "minimum" of the regions supplied to a given opaque type.
-    /// It must be a relation that can answer whether `'a <= 'b`,
-    /// where `'a` and `'b` are regions that appear in the "substs"
-    /// for the opaque type references (the `<'a>` in `Foo1<'a>`).
-    ///
-    /// Note that we do not impose the constraints based on the
-    /// generic regions from the `Foo1` definition (e.g., `'x`). This
-    /// is because the constraints we are imposing here is basically
-    /// the concern of the one generating the constraining type C1,
-    /// which is the current function. It also means that we can
-    /// take "implied bounds" into account in some cases:
-    ///
-    /// ```text
-    /// trait SomeTrait<'a, 'b> { }
-    /// fn foo<'a, 'b>(_: &'a &'b u32) -> impl SomeTrait<'a, 'b> { .. }
-    /// ```
-    ///
-    /// Here, the fact that `'b: 'a` is known only because of the
-    /// implied bounds from the `&'a &'b u32` parameter, and is not
-    /// "inherent" to the opaque type definition.
-    ///
-    /// # Parameters
-    ///
-    /// - `opaque_types` -- the map produced by `instantiate_opaque_types`
-    /// - `free_region_relations` -- something that can be used to relate
-    ///   the free regions (`'a`) that appear in the impl trait.
     #[instrument(level = "debug", skip(self))]
     pub fn register_member_constraints(
         &self,