about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-08-02 00:05:19 +0100
committervarkor <github@varkor.com>2019-08-02 02:44:36 +0100
commit2777386dc2e3c950980a469d4ac9701ccbab3a02 (patch)
treedb77502df9a3e35e81d9eaf17b816a7506a65cfb /src
parent70c8839f7cc14436a0ed3ab21d2ee14082e29e46 (diff)
downloadrust-2777386dc2e3c950980a469d4ac9701ccbab3a02.tar.gz
rust-2777386dc2e3c950980a469d4ac9701ccbab3a02.zip
Replace `abstract type` with type alias `impl Trait`
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/lowering.rs2
-rw-r--r--src/librustc/infer/opaque_types/mod.rs38
-rw-r--r--src/librustc/middle/resolve_lifetime.rs48
-rw-r--r--src/test/rustdoc-ui/coverage/traits.rs2
4 files changed, 45 insertions, 45 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
index f92ea8a008e..f2d4ceb1636 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -1894,7 +1894,7 @@ impl<'a> LoweringContext<'a> {
                     hir::LifetimeName::Implicit | hir::LifetimeName::Underscore => {
                         if self.collect_elided_lifetimes {
                             // Use `'_` for both implicit and underscore lifetimes in
-                            // `abstract type Foo<'_>: SomeTrait<'_>;`.
+                            // `type Foo<'_> = impl SomeTrait<'_>;`.
                             hir::LifetimeName::Underscore
                         } else {
                             return;
diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs
index b3577bea313..7105dd8f745 100644
--- a/src/librustc/infer/opaque_types/mod.rs
+++ b/src/librustc/infer/opaque_types/mod.rs
@@ -18,19 +18,19 @@ use syntax_pos::Span;
 
 pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
 
-/// Information about the opaque, abstract types whose values we
+/// Information about the opaque types whose values we
 /// are inferring in this function (these are the `impl Trait` that
 /// appear in the return type).
 #[derive(Copy, Clone, Debug)]
 pub struct OpaqueTypeDecl<'tcx> {
-    /// The substitutions that we apply to the abstract that this
+    /// The substitutions that we apply to the opaque type that this
     /// `impl Trait` desugars to. e.g., if:
     ///
     ///     fn foo<'a, 'b, T>() -> impl Trait<'a>
     ///
     /// winds up desugared to:
     ///
-    ///     abstract type Foo<'x, X>: Trait<'x>
+    ///     type Foo<'x, X> = impl Trait<'x>
     ///     fn foo<'a, 'b, T>() -> Foo<'a, T>
     ///
     /// then `substs` would be `['a, T]`.
@@ -50,7 +50,7 @@ pub struct OpaqueTypeDecl<'tcx> {
     /// over-approximated, but better than nothing.
     pub definition_span: Span,
 
-    /// The type variable that represents the value of the abstract type
+    /// The type variable that represents the value of the opaque type
     /// that we require. In other words, after we compile this function,
     /// we will be created a constraint like:
     ///
@@ -164,12 +164,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     /// Here, we have two `impl Trait` types whose values are being
     /// inferred (the `impl Bar<'a>` and the `impl
     /// Bar<'b>`). Conceptually, this is sugar for a setup where we
-    /// define underlying abstract types (`Foo1`, `Foo2`) and then, in
+    /// define underlying opaque types (`Foo1`, `Foo2`) and then, in
     /// the return type of `foo`, we *reference* those definitions:
     ///
     /// ```text
-    /// abstract type Foo1<'x>: Bar<'x>;
-    /// abstract type Foo2<'x>: Bar<'x>;
+    /// type Foo1<'x> = impl Bar<'x>;
+    /// type Foo2<'x> = impl Bar<'x>;
     /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
     ///                    //  ^^^^ ^^
     ///                    //  |    |
@@ -228,7 +228,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     ///
     /// This is actually a bit of a tricky constraint in general. We
     /// want to say that each variable (e.g., `'0`) can only take on
-    /// values that were supplied as arguments to the abstract type
+    /// values that were supplied as arguments to the opaque type
     /// (e.g., `'a` for `Foo1<'a>`) or `'static`, which is always in
     /// scope. We don't have a constraint quite of this kind in the current
     /// region checker.
@@ -279,10 +279,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     /// # The `free_region_relations` parameter
     ///
     /// The `free_region_relations` argument is used to find the
-    /// "minimum" of the regions supplied to a given abstract type.
+    /// "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 abstract type references (the `<'a>` in `Foo1<'a>`).
+    /// 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
@@ -298,7 +298,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     ///
     /// 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 abstract type definition.
+    /// "inherent" to the opaque type definition.
     ///
     /// # Parameters
     ///
@@ -361,7 +361,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
         // There were no `required_region_bounds`,
         // so we have to search for a `least_region`.
         // Go through all the regions used as arguments to the
-        // abstract type. These are the parameters to the abstract
+        // opaque type. These are the parameters to the opaque
         // type; so in our example above, `substs` would contain
         // `['a]` for the first impl trait and `'b` for the
         // second.
@@ -528,12 +528,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
 
     /// Given the fully resolved, instantiated type for an opaque
     /// type, i.e., the value of an inference variable like C1 or C2
-    /// (*), computes the "definition type" for an abstract type
+    /// (*), computes the "definition type" for an opaque type
     /// definition -- that is, the inferred value of `Foo1<'x>` or
     /// `Foo2<'x>` that we would conceptually use in its definition:
     ///
-    ///     abstract type Foo1<'x>: Bar<'x> = AAA; <-- this type AAA
-    ///     abstract type Foo2<'x>: Bar<'x> = BBB; <-- or this type BBB
+    ///     type Foo1<'x> = impl Bar<'x> = AAA; <-- this type AAA
+    ///     type Foo2<'x> = impl Bar<'x> = BBB; <-- or this type BBB
     ///     fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
     ///
     /// Note that these values are defined in terms of a distinct set of
@@ -994,15 +994,15 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
                     // value we are inferring.  At present, this is
                     // always true during the first phase of
                     // type-check, but not always true later on during
-                    // NLL. Once we support named abstract types more fully,
+                    // NLL. Once we support named opaque types more fully,
                     // this same scenario will be able to arise during all phases.
                     //
-                    // Here is an example using `abstract type` that indicates
-                    // the distinction we are checking for:
+                    // Here is an example using type alias `impl Trait`
+                    // that indicates the distinction we are checking for:
                     //
                     // ```rust
                     // mod a {
-                    //   pub abstract type Foo: Iterator;
+                    //   pub type Foo = impl Iterator;
                     //   pub fn make_foo() -> Foo { .. }
                     // }
                     //
diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs
index 4862af38022..90e449a0c67 100644
--- a/src/librustc/middle/resolve_lifetime.rs
+++ b/src/librustc/middle/resolve_lifetime.rs
@@ -268,17 +268,17 @@ enum Scope<'a> {
         track_lifetime_uses: bool,
 
         /// Whether or not this binder would serve as the parent
-        /// binder for abstract types introduced within. For example:
+        /// binder for opaque types introduced within. For example:
         ///
         ///     fn foo<'a>() -> impl for<'b> Trait<Item = impl Trait2<'a>>
         ///
-        /// Here, the abstract types we create for the `impl Trait`
+        /// Here, the opaque types we create for the `impl Trait`
         /// and `impl Trait2` references will both have the `foo` item
         /// as their parent. When we get to `impl Trait2`, we find
         /// that it is nested within the `for<>` binder -- this flag
         /// allows us to skip that when looking for the parent binder
-        /// of the resulting abstract type.
-        abstract_type_parent: bool,
+        /// of the resulting opaque type.
+        opaque_type_parent: bool,
 
         s: ScopeRef<'a>,
     },
@@ -526,7 +526,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                 let scope = Scope::Binder {
                     lifetimes,
                     next_early_index: index + non_lifetime_count,
-                    abstract_type_parent: true,
+                    opaque_type_parent: true,
                     track_lifetime_uses,
                     s: ROOT_SCOPE,
                 };
@@ -574,7 +574,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                     s: self.scope,
                     next_early_index,
                     track_lifetime_uses: true,
-                    abstract_type_parent: false,
+                    opaque_type_parent: false,
                 };
                 self.with(scope, |old_scope, this| {
                     // a bare fn has no bounds, so everything
@@ -622,9 +622,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
             hir::TyKind::Def(item_id, ref lifetimes) => {
                 // Resolve the lifetimes in the bounds to the lifetime defs in the generics.
                 // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
-                // `abstract type MyAnonTy<'b>: MyTrait<'b>;`
-                //                          ^            ^ this gets resolved in the scope of
-                //                                         the exist_ty generics
+                // `type MyAnonTy<'b> = impl MyTrait<'b>;`
+                //                 ^                  ^ this gets resolved in the scope of
+                //                                      the opaque_ty generics
                 let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node
                 {
                     // Named opaque `impl Trait` types are reached via `TyKind::Path`.
@@ -687,7 +687,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
 
                 // We want to start our early-bound indices at the end of the parent scope,
                 // not including any parent `impl Trait`s.
-                let mut index = self.next_early_index_for_abstract_type();
+                let mut index = self.next_early_index_for_opaque_type();
                 debug!("visit_ty: index = {}", index);
 
                 let mut elision = None;
@@ -728,7 +728,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                             next_early_index,
                             s: this.scope,
                             track_lifetime_uses: true,
-                            abstract_type_parent: false,
+                            opaque_type_parent: false,
                         };
                         this.with(scope, |_old_scope, this| {
                             this.visit_generics(generics);
@@ -743,7 +743,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                         next_early_index,
                         s: self.scope,
                         track_lifetime_uses: true,
-                        abstract_type_parent: false,
+                        opaque_type_parent: false,
                     };
                     self.with(scope, |_old_scope, this| {
                         this.visit_generics(generics);
@@ -796,7 +796,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                     next_early_index: index + non_lifetime_count,
                     s: self.scope,
                     track_lifetime_uses: true,
-                    abstract_type_parent: true,
+                    opaque_type_parent: true,
                 };
                 self.with(scope, |_old_scope, this| {
                     this.visit_generics(generics);
@@ -848,7 +848,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                     next_early_index: index + non_lifetime_count,
                     s: self.scope,
                     track_lifetime_uses: true,
-                    abstract_type_parent: true,
+                    opaque_type_parent: true,
                 };
                 self.with(scope, |_old_scope, this| {
                     this.visit_generics(generics);
@@ -879,7 +879,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                     next_early_index,
                     s: self.scope,
                     track_lifetime_uses: true,
-                    abstract_type_parent: true,
+                    opaque_type_parent: true,
                 };
                 self.with(scope, |_old_scope, this| {
                     this.visit_generics(generics);
@@ -967,7 +967,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                             s: self.scope,
                             next_early_index,
                             track_lifetime_uses: true,
-                            abstract_type_parent: false,
+                            opaque_type_parent: false,
                         };
                         let result = self.with(scope, |old_scope, this| {
                             this.check_lifetime_params(old_scope, &bound_generic_params);
@@ -1037,7 +1037,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                 s: self.scope,
                 next_early_index,
                 track_lifetime_uses: true,
-                abstract_type_parent: false,
+                opaque_type_parent: false,
             };
             self.with(scope, |old_scope, this| {
                 this.check_lifetime_params(old_scope, &trait_ref.bound_generic_params);
@@ -1753,7 +1753,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
             lifetimes,
             next_early_index,
             s: self.scope,
-            abstract_type_parent: true,
+            opaque_type_parent: true,
             track_lifetime_uses: false,
         };
         self.with(scope, move |old_scope, this| {
@@ -1762,7 +1762,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
         });
     }
 
-    fn next_early_index_helper(&self, only_abstract_type_parent: bool) -> u32 {
+    fn next_early_index_helper(&self, only_opaque_type_parent: bool) -> u32 {
         let mut scope = self.scope;
         loop {
             match *scope {
@@ -1770,9 +1770,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
 
                 Scope::Binder {
                     next_early_index,
-                    abstract_type_parent,
+                    opaque_type_parent,
                     ..
-                } if (!only_abstract_type_parent || abstract_type_parent) =>
+                } if (!only_opaque_type_parent || opaque_type_parent) =>
                 {
                     return next_early_index
                 }
@@ -1792,10 +1792,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
     }
 
     /// Returns the next index one would use for an `impl Trait` that
-    /// is being converted into an `abstract type`. This will be the
+    /// is being converted into an opaque type alias `impl Trait`. This will be the
     /// next early index from the enclosing item, for the most
-    /// part. See the `abstract_type_parent` field for more info.
-    fn next_early_index_for_abstract_type(&self) -> u32 {
+    /// part. See the `opaque_type_parent` field for more info.
+    fn next_early_index_for_opaque_type(&self) -> u32 {
         self.next_early_index_helper(false)
     }
 
diff --git a/src/test/rustdoc-ui/coverage/traits.rs b/src/test/rustdoc-ui/coverage/traits.rs
index 797ac00ad53..97f73b4e1f2 100644
--- a/src/test/rustdoc-ui/coverage/traits.rs
+++ b/src/test/rustdoc-ui/coverage/traits.rs
@@ -31,7 +31,7 @@ pub trait MyAlias = ThisTrait + Send + Sync;
 
 // FIXME(58624): once rustdoc can process opaque `impl Trait` types,
 // we need to make sure they're counted
-// /// woah, getting all abstract in here
+// /// woah, getting all opaque in here
 // pub type ThisExists = impl ThisTrait;
 //
 // /// why don't we get a little more concrete